libyui-ncurses-pkg  2.48.9
NCPkgFilterService.h
1 /****************************************************************************
2 |
3 | Copyright (c) [2002-2011] Novell, Inc.
4 | Copyright (c) [2018] SUSE LLC
5 | All Rights Reserved.
6 |
7 | This program is free software; you can redistribute it and/or
8 | modify it under the terms of version 2 of the GNU General Public License as
9 | published by the Free Software Foundation.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with this program; if not, contact SUSE.
18 |
19 | To contact SUSE about this file by physical or electronic mail,
20 | you may find current contact information at www.suse.com
21 |
22 |***************************************************************************/
23 
24 #ifndef NCPkgFilterService_h
25 #define NCPkgFilterService_h
26 
27 #include <iosfwd>
28 
29 #include <vector>
30 #include <string>
31 #include <algorithm>
32 #include <zypp/RepoManager.h>
33 
34 #include "NCPadWidget.h"
35 #include "NCPopup.h"
36 #include "NCPushButton.h"
37 #include "NCTable.h"
38 #include "NCTablePad.h"
39 #include "NCZypp.h"
40 
41 class NCTable;
42 class NCPushButton;
43 class NCPackageSelector;
44 
45 // represent a service by its name
46 typedef std::string ZyppService;
47 
48 class NCPkgServiceTag : public YTableCell
49 {
50 
51 private:
52 
53  ZyppService service;
54 
55 public:
56  /**
57  * A helper class to hold a reference to zypp::Service
58  * for each service table line
59  * (actually it's a dummy column of the table)
60  * @param service zypp::Service reference
61  */
62 
63  NCPkgServiceTag ( ZyppService service);
64 
65  ~NCPkgServiceTag() { };
66 
67  /*
68  * Get service reference from the line tag
69  * @return ZyppService
70  */
71 
72  ZyppService getService() const { return service; }
73 
74 };
75 
76 class NCPkgServiceTable : public NCTable
77 {
78 private:
79 
80  NCPkgServiceTable & operator=( const NCPkgServiceTable & );
82 
83  NCPackageSelector *packager;
84  zypp::shared_ptr<zypp::RepoManager> repo_manager;
85 
86 public:
87 
88  /**
89  * A helper class to hold service data in a neat table
90  * widget
91  * @param parent A parent widget
92  * @param tableHeader table header
93  * @param pkg the master object
94  */
95 
96  NCPkgServiceTable ( YWidget *parent, YTableHeader *tableHeader, NCPackageSelector *pkg);
97 
98  virtual ~NCPkgServiceTable() {};
99 
100  /**
101  * @return bool any service is present at all
102  */
103  static bool any_service();
104 
105  /**
106  * Add one line (with tag) to the services table
107  * @param ZyppService Reference to zypp::Service
108  * @param cols String std::vector with service data (name + URL)
109  */
110  virtual void addLine( ZyppService r, const std::vector<std::string> & cols );
111 
112  /*
113  * Fill header of services table (name + URL)
114  */
115  void fillHeader();
116 
117  /**
118  * Get tag of service table line on current index,
119  * (contains service reference)
120  * @param index Index of selected table line
121  * @return NCPkgServiceTag* Tag of selected line
122  */
123  NCPkgServiceTag * getTag ( int index );
124 
125  /**
126  * Get service reference from selected line's tag
127  * @param index Index of selected table line
128  * @return ZyppService Associated zypp::Service reference
129  */
130  ZyppService getService( int index );
131 
132  /**
133  * @return HTML contents for the description pane
134  */
135  std::string getDescription (ZyppService r);
136 
137  virtual NCursesEvent wHandleInput ( wint_t ch );
138 
139  /**
140  * Add items to the service list (assoc.
141  * product name, if any, and URL)
142  * @return bool (always true ;-) )
143  */
144  bool fillServiceList( );
145 
146  /**
147  * Make the Package List show the packages
148  * for the currently selected service
149  */
150  void showServicePackages( );
151 
152 };
153 #endif
NCPkgServiceTag(ZyppService service)
A helper class to hold a reference to zypp::Service for each service table line (actually it's a dumm...
NCPkgServiceTag * getTag(int index)
Get tag of service table line on current index, (contains service reference)
virtual void addLine(ZyppService r, const std::vector< std::string > &cols)
Add one line (with tag) to the services table.
std::string getDescription(ZyppService r)
static bool any_service()
bool fillServiceList()
Add items to the service list (assoc.
ZyppService getService(int index)
Get service reference from selected line's tag.
void showServicePackages()
Make the Package List show the packages for the currently selected service.