File indexing completed on 2024-09-15 03:38:39
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2002 Carsten Pfeiffer <pfeiffer@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only 0006 */ 0007 0008 #include "kfilebookmarkhandler_p.h" 0009 0010 #include <stdio.h> 0011 #include <stdlib.h> 0012 0013 #include <QMenu> 0014 0015 #include <QStandardPaths> 0016 #include <kio/global.h> 0017 0018 #include "kfilewidget.h" 0019 0020 KFileBookmarkHandler::KFileBookmarkHandler(KFileWidget *widget) 0021 : QObject(widget) 0022 , KBookmarkOwner() 0023 , m_widget(widget) 0024 { 0025 setObjectName(QStringLiteral("KFileBookmarkHandler")); 0026 m_menu = new QMenu(widget); 0027 m_menu->setObjectName(QStringLiteral("bookmark menu")); 0028 0029 QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kfile/bookmarks.xml")); 0030 if (file.isEmpty()) { 0031 file = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/kfile/bookmarks.xml"); 0032 } 0033 0034 m_bookmarkManager = new KBookmarkManager(file, this); 0035 0036 m_bookmarkMenu = new KBookmarkMenu(m_bookmarkManager, this, m_menu); 0037 } 0038 0039 KFileBookmarkHandler::~KFileBookmarkHandler() 0040 { 0041 delete m_bookmarkMenu; 0042 } 0043 0044 void KFileBookmarkHandler::openBookmark(const KBookmark &bm, Qt::MouseButtons, Qt::KeyboardModifiers) 0045 { 0046 Q_EMIT openUrl(bm.url().toString()); 0047 } 0048 0049 QUrl KFileBookmarkHandler::currentUrl() const 0050 { 0051 return m_widget->baseUrl(); 0052 } 0053 0054 QString KFileBookmarkHandler::currentTitle() const 0055 { 0056 return m_widget->baseUrl().toDisplayString(); 0057 } 0058 0059 QString KFileBookmarkHandler::currentIcon() const 0060 { 0061 return KIO::iconNameForUrl(currentUrl()); 0062 } 0063 0064 #include "moc_kfilebookmarkhandler_p.cpp"