KIO

kfilebookmarkhandler.cpp
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
20KFileBookmarkHandler::KFileBookmarkHandler(KFileWidget *widget)
21 : QObject(widget)
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(QStandardPaths::GenericDataLocation, QStringLiteral("kfile/bookmarks.xml"));
30 if (file.isEmpty()) {
32 }
33
34 m_bookmarkManager = new KBookmarkManager(file, this);
35
36 m_bookmarkMenu = new KBookmarkMenu(m_bookmarkManager, this, m_menu);
37}
38
39KFileBookmarkHandler::~KFileBookmarkHandler()
40{
41 delete m_bookmarkMenu;
42}
43
44void KFileBookmarkHandler::openBookmark(const KBookmark &bm, Qt::MouseButtons, Qt::KeyboardModifiers)
45{
46 Q_EMIT openUrl(bm.url().toString());
47}
48
49QUrl KFileBookmarkHandler::currentUrl() const
50{
51 return m_widget->baseUrl();
52}
53
54QString KFileBookmarkHandler::currentTitle() const
55{
56 return m_widget->baseUrl().toDisplayString();
57}
58
59QString KFileBookmarkHandler::currentIcon() const
60{
61 return KIO::iconNameForUrl(currentUrl());
62}
63
64#include "moc_kfilebookmarkhandler_p.cpp"
QUrl url() const
File selector widget.
Definition kfilewidget.h:49
KIOCORE_EXPORT QString iconNameForUrl(const QUrl &url)
Return the icon name for a URL.
Definition global.cpp:188
QString locate(StandardLocation type, const QString &fileName, LocateOptions options)
QString writableLocation(StandardLocation type)
bool isEmpty() const const
typedef KeyboardModifiers
typedef MouseButtons
QString toString(FormattingOptions options) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:28 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.