1 /* This file is part of the KDE project 2 SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org> 3 4 SPDX-License-Identifier: LGPL-2.0-only 5 */ 6 7 #ifndef KONQ_SIDEBARTREETOPLEVELITEM_H 8 #define KONQ_SIDEBARTREETOPLEVELITEM_H 9 10 #include "konq_sidebartreeitem.h" 11 #include <konq_operations.h> 12 13 class QMimeData; 14 class KonqSidebarTreeModule; 15 16 /** 17 * Each toplevel item (created from a desktop file) 18 * points to the module that handles it 19 --> this doesn't prevent the same module from handling multiple toplevel items, 20 but we don't do that currently. 21 */ 22 class KonqSidebarTreeTopLevelItem : public KonqSidebarTreeItem 23 { 24 public: 25 /** 26 * Create a toplevel toplevel-item :) 27 * @param module the module handling this toplevel item 28 * @param path the path to the desktop file that was the reason for creating this item 29 */ KonqSidebarTreeTopLevelItem(KonqSidebarTree * parent,KonqSidebarTreeModule * module,const QString & path)30 KonqSidebarTreeTopLevelItem(KonqSidebarTree *parent, KonqSidebarTreeModule *module, const QString &path) 31 : KonqSidebarTreeItem(parent, 0L), m_module(module), m_path(path), m_bTopLevelGroup(false) 32 { 33 init(); 34 } 35 36 /** 37 * Create a toplevel-item under a toplevel group 38 * @param module the module handling this toplevel item 39 * @param path the path to the desktop file that was the reason for creating this item 40 */ KonqSidebarTreeTopLevelItem(KonqSidebarTreeItem * parentItem,KonqSidebarTreeModule * module,const QString & path)41 KonqSidebarTreeTopLevelItem(KonqSidebarTreeItem *parentItem, KonqSidebarTreeModule *module, const QString &path) 42 : KonqSidebarTreeItem(parentItem, 0L), m_module(module), m_path(path), m_bTopLevelGroup(false) 43 { 44 init(); 45 } 46 47 void init(); 48 49 virtual bool acceptsDrops(const Q3StrList &formats); 50 virtual void drop(QDropEvent *ev); 51 virtual bool populateMimeData(QMimeData *mimeData, bool move); 52 virtual void middleButtonClicked(); 53 virtual void rightButtonPressed(); 54 55 virtual void paste(); 56 virtual void trash(); 57 virtual void del(); 58 virtual void rename(); // start a rename operation 59 virtual void rename(const QString &name); // do the actual renaming 60 61 virtual void setOpen(bool open); 62 63 // Whether the item is a toplevel item - true isTopLevelItem()64 virtual bool isTopLevelItem() const 65 { 66 return true; 67 } 68 externalURL()69 virtual QUrl externalURL() const 70 { 71 return m_externalURL; 72 } 73 74 virtual QString toolTipText() const; 75 76 virtual void itemSelected(); 77 78 // The module should call this for each toplevel item that is passed to it 79 // unless it calls setClickable(false) setExternalURL(const QUrl & url)80 void setExternalURL(const QUrl &url) 81 { 82 m_externalURL = url; 83 } 84 85 // Whether the item is a toplevel group. [Only matters for dnd] setTopLevelGroup(bool b)86 void setTopLevelGroup(bool b) 87 { 88 m_bTopLevelGroup = b; 89 } isTopLevelGroup()90 bool isTopLevelGroup() const 91 { 92 return m_bTopLevelGroup; 93 } 94 95 // The module that handles the subtree below this toplevel item module()96 KonqSidebarTreeModule *module() const 97 { 98 return m_module; 99 } 100 101 // The path to the desktop file responsible for this toplevel item path()102 QString path() const 103 { 104 return m_path; 105 } 106 107 protected: 108 void delOperation(KonqOperations::Operation method); 109 KonqSidebarTreeModule *m_module; 110 QString m_path; 111 QString m_comment; 112 QUrl m_externalURL; 113 bool m_bTopLevelGroup; 114 }; 115 116 #endif // KONQ_SIDEBARTREETOPLEVELITEM_H 117