File indexing completed on 2024-04-28 04:58:27
0001 /* This file is part of the KDE project 0002 SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org> 0003 SPDX-FileCopyrightText: 2003 Waldo Bastian <bastian@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only 0006 */ 0007 0008 #ifndef KONQ_SIDEBARTREEITEM_H 0009 #define KONQ_SIDEBARTREEITEM_H 0010 0011 #include <QStringList> 0012 #include <Qt3Support/Q3ListView> 0013 #include <Qt3Support/Q3UriDrag> 0014 #include <QUrl> 0015 0016 class KonqSidebarTree; 0017 class KonqSidebarTreeItem; 0018 class KonqSidebarTreeModule; 0019 class KonqSidebarTreeTopLevelItem; 0020 0021 /** 0022 * The base class for any item in the tree. 0023 * Items belonging to a given module are created and managed by the module, 0024 * but they should all be KonqSidebarTreeItems, for the event handling in KonqSidebarTree. 0025 */ 0026 class KonqSidebarTreeItem : public Q3ListViewItem 0027 { 0028 public: 0029 // Create an item under another one 0030 KonqSidebarTreeItem(KonqSidebarTreeItem *parentItem, KonqSidebarTreeTopLevelItem *topLevelItem); 0031 0032 void initItem(KonqSidebarTreeTopLevelItem *topLevelItem); 0033 0034 virtual ~KonqSidebarTreeItem(); 0035 0036 // Whether the item accepts a drop consisting in those @p formats 0037 virtual bool acceptsDrops(const Q3StrList &) 0038 { 0039 return false; 0040 } 0041 0042 // Handle a drop on this item. If you didn't want it, you shouldn't 0043 // have return true in acceptsDrops :) 0044 virtual void drop(QDropEvent *) {} 0045 0046 // Create a drag object from this item. 0047 virtual bool populateMimeData(QMimeData *mimeData, bool move) = 0; 0048 0049 virtual void middleButtonClicked(); 0050 virtual void rightButtonPressed() = 0; 0051 0052 virtual void paste() {} 0053 virtual void trash() {} 0054 virtual void del() {} 0055 virtual void rename() {} 0056 virtual void rename(const QString &) {} 0057 0058 // The URL to open when this link is clicked 0059 virtual QUrl externalURL() const = 0; 0060 0061 // The mimetype to use when this link is clicked 0062 // If unknown, return QString(), konq will determine the mimetype itself 0063 virtual QString externalMimeType() const 0064 { 0065 return QString(); 0066 } 0067 0068 // overwrite this if you want a tooltip shown on your item 0069 virtual QString toolTipText() const 0070 { 0071 return QString(); 0072 } 0073 0074 // Called when this item is selected 0075 // Reimplement, and call tree()->part()->extension()->enableActions(...) 0076 virtual void itemSelected() = 0; 0077 0078 // Basically, true for directories and toplevel items 0079 void setListable(bool b) 0080 { 0081 m_bListable = b; 0082 } 0083 bool isListable() const 0084 { 0085 return m_bListable; 0086 } 0087 0088 // Whether clicking on the item should open the "external URL" of the item 0089 void setClickable(bool b) 0090 { 0091 m_bClickable = b; 0092 } 0093 bool isClickable() const 0094 { 0095 return m_bClickable; 0096 } 0097 0098 // Whether the item is a toplevel item 0099 virtual bool isTopLevelItem() const 0100 { 0101 return false; 0102 } 0103 0104 KonqSidebarTreeTopLevelItem *topLevelItem() const 0105 { 0106 return m_topLevelItem; 0107 } 0108 0109 // returns the module associated to our toplevel item 0110 KonqSidebarTreeModule *module() const; 0111 0112 // returns the tree inside which this item is 0113 KonqSidebarTree *tree() const; 0114 0115 virtual QString key(int column, bool) const 0116 { 0117 return text(column).toLower(); 0118 } 0119 0120 // List of alternative names (URLs) this entry is known under 0121 QStringList alias; 0122 protected: 0123 // Create an item at the toplevel - only for toplevel items -> protected 0124 KonqSidebarTreeItem(KonqSidebarTree *parent, KonqSidebarTreeTopLevelItem *topLevelItem); 0125 0126 KonqSidebarTreeTopLevelItem *m_topLevelItem; 0127 bool m_bListable: 1; 0128 bool m_bClickable: 1; 0129 }; 0130 0131 #endif // KONQ_SIDEBARTREEITEM_H