1
/* rpackageview.h - Package sectioning system
3
* Copyright (c) 2004 Conectiva S/A
4
* 2004 Michael Vogt <mvo@debian.org>
6
* Author: Gustavo Niemeyer
7
* Michael Vogt <mvo@debian.org>
9
* This program is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU General Public License as
11
* published by the Free Software Foundation; either version 2 of the
12
* License, or (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26
#ifndef RPACKAGEVIEW_H
27
#define RPACKAGEVIEW_H
33
#include <ept/axi/axi.h>
37
#include "rpackagefilter.h"
45
enum {PACKAGE_VIEW_SECTION,
56
map<string, vector<RPackage *> > _view;
61
// packages in selected
62
vector<RPackage *> _selectedView;
64
// all packages in current global filter
65
vector<RPackage *> &_all;
68
RPackageView(vector<RPackage *> &allPackages): _all(allPackages) {};
69
virtual ~RPackageView() {};
71
bool hasSelection() { return _hasSelection; };
72
string getSelected() { return _selectedName; };
73
bool hasPackage(RPackage *pkg);
74
virtual bool setSelected(string name);
78
_hasSelection = false;
79
_selectedName.clear();
82
virtual vector<string> getSubViews();
84
virtual string getName() = 0;
85
virtual void addPackage(RPackage *package) = 0;
87
typedef vector<RPackage *>::iterator iterator;
89
virtual iterator begin() { return _selectedView.begin(); };
90
virtual iterator end() { return _selectedView.end(); };
93
virtual void clearSelection();
95
virtual void refresh();
100
class RPackageViewSections : public RPackageView {
102
RPackageViewSections(vector<RPackage *> &allPkgs) : RPackageView(allPkgs) {};
105
return _("Sections");
108
void addPackage(RPackage *package);
111
class RPackageViewAlphabetic : public RPackageView {
113
RPackageViewAlphabetic(vector<RPackage *> &allPkgs) : RPackageView(allPkgs) {};
115
return _("Alphabetic");
118
void addPackage(RPackage *package) {
119
char letter[2] = { ' ', '\0' };
120
letter[0] = toupper(package->name()[0]);
121
_view[letter].push_back(package);
125
class RPackageViewOrigin : public RPackageView {
127
RPackageViewOrigin(vector<RPackage *> &allPkgs) : RPackageView(allPkgs) {};
132
void addPackage(RPackage *package);
135
class RPackageViewStatus:public RPackageView {
137
// mark the software as unsupported in status view
138
bool markUnsupported;
139
vector<string> supportedComponents;
142
RPackageViewStatus(vector<RPackage *> &allPkgs);
148
void addPackage(RPackage *package);
151
class RPackageViewSearch : public RPackageView {
153
vector<string> searchStrings;
157
// the search history
158
map<string, searchItem> searchHistory;
159
searchItem _currentSearchItem;
160
int found; // nr of found pkgs for the last search
165
RPackageViewSearch(vector<RPackage *> &allPkgs)
166
: RPackageView(allPkgs), found(0) {};
168
int setSearch(string searchName, int type, string searchString,
169
OpProgress &searchProgress);
172
return _("Search History");
175
// return search history here
176
virtual vector<string> getSubViews();
177
virtual bool setSelected(string name);
179
void addPackage(RPackage *package);
182
virtual void refresh() {};
186
class RPackageViewFilter : public RPackageView {
188
vector<RFilter *> _filterL;
189
set<string> _sectionList; // list of all available package sections
193
void restoreFilters();
194
// called after the filtereditor was run
195
void refreshFilters();
198
bool registerFilter(RFilter *filter);
199
void unregisterFilter(RFilter *filter);
201
void makePresetFilters();
203
RFilter* findFilter(string name);
204
unsigned int nrOfFilters() { return _filterL.size(); };
205
RFilter *findFilter(unsigned int index) {
206
if (index > _filterL.size())
209
return _filterL[index];
213
int getFilterIndex(RFilter *filter);
215
vector<string> getFilterNames();
216
const set<string> &getSections();
218
RPackageViewFilter(vector<RPackage *> &allPkgs);
220
// build packages list on "demand"
221
virtual iterator begin();
223
// we never need to clear because we build the view "on-demand"
224
virtual void clear() {clearSelection();};
230
void addPackage(RPackage *package);