2 * Copyright (c) 2002 Robert Collins.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by Robert Collins <robertc@hotmail.com>
16 #ifndef SETUP_PICKVIEW_H
17 #define SETUP_PICKVIEW_H
21 #include "package_meta.h"
30 trusts deftrust
; // XXX: needs accessor
44 void defaultTrust (trusts trust
);
45 void setViewMode (views mode
);
47 void init(views _mode
, ListView
*_listview
, Window
*parent
);
48 void build_category_tree();
49 static unsigned int mode_caption (views mode
);
50 void setObsolete (bool doit
);
54 void SetPackageFilter (const std::string
&filterString
)
56 packageFilterString
= filterString
;
59 Window
*GetParent(void) { return parent
; }
65 std::string packageFilterString
;
66 ListViewContents contents
;
67 CategoryTree
*cat_tree_root
;
70 void insert_pkg (packagemeta
&, int indent
= 0);
71 void insert_category (CategoryTree
*);
74 // column numbers, must match index into pkg_headers[]
77 pkgname_col
= 0, // package/category name
79 new_col
= 2, // action
86 bool isObsolete (std::set
<std::string
, casecompare_lt_op
> &categories
);
87 bool isObsolete (const std::string
& catname
);
90 // Helper class which stores the contents and collapsed/expanded state for each
91 // category (and the pseudo-category 'All')
97 CategoryTree(Category
& cat
, bool collapsed
) :
99 _collapsed(collapsed
),
100 _action (packagemeta::NoChange_action
)
108 std::vector
<CategoryTree
*> & bucket()
118 const Category
&category()
123 packagemeta::_actions
& action()
128 int do_action(packagemeta::_actions action_id
, trusts
const deftrust
)
135 for (std::vector
<CategoryTree
*>::const_iterator i
= _bucket
.begin();
139 // recurse for all contained non-obsolete categories
140 if (isObsolete((*i
)->_cat
.first
))
143 int l
= (*i
)->do_action(action_id
, deftrust
);
151 // otherwise, this is a leaf category, so apply action to all packages
154 for (std::vector
<packagemeta
*>::const_iterator pkg
= _cat
.second
.begin();
155 pkg
!= _cat
.second
.end();
158 (*pkg
)->select_action(action_id
, deftrust
);
162 // these lines need to be updated, if displayed
172 std::vector
<CategoryTree
*> _bucket
;
173 packagemeta::_actions _action
;
176 #endif /* SETUP_PICKVIEW_H */