1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/* This file is part of the KDE project
Copyright (C) 2000 David Faure <[email protected]>
Copyright (C) 2003 Waldo Bastian <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef konq_treeitem_h
#define konq_treeitem_h
#include <qlistview.h>
#include <qstringlist.h>
#include <kurl.h>
class QPainter;
class QDragObject;
class QStrList;
class KonqSidebarTree;
class KonqSidebarTreeItem;
class KonqSidebarTreeModule;
class KonqSidebarTreeTopLevelItem;
/**
* The base class for any item in the tree.
* Items belonging to a given module are created and managed by the module,
* but they should all be KonqSidebarTreeItems, for the event handling in KonqSidebarTree.
*/
class KonqSidebarTreeItem : public QListViewItem
{
public:
// Create an item under another one
KonqSidebarTreeItem( KonqSidebarTreeItem *parentItem, KonqSidebarTreeTopLevelItem *topLevelItem );
void initItem( KonqSidebarTreeTopLevelItem *topLevelItem );
virtual ~KonqSidebarTreeItem();
// Whether the item accepts a drop consisting in those @p formats
virtual bool acceptsDrops( const QStrList & ) { return false; }
// Handle a drop on this item. If you didn't want it, you shouln't
// have return true in acceptsDrops :)
virtual void drop( QDropEvent * ) {}
// Create a drag object from this item.
virtual QDragObject * dragObject( QWidget * parent, bool move = false ) = 0;
virtual void middleButtonClicked();
virtual void rightButtonPressed() = 0;
virtual void paste() {}
virtual void trash() {}
virtual void del() {}
virtual void shred() {}
virtual void rename() {}
virtual void rename( const QString& ) {}
// The URL to open when this link is clicked
virtual KURL externalURL() const = 0;
// The mimetype to use when this link is clicked
// If unknown, return QString::null, konq will determine the mimetype itself
virtual QString externalMimeType() const { return QString::null; }
// overwrite this if you want a tooltip shown on your item
virtual QString toolTipText() const { return QString::null; }
// Called when this item is selected
// Reimplement, and call tree()->part()->extension()->enableActions(...)
virtual void itemSelected() = 0;
// Basically, true for directories and toplevel items
void setListable( bool b ) { m_bListable = b; }
bool isListable() const { return m_bListable; }
// Whether clicking on the item should open the "external URL" of the item
void setClickable( bool b ) { m_bClickable = b; }
bool isClickable() const { return m_bClickable; }
// Whether the item is a toplevel item
virtual bool isTopLevelItem() const { return false; }
KonqSidebarTreeTopLevelItem * topLevelItem() const { return m_topLevelItem; }
// returns the module associated to our toplevel item
KonqSidebarTreeModule * module() const;
// returns the tree inside which this item is
KonqSidebarTree *tree() const;
virtual QString key( int column, bool ) const { return text( column ).lower(); }
// List of alternative names (URLs) this entry is known under
QStringList alias;
protected:
// Create an item at the toplevel - only for toplevel items -> protected
KonqSidebarTreeItem( KonqSidebarTree *parent, KonqSidebarTreeTopLevelItem *topLevelItem );
KonqSidebarTreeTopLevelItem *m_topLevelItem;
bool m_bListable:1;
bool m_bClickable:1;
};
#endif
|