libyui-ncurses-pkg
NCPkgPopupDiskspace.h
1 /****************************************************************************
2 |
3 | Copyright (c) [2002-2011] Novell, Inc.
4 | All Rights Reserved.
5 |
6 | This program is free software; you can redistribute it and/or
7 | modify it under the terms of version 2 of the GNU General Public License as
8 | published by the Free Software Foundation.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, contact Novell, Inc.
17 |
18 | To contact Novell about this file by physical or electronic mail,
19 | you may find current contact information at www.novell.com
20 |
21 |***************************************************************************/
22 
23 
24 /*---------------------------------------------------------------------\
25 | |
26 | __ __ ____ _____ ____ |
27 | \ \ / /_ _/ ___|_ _|___ \ |
28 | \ V / _` \___ \ | | __) | |
29 | | | (_| |___) || | / __/ |
30 | |_|\__,_|____/ |_| |_____| |
31 | |
32 | core system |
33 | (C) SuSE GmbH |
34 \----------------------------------------------------------------------/
35 
36  File: NCPkgPopupDiskspace.h
37 
38  Author: Gabriele Strattner <gs@suse.de>
39 
40 /-*/
41 #ifndef NCPkgPopupDiskspace_h
42 #define NCPkgPopupDiskspace_h
43 
44 #include <iosfwd>
45 #include <vector>
46 #include <string>
47 
48 #include <yui/FSize.h>
49 #include <yui/ncurses/NCPopup.h>
50 #include <yui/ncurses/NCLabel.h>
51 
52 #include "NCZypp.h"
53 
54 
55 typedef zypp::DiskUsageCounter::MountPoint ZyppPartitionDu;
56 typedef zypp::DiskUsageCounter::MountPointSet ZyppDuSet;
57 typedef zypp::DiskUsageCounter::MountPointSet::iterator ZyppDuSetIterator;
58 
59 class NCTable;
60 class NCPushButton;
61 
63 //
64 // CLASS NAME : NCPkgWarningRangeNotifier
65 //
66 // Class YQPkgWarningRangeNotifier from YQPkgDiskUsageList.h
67 //
68 
93 {
94 public:
95 
100 
105  void enterRange();
106 
112  void enterProximity();
113 
117  void warningPostedNotify();
118 
123  bool inRange() const;
124 
130  bool needWarning() const;
131 
135  bool leavingProximity() const;
136 
137  /*
138  * Log settings to y2log
139  */
140  void logSettings() const;
141 
145  void clear();
146 
151  void clearHistory();
152 
153 
154 protected:
155 
156  bool _inRange;
157  bool _isClose;
158  bool _hasBeenClose;
159  bool _warningPosted;
160 };
161 
162 class NCPkgPopupDiskspace : public NCPopup
163 {
164 private:
165  NCTable * partitions;
166  NCPushButton * okButton;
167  NCLabel * head;
168 
169 protected:
170 
171  virtual bool postAgain();
172 
173  virtual NCursesEvent wHandleInput( wint_t ch );
174 
175 public:
176  NCPkgPopupDiskspace( const wpos at, std::string headline );
177 
178  virtual ~NCPkgPopupDiskspace();
179 
180  void createLayout( std::string headline );
181  void doit();
182 
183  NCTable *Partitions() { return partitions; }
184 
185  virtual int preferredWidth();
186  virtual int preferredHeight();
187 
188 };
189 
191 //
192 // CLASS NAME : NCPkgPopupDiskspace
193 //
194 // DESCRIPTION :
195 //
197 {
198  NCPkgDiskspace & operator=( const NCPkgDiskspace & );
199  NCPkgDiskspace ( const NCPkgDiskspace & );
200 
201 private:
202 
203  bool testmode;
204  NCPkgPopupDiskspace *popupWin;
205  ZyppDuSet testDiskUsage;
206 
207  std::string usedPercent( const FSize &used, const FSize &total );
208 
212  NCPkgWarningRangeNotifier runningOutWarning;
213 
217  NCPkgWarningRangeNotifier overflowWarning;
218 
219 
220 public:
221 
222  NCPkgDiskspace( bool testSpaceMode );
223 
224  virtual ~NCPkgDiskspace();
225 
226 
227  void fillPartitionTable();
228 
229  std::string checkDiskSpace();
230 
231  void setDiskSpace( wint_t key ); // used for testing
232 
233  void checkDiskSpaceRange();
234 
235  void showInfoPopup( std::string headline );
236 
237  void checkRemainingDiskSpace( const ZyppPartitionDu & partition );
238 
239  FSize calculateDiff();
240 };
241 
242 
244 
245 
246 #endif // NCPkgPopupDiskspace_h
bool needWarning() const
Definition: NCPkgPopupDiskspace.cc:657
void warningPostedNotify()
Definition: NCPkgPopupDiskspace.cc:636
void clearHistory()
Definition: NCPkgPopupDiskspace.cc:611
bool leavingProximity() const
Definition: NCPkgPopupDiskspace.cc:650
Definition: NCPkgPopupDiskspace.h:92
void clear()
Definition: NCPkgPopupDiskspace.cc:602
NCPkgWarningRangeNotifier()
Definition: NCPkgPopupDiskspace.cc:595
bool inRange() const
Definition: NCPkgPopupDiskspace.cc:643
void enterProximity()
Definition: NCPkgPopupDiskspace.cc:628
void enterRange()
Definition: NCPkgPopupDiskspace.cc:620
Definition: NCPkgPopupDiskspace.h:162
Definition: NCPkgPopupDiskspace.h:196