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
46 void defaultTrust (trusts trust
);
47 void setViewMode (views mode
);
49 void init(views _mode
, ListView
*_listview
, Window
*parent
);
50 void build_category_tree();
51 static unsigned int mode_caption (views mode
);
52 void setObsolete (bool doit
);
56 void SetPackageFilter (const std::string
&filterString
)
58 packageFilterString
= filterString
;
61 Window
*GetParent(void) { return parent
; }
67 std::string packageFilterString
;
68 ListViewContents contents
;
69 CategoryTree
*cat_tree_root
;
72 void insert_pkg (packagemeta
&, int indent
= 0);
73 void insert_category (CategoryTree
*);
76 // column numbers, must match index into pkg_headers[]
79 pkgname_col
= 0, // package/category name
81 new_col
= 2, // action
88 bool isObsolete (std::set
<std::string
, casecompare_lt_op
> &categories
);
89 bool isObsolete (const std::string
& catname
);
92 // Helper class which stores the contents and collapsed/expanded state for each
93 // category (and the pseudo-category 'All')
99 CategoryTree(Category
& cat
, bool collapsed
) :
101 _collapsed(collapsed
),
102 _action (packagemeta::NoChange_action
)
110 std::vector
<CategoryTree
*> & bucket()
120 const Category
&category()
125 packagemeta::_actions
& action()
130 int do_action(packagemeta::_actions action_id
, trusts
const deftrust
)
137 for (std::vector
<CategoryTree
*>::const_iterator i
= _bucket
.begin();
141 // recurse for all contained non-obsolete categories
142 if (isObsolete((*i
)->_cat
.first
))
145 int l
= (*i
)->do_action(action_id
, deftrust
);
153 // otherwise, this is a leaf category, so apply action to all packages
156 for (std::vector
<packagemeta
*>::const_iterator pkg
= _cat
.second
.begin();
157 pkg
!= _cat
.second
.end();
160 (*pkg
)->select_action(action_id
, deftrust
);
164 // these lines need to be updated, if displayed
174 std::vector
<CategoryTree
*> _bucket
;
175 packagemeta::_actions _action
;
178 #endif /* SETUP_PICKVIEW_H */