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
|
// Copyright (c) 2003 Charles Samuels <charles@kde.org>
// See the file COPYING for redistribution terms.
#ifndef QUERY_H
#define QUERY_H
#include "base.h"
#include <tqregexp.h>
#include <tqstring.h>
class Query;
class QDomElement;
class QueryGroup
{
friend class Query;
QueryGroup *mFirstChild;
QueryGroup *mNextSibling;
int mFuzzyness;
int mOptions;
TQString mPropertyName;
TQString mPresentation;
TQRegExp mValue;
public:
QueryGroup();
QueryGroup(const QueryGroup ©);
QueryGroup &operator =(const QueryGroup ©);
/**
* delete my first child, and my next sibling
**/
~QueryGroup();
void setFirstChild(QueryGroup *g) { mFirstChild = g; }
void setNextSibling(QueryGroup *g) { mNextSibling = g; }
QueryGroup *firstChild() { return mFirstChild; }
const QueryGroup *firstChild() const { return mFirstChild; }
QueryGroup *lastChild();
QueryGroup *nextSibling() { return mNextSibling; }
const QueryGroup *nextSibling() const { return mNextSibling; }
/**
* insert @p after as a sibling immediately after this
**/
void insertAfter(QueryGroup *insert);
/**
* insert @p immediately after this as a child
**/
void insertUnder(QueryGroup *insert);
/**
* Try get the "best fit" for the two parameters
**/
void move(Query *query, QueryGroup *under, QueryGroup *after);
TQString propertyName() const { return mPropertyName; }
TQRegExp value() const { return mValue; }
TQString presentation() const { return mPresentation; }
void setPropertyName(const TQString &v) { mPropertyName = v; }
void setPresentation(const TQString &v) { mPresentation = v; }
void setValue(const TQRegExp &v) { mValue = v; }
enum Fuzzyness
{
Case = 1<<0, Spaces = 1<<1, Articles = 1<<2, Symbols = 1<<3
};
bool fuzzyness(Fuzzyness f) const;
enum Option
{
AutoHide = 1<<0, Disabled = 1<<1, Playable = 1<<2,
ChildrenVisible = 1<<3, AutoOpen = 1<<4
};
bool option(Option option) const;
void setOption(Option option, bool on);
/**
* @return if I match @p file
**/
bool matches(const File &file) const;
TQString presentation(const File &file) const;
private:
/**
* apply all the "normalizing" transformations according
* to the fuzzyness
**/
TQString fuzzify(const TQString &str) const;
/**
* @returns the previous or parent of this item (slow)
**/
QueryGroup *previous(Query *query);
QueryGroup *previous(QueryGroup *startWith);
};
/**
* a query is the tree structure that is shown to the user
**/
class Query
{
QueryGroup *mGroupFirst;
TQString mName;
public:
Query();
Query(const Query ©);
~Query();
Query &operator =(const Query ©);
QueryGroup *firstChild();
const QueryGroup *firstChild() const;
void setFirstChild(QueryGroup *g);
void insertFirst(QueryGroup *g);
void clear();
/**
* @returns the name to be used internally
**/
TQString name() const { return mName; }
void setName(const TQString &name) { mName = name; }
/**
* @returns the name of the query
**/
TQString load(const TQString &filename);
void save(const TQString &name, TQDomElement &element);
void save(const TQString &name, const TQString &filename);
/**
* remove any trace of this from the tree, but don't actually delete it
**/
void take(QueryGroup *item);
void dump();
/**
* @returns the name of this query as used internally by the db.
*
* Will give it a name in the db if necessary
**/
TQString dbname(Base *base);
private:
void loadGroup(TQDomElement element, QueryGroup *parent=0);
void saveGroup(TQDomElement &parent, QueryGroup *group);
void deepCopy(const QueryGroup *from, QueryGroup *toParent);
/**
* @returns the name of the query
**/
TQString load(TQDomElement element);
};
#endif
|