diff options
Diffstat (limited to 'linden/indra/llui/llviewquery.cpp')
-rw-r--r-- | linden/indra/llui/llviewquery.cpp | 252 |
1 files changed, 126 insertions, 126 deletions
diff --git a/linden/indra/llui/llviewquery.cpp b/linden/indra/llui/llviewquery.cpp index 4867116..89b2192 100644 --- a/linden/indra/llui/llviewquery.cpp +++ b/linden/indra/llui/llviewquery.cpp | |||
@@ -1,8 +1,8 @@ | |||
1 | /** | 1 | /** |
2 | * @file llviewquery.cpp | 2 | * @file llviewquery.cpp |
3 | * @brief Implementation of view query class. | 3 | * @brief Implementation of view query class. |
4 | * | 4 | * |
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | 5 | * Copyright (c) 2001-2007, Linden Research, Inc. |
6 | * | 6 | * |
7 | * The source code in this file ("Source Code") is provided by Linden Lab | 7 | * The source code in this file ("Source Code") is provided by Linden Lab |
8 | * to you under the terms of the GNU General Public License, version 2.0 | 8 | * to you under the terms of the GNU General Public License, version 2.0 |
@@ -22,124 +22,124 @@ | |||
22 | * | 22 | * |
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | 23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO |
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | 24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, |
25 | * COMPLETENESS OR PERFORMANCE. | 25 | * COMPLETENESS OR PERFORMANCE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "llview.h" | 28 | #include "llview.h" |
29 | #include "lluictrl.h" | 29 | #include "lluictrl.h" |
30 | #include "llviewquery.h" | 30 | #include "llviewquery.h" |
31 | 31 | ||
32 | void LLQuerySorter::operator() (LLView * parent, viewList_t &children) const {} | 32 | void LLQuerySorter::operator() (LLView * parent, viewList_t &children) const {} |
33 | 33 | ||
34 | filterResult_t LLNoLeavesFilter::operator() (const LLView* const view, const viewList_t & children) const | 34 | filterResult_t LLNoLeavesFilter::operator() (const LLView* const view, const viewList_t & children) const |
35 | { | 35 | { |
36 | return filterResult_t(!(view->getChildList()->size() == 0), TRUE); | 36 | return filterResult_t(!(view->getChildList()->size() == 0), TRUE); |
37 | } | 37 | } |
38 | 38 | ||
39 | filterResult_t LLVisibleFilter::operator() (const LLView* const view, const viewList_t & children) const | 39 | filterResult_t LLVisibleFilter::operator() (const LLView* const view, const viewList_t & children) const |
40 | { | 40 | { |
41 | return filterResult_t(view->getVisible(), view->getVisible()); | 41 | return filterResult_t(view->getVisible(), view->getVisible()); |
42 | } | 42 | } |
43 | filterResult_t LLEnabledFilter::operator() (const LLView* const view, const viewList_t & children) const | 43 | filterResult_t LLEnabledFilter::operator() (const LLView* const view, const viewList_t & children) const |
44 | { | 44 | { |
45 | return filterResult_t(view->getEnabled(), view->getEnabled()); | 45 | return filterResult_t(view->getEnabled(), view->getEnabled()); |
46 | } | 46 | } |
47 | filterResult_t LLTabStopFilter::operator() (const LLView* const view, const viewList_t & children) const | 47 | filterResult_t LLTabStopFilter::operator() (const LLView* const view, const viewList_t & children) const |
48 | { | 48 | { |
49 | return filterResult_t(view->isCtrl() && static_cast<const LLUICtrl* const>(view)->hasTabStop(), | 49 | return filterResult_t(view->isCtrl() && static_cast<const LLUICtrl* const>(view)->hasTabStop(), |
50 | view->canFocusChildren()); | 50 | view->canFocusChildren()); |
51 | } | 51 | } |
52 | 52 | ||
53 | // LLViewQuery | 53 | // LLViewQuery |
54 | 54 | ||
55 | LLViewQuery::LLViewQuery(): mPreFilters(), mPostFilters(), mSorterp() | 55 | LLViewQuery::LLViewQuery(): mPreFilters(), mPostFilters(), mSorterp() |
56 | { | 56 | { |
57 | } | 57 | } |
58 | 58 | ||
59 | void LLViewQuery::addPreFilter(const LLQueryFilter* prefilter) { mPreFilters.push_back(prefilter); } | 59 | void LLViewQuery::addPreFilter(const LLQueryFilter* prefilter) { mPreFilters.push_back(prefilter); } |
60 | 60 | ||
61 | void LLViewQuery::addPostFilter(const LLQueryFilter* postfilter) { mPostFilters.push_back(postfilter); } | 61 | void LLViewQuery::addPostFilter(const LLQueryFilter* postfilter) { mPostFilters.push_back(postfilter); } |
62 | 62 | ||
63 | const LLViewQuery::filterList_t & LLViewQuery::getPreFilters() const { return mPreFilters; } | 63 | const LLViewQuery::filterList_t & LLViewQuery::getPreFilters() const { return mPreFilters; } |
64 | 64 | ||
65 | const LLViewQuery::filterList_t & LLViewQuery::getPostFilters() const { return mPostFilters; } | 65 | const LLViewQuery::filterList_t & LLViewQuery::getPostFilters() const { return mPostFilters; } |
66 | 66 | ||
67 | void LLViewQuery::setSorter(const LLQuerySorter* sorterp) { mSorterp = sorterp; } | 67 | void LLViewQuery::setSorter(const LLQuerySorter* sorterp) { mSorterp = sorterp; } |
68 | const LLQuerySorter* LLViewQuery::getSorter() const { return mSorterp; } | 68 | const LLQuerySorter* LLViewQuery::getSorter() const { return mSorterp; } |
69 | 69 | ||
70 | viewList_t LLViewQuery::run(LLView * view) const | 70 | viewList_t LLViewQuery::run(LLView * view) const |
71 | { | 71 | { |
72 | viewList_t result; | 72 | viewList_t result; |
73 | 73 | ||
74 | filterResult_t pre = runFilters(view, viewList_t(), mPreFilters); | 74 | filterResult_t pre = runFilters(view, viewList_t(), mPreFilters); |
75 | if(!pre.first && !pre.second) | 75 | if(!pre.first && !pre.second) |
76 | { | 76 | { |
77 | // skip post filters completely if we're not including ourselves or the children | 77 | // skip post filters completely if we're not including ourselves or the children |
78 | return result; | 78 | return result; |
79 | } | 79 | } |
80 | if(pre.second) | 80 | if(pre.second) |
81 | { | 81 | { |
82 | // run filters on children | 82 | // run filters on children |
83 | viewList_t filtered_children; | 83 | viewList_t filtered_children; |
84 | filterChildren(view, filtered_children); | 84 | filterChildren(view, filtered_children); |
85 | filterResult_t post = runFilters(view, filtered_children, mPostFilters); | 85 | filterResult_t post = runFilters(view, filtered_children, mPostFilters); |
86 | if(pre.first && post.first) | 86 | if(pre.first && post.first) |
87 | { | 87 | { |
88 | result.push_back(view); | 88 | result.push_back(view); |
89 | } | 89 | } |
90 | if(post.second) | 90 | if(post.second) |
91 | { | 91 | { |
92 | result.insert(result.end(), filtered_children.begin(), filtered_children.end()); | 92 | result.insert(result.end(), filtered_children.begin(), filtered_children.end()); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | else | 95 | else |
96 | { | 96 | { |
97 | if(pre.first) | 97 | if(pre.first) |
98 | { | 98 | { |
99 | result.push_back(view); | 99 | result.push_back(view); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | return result; | 102 | return result; |
103 | } | 103 | } |
104 | 104 | ||
105 | void LLViewQuery::filterChildren(LLView * view, viewList_t & filtered_children) const | 105 | void LLViewQuery::filterChildren(LLView * view, viewList_t & filtered_children) const |
106 | { | 106 | { |
107 | LLView::child_list_t views(*(view->getChildList())); | 107 | LLView::child_list_t views(*(view->getChildList())); |
108 | (*mSorterp)(view, views); // sort the children per the sorter | 108 | (*mSorterp)(view, views); // sort the children per the sorter |
109 | for(LLView::child_list_iter_t iter = views.begin(); | 109 | for(LLView::child_list_iter_t iter = views.begin(); |
110 | iter != views.end(); | 110 | iter != views.end(); |
111 | iter++) | 111 | iter++) |
112 | { | 112 | { |
113 | viewList_t indiv_children = this->run(*iter); | 113 | viewList_t indiv_children = this->run(*iter); |
114 | filtered_children.insert(filtered_children.end(), indiv_children.begin(), indiv_children.end()); | 114 | filtered_children.insert(filtered_children.end(), indiv_children.begin(), indiv_children.end()); |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | filterResult_t LLViewQuery::runFilters(LLView * view, const viewList_t children, const filterList_t filters) const | 118 | filterResult_t LLViewQuery::runFilters(LLView * view, const viewList_t children, const filterList_t filters) const |
119 | { | 119 | { |
120 | filterResult_t result = filterResult_t(TRUE, TRUE); | 120 | filterResult_t result = filterResult_t(TRUE, TRUE); |
121 | for(filterList_const_iter_t iter = filters.begin(); | 121 | for(filterList_const_iter_t iter = filters.begin(); |
122 | iter != filters.end(); | 122 | iter != filters.end(); |
123 | iter++) | 123 | iter++) |
124 | { | 124 | { |
125 | filterResult_t filtered = (**iter)(view, children); | 125 | filterResult_t filtered = (**iter)(view, children); |
126 | result.first = result.first && filtered.first; | 126 | result.first = result.first && filtered.first; |
127 | result.second = result.second && filtered.second; | 127 | result.second = result.second && filtered.second; |
128 | } | 128 | } |
129 | return result; | 129 | return result; |
130 | } | 130 | } |
131 | 131 | ||
132 | class SortByTabOrder : public LLQuerySorter, public LLSingleton<SortByTabOrder> | 132 | class SortByTabOrder : public LLQuerySorter, public LLSingleton<SortByTabOrder> |
133 | { | 133 | { |
134 | /*virtual*/ void operator() (LLView * parent, LLView::child_list_t &children) const | 134 | /*virtual*/ void operator() (LLView * parent, LLView::child_list_t &children) const |
135 | { | 135 | { |
136 | children.sort(LLCompareByTabOrder(parent->getCtrlOrder())); | 136 | children.sort(LLCompareByTabOrder(parent->getCtrlOrder())); |
137 | } | 137 | } |
138 | }; | 138 | }; |
139 | 139 | ||
140 | LLCtrlQuery::LLCtrlQuery() : | 140 | LLCtrlQuery::LLCtrlQuery() : |
141 | LLViewQuery() | 141 | LLViewQuery() |
142 | { | 142 | { |
143 | setSorter(SortByTabOrder::getInstance()); | 143 | setSorter(SortByTabOrder::getInstance()); |
144 | } | 144 | } |
145 | 145 | ||