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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
// Copyright (c) 2003 Charles Samuels <charles@kde.org>
// See the file COPYING for redistribution terms.
#ifndef TREE_H
#define TREE_H
#include <tqwidget.h>
#include <klistview.h>
#include "base.h"
#include "query.h"
#include "file.h"
class Oblique;
class Tree;
class TreeItem : public TDEListViewItem
{
QueryGroup *mGroup;
File mFile;
bool mUserOpened:1;
bool mHidden:1;
public:
TreeItem(Tree *parent, QueryGroup *group, const File &file, const TQString &p=0);
TreeItem(TreeItem *parent, QueryGroup *group, const File &file, const TQString &p=0);
~TreeItem();
QueryGroup *group() { return mGroup; }
const QueryGroup *group() const { return mGroup; }
void setGroup(QueryGroup *group) { mGroup = group; }
TreeItem *parent() { return static_cast<TreeItem*>(TDEListViewItem::parent()); }
Tree *tree();
TreeItem *itemBelow() { return static_cast<TreeItem*>(TDEListViewItem::itemBelow()); }
TreeItem *firstChild() { return static_cast<TreeItem*>(TDEListViewItem::firstChild()); }
TreeItem *nextSibling() { return static_cast<TreeItem*>(TDEListViewItem::nextSibling()); }
// for gdb, which sucks.
TQString presentation() const;
File file() { return mFile; }
void setFile(File file) { mFile = file; }
void setOpen(bool o);
TreeItem *find(File item);
bool playable() const;
/**
* get the next item that is playable logically.
* that is, if it has a File, and its parent hasn't a
* File
**/
TreeItem *nextPlayable();
void paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int align);
virtual int compare(TQListViewItem * i, int col, bool) const;
/**
* open my parents so that I'm visible, if I'm playing or
* close my parents if I'm not playing, and the user
* didn't open
**/
void autoExpand();
bool userOpened() const { return mUserOpened; }
bool hideIfNoMatch(const TQString &match);
void setHidden(bool on);
virtual void setup();
private:
TreeItem *next();
void forceAutoExpand();
};
class FileMenu;
class Loader;
class Tree : public TDEListView
{
Q_OBJECT
Oblique *mOblique;
Query mQuery;
TreeItem *mCurrent;
FileMenu *lastMenu;
Slice *mSlice;
TQString mFileOfQuery;
friend class TreeItem;
int mPlayableItemCount; // used by the friendship
TQPtrList<TreeItem> mAutoExpanded;
unsigned int mAutoExpanding;
Loader *mLoader;
public:
Tree(Oblique *oblique, TQWidget *parent=0);
~Tree();
TreeItem *firstChild();
TreeItem *find(File item);
TreeItem *current() { return mCurrent; }
Query *query() { return &mQuery; }
Oblique *oblique() { return mOblique; }
Slice *slice() { return mSlice; }
TQString fileOfQuery() const { return mFileOfQuery; }
void clear();
int playableItemCount() const { return mPlayableItemCount; }
void addAutoExpanded(TreeItem *i) { mAutoExpanded.append(i); }
void removeAutoExpanded(TreeItem *i) { mAutoExpanded.removeRef(i); }
void resetAutoExpanded() { mAutoExpanded.clear(); }
void setAutoExpanding(bool e) { mAutoExpanding += e ? 1 : -1; }
bool autoExpanding() const { return mAutoExpanding; }
void deleted(TreeItem *item);
bool setSchema(const TQString &name);
protected:
virtual TQDragObject *dragObject();
void movableDropEvent(TQListViewItem* parent, TQListViewItem* afterme);
public slots:
void insert(TreeItem *replace, File file);
void insert(File file);
void remove(File file);
void update(File file);
void setCurrent(TreeItem *cur);
void setSlice(Slice *sl);
void checkInsert(Slice*, File);
void checkRemove(Slice*, File);
/**
* the resulting presentation of this item must contain the string @p text
* or it will not be displayed
* (used for Jump)
**/
void setLimit(const TQString &text);
private slots:
void contextMenu(TDEListView* l, TQListViewItem* i, const TQPoint& p);
void play(TQListViewItem *item);
void destroyLoader();
void dropped(TQPtrList<TQListViewItem> &items, TQPtrList<TQListViewItem> &, TQPtrList<TQListViewItem> &afterNow);
signals:
void selected(TreeItem *);
private:
/**
* check if it fits into the group, and create
* the tree nodes for it
**/
TreeItem *collate(TreeItem *fix, QueryGroup *group, const File &file, TreeItem *childOf=0);
TreeItem *collate(const File &file, TreeItem *childOf=0)
{
if (!mQuery.firstChild()) return 0;
return collate(0, mQuery.firstChild(), file, childOf);
}
TreeItem *collate(TreeItem *fix, const File &file, TreeItem *childOf=0)
{
if (!mQuery.firstChild()) return 0;
return collate(fix, mQuery.firstChild(), file, childOf);
}
TreeItem *node(TreeItem *fix, QueryGroup *group, const File &file, TreeItem *childOf);
/**
* remove the siblings and children of the treeitem
**/
void remove(TreeItem *, const File &file);
void limitHide(TreeItem *i, const TQString &text);
void reload();
};
#endif
|