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
|
// pkg_tree.h -*-c++-*-
//
// Copyright 1999-2002, 2004-2005, 2008 Daniel Burrows
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; see the file COPYING. If not, write to
// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
#ifndef PKG_TREE_H
#define PKG_TREE_H
#include "apt_undo_tree.h"
#include <apt-pkg/pkgcache.h>
/** \brief Uses the cwidget::widgets::tree classes to display a tree containing packages
*
*
* Uses the cwidget::widgets::tree classes to display a tree containing packages. A generic
* version of this, suitable only for displaying the current state of the
* package cache, is provided; it can be extended as needed.
*
* \file pkg_tree.h
*/
class OpProgress;
class pkg_grouppolicy;
class pkg_grouppolicy_factory;
class pkg_sortpolicy;
class pkg_tree_node;
class undo_group;
class pkg_tree:public apt_undo_tree
{
/** If \b true, the tree is fully initialized: in particular,
* the cache-reload signals are connected up.
*/
bool initialized;
pkg_grouppolicy_factory *grouping;
std::string groupingstr;
pkg_sortpolicy *sorting;
aptitude::matching::pkg_matcher *limit;
std::wstring limitstr;
// Defines the limits on the display (what packages will be allowed
// to be displayed) This could be a grouping policy, but hardcoding the
// filter here makes it easier to alter from the UI.
static cwidget::widgets::editline::history_list limit_history, grouping_history,
sorting_history;
void handle_cache_close();
/** Set up the limit and handle a few other things. */
void init(const char *limitstr);
protected:
virtual bool handle_key(const cwidget::config::key &k);
pkg_tree(const std::string &groupingstr,
pkg_grouppolicy_factory *_grouping,
const std::wstring &limitstr);
pkg_tree(const std::string &groupingstr,
pkg_grouppolicy_factory *_grouping);
public:
/** Initialize a package tree, but don't build it. The caller
* should call build_tree(). The main reason to do this is so you
* can connect up the tree's signals before building it.
*/
static cwidget::util::ref_ptr<pkg_tree>
create(const std::string &groupingstr,
pkg_grouppolicy_factory *grouping,
const std::wstring &limitstr)
{
cwidget::util::ref_ptr<pkg_tree> rval(new pkg_tree(groupingstr, grouping, limitstr));
rval->decref();
return rval;
}
/** Initialize a package tree, but don't build it. The caller
* should call build_tree(). The main reason to do this is so you
* can connect up the tree's signals before building it.
*
* The default tree limit is used.
*/
static cwidget::util::ref_ptr<pkg_tree>
create(const std::string &groupingstr,
pkg_grouppolicy_factory *grouping)
{
cwidget::util::ref_ptr<pkg_tree> rval(new pkg_tree(groupingstr, grouping));
rval->decref();
return rval;
}
// Should you be able to just pass in a string (?)
~pkg_tree();
/** Rebuilds the tree. If the new tree would be empty, keeps the
* current tree and returns \b false.
*
* \param progress a progress bar with which to show the progress
* of the rebuild.
*
* \return true iff the rebuild was successful.
*/
bool build_tree(OpProgress &progress);
/** Rebuilds the tree. If the new tree would be empty, keeps the
* current tree and returns \b false. Generates a new progress bar
* using gen_progress_bar().
*
* \return true iff the rebuild was successful.
*/
bool build_tree();
void set_grouping(pkg_grouppolicy_factory *_grouping);
void set_grouping(const std::wstring &s);
void set_sorting(pkg_sortpolicy *_sorting);
void set_sorting(const std::wstring &s);
void set_limit(const std::wstring &_limit);
// Selects a new limit and rebuilds the tree.
std::wstring get_limit_str() {return limitstr;}
/** Return \b true. */
bool find_limit_enabled();
/** Pop up the limit selection dialog. */
bool find_limit();
/** Return \b true if a limit is already set. */
bool find_reset_limit_enabled();
/** Reset the limit. */
bool find_reset_limit();
// Local bindings:
static cwidget::config::keybindings *bindings;
static void init_bindings();
sigc::signal2<void, const pkgCache::PkgIterator &, const pkgCache::VerIterator &> selected_signal;
sigc::signal1<void, std::wstring> selected_desc_signal;
};
typedef cwidget::util::ref_ptr<pkg_tree> pkg_tree_ref;
#endif
|