File indexing completed on 2024-04-28 04:58:28
0001 /* This file is part of the KDE project 0002 SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #ifndef KONQ_SIDEBARTREETOPLEVELITEM_H 0008 #define KONQ_SIDEBARTREETOPLEVELITEM_H 0009 0010 #include "konq_sidebartreeitem.h" 0011 #include <konq_operations.h> 0012 0013 class QMimeData; 0014 class KonqSidebarTreeModule; 0015 0016 /** 0017 * Each toplevel item (created from a desktop file) 0018 * points to the module that handles it 0019 --> this doesn't prevent the same module from handling multiple toplevel items, 0020 but we don't do that currently. 0021 */ 0022 class KonqSidebarTreeTopLevelItem : public KonqSidebarTreeItem 0023 { 0024 public: 0025 /** 0026 * Create a toplevel toplevel-item :) 0027 * @param module the module handling this toplevel item 0028 * @param path the path to the desktop file that was the reason for creating this item 0029 */ 0030 KonqSidebarTreeTopLevelItem(KonqSidebarTree *parent, KonqSidebarTreeModule *module, const QString &path) 0031 : KonqSidebarTreeItem(parent, 0L), m_module(module), m_path(path), m_bTopLevelGroup(false) 0032 { 0033 init(); 0034 } 0035 0036 /** 0037 * Create a toplevel-item under a toplevel group 0038 * @param module the module handling this toplevel item 0039 * @param path the path to the desktop file that was the reason for creating this item 0040 */ 0041 KonqSidebarTreeTopLevelItem(KonqSidebarTreeItem *parentItem, KonqSidebarTreeModule *module, const QString &path) 0042 : KonqSidebarTreeItem(parentItem, 0L), m_module(module), m_path(path), m_bTopLevelGroup(false) 0043 { 0044 init(); 0045 } 0046 0047 void init(); 0048 0049 virtual bool acceptsDrops(const Q3StrList &formats); 0050 virtual void drop(QDropEvent *ev); 0051 virtual bool populateMimeData(QMimeData *mimeData, bool move); 0052 virtual void middleButtonClicked(); 0053 virtual void rightButtonPressed(); 0054 0055 virtual void paste(); 0056 virtual void trash(); 0057 virtual void del(); 0058 virtual void rename(); // start a rename operation 0059 virtual void rename(const QString &name); // do the actual renaming 0060 0061 virtual void setOpen(bool open); 0062 0063 // Whether the item is a toplevel item - true 0064 virtual bool isTopLevelItem() const 0065 { 0066 return true; 0067 } 0068 0069 virtual QUrl externalURL() const 0070 { 0071 return m_externalURL; 0072 } 0073 0074 virtual QString toolTipText() const; 0075 0076 virtual void itemSelected(); 0077 0078 // The module should call this for each toplevel item that is passed to it 0079 // unless it calls setClickable(false) 0080 void setExternalURL(const QUrl &url) 0081 { 0082 m_externalURL = url; 0083 } 0084 0085 // Whether the item is a toplevel group. [Only matters for dnd] 0086 void setTopLevelGroup(bool b) 0087 { 0088 m_bTopLevelGroup = b; 0089 } 0090 bool isTopLevelGroup() const 0091 { 0092 return m_bTopLevelGroup; 0093 } 0094 0095 // The module that handles the subtree below this toplevel item 0096 KonqSidebarTreeModule *module() const 0097 { 0098 return m_module; 0099 } 0100 0101 // The path to the desktop file responsible for this toplevel item 0102 QString path() const 0103 { 0104 return m_path; 0105 } 0106 0107 protected: 0108 void delOperation(KonqOperations::Operation method); 0109 KonqSidebarTreeModule *m_module; 0110 QString m_path; 0111 QString m_comment; 0112 QUrl m_externalURL; 0113 bool m_bTopLevelGroup; 0114 }; 0115 0116 #endif // KONQ_SIDEBARTREETOPLEVELITEM_H