1 | /* |
---|---|
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 2002 Carsten Pfeiffer <pfeiffer@kde.org> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-only |
6 | */ |
7 | |
8 | #include "kfilebookmarkhandler_p.h" |
9 | |
10 | #include <stdio.h> |
11 | #include <stdlib.h> |
12 | |
13 | #include <QMenu> |
14 | |
15 | #include <QStandardPaths> |
16 | #include <kio/global.h> |
17 | |
18 | #include "kfilewidget.h" |
19 | |
20 | KFileBookmarkHandler::KFileBookmarkHandler(KFileWidget *widget) |
21 | : QObject(widget) |
22 | , KBookmarkOwner() |
23 | , m_widget(widget) |
24 | { |
25 | setObjectName(QStringLiteral("KFileBookmarkHandler")); |
26 | m_menu = new QMenu(widget); |
27 | m_menu->setObjectName(QStringLiteral("bookmark menu")); |
28 | |
29 | QString file = QStandardPaths::locate(type: QStandardPaths::GenericDataLocation, QStringLiteral("kfile/bookmarks.xml")); |
30 | if (file.isEmpty()) { |
31 | file = QStandardPaths::writableLocation(type: QStandardPaths::GenericDataLocation) + QLatin1String("/kfile/bookmarks.xml"); |
32 | } |
33 | |
34 | m_bookmarkManager = new KBookmarkManager(file, this); |
35 | |
36 | m_bookmarkMenu = new KBookmarkMenu(m_bookmarkManager, this, m_menu); |
37 | } |
38 | |
39 | KFileBookmarkHandler::~KFileBookmarkHandler() |
40 | { |
41 | delete m_bookmarkMenu; |
42 | } |
43 | |
44 | void KFileBookmarkHandler::openBookmark(const KBookmark &bm, Qt::MouseButtons, Qt::KeyboardModifiers) |
45 | { |
46 | Q_EMIT openUrl(url: bm.url().toString()); |
47 | } |
48 | |
49 | QUrl KFileBookmarkHandler::currentUrl() const |
50 | { |
51 | return m_widget->baseUrl(); |
52 | } |
53 | |
54 | QString KFileBookmarkHandler::currentTitle() const |
55 | { |
56 | return m_widget->baseUrl().toDisplayString(); |
57 | } |
58 | |
59 | QString KFileBookmarkHandler::currentIcon() const |
60 | { |
61 | return KIO::iconNameForUrl(url: currentUrl()); |
62 | } |
63 | |
64 | #include "moc_kfilebookmarkhandler_p.cpp" |
65 |