libyui
3.0.10
|
00001 /* 00002 Copyright (C) 2000-2012 Novell, Inc 00003 This library is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU Lesser General Public License as 00005 published by the Free Software Foundation; either version 2.1 of the 00006 License, or (at your option) version 3.0 of the License. This library 00007 is distributed in the hope that it will be useful, but WITHOUT ANY 00008 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00009 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00010 License for more details. You should have received a copy of the GNU 00011 Lesser General Public License along with this library; if not, write 00012 to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00013 Floor, Boston, MA 02110-1301 USA 00014 */ 00015 00016 00017 /*-/ 00018 00019 File: YDownloadProgress.h 00020 00021 Author: Stefan Hundhammer <sh@suse.de> 00022 00023 /-*/ 00024 00025 #ifndef YDownloadProgress_h 00026 #define YDownloadProgress_h 00027 00028 #include "YWidget.h" 00029 00030 00031 class YDownloadProgressPrivate; 00032 00033 /** 00034 * DownloadProgress: A progress bar that monitors downloading a file by 00035 * repeatedly polling its size up to its expected size. 00036 **/ 00037 class YDownloadProgress : public YWidget 00038 { 00039 protected: 00040 /** 00041 * Constructor. 00042 * 00043 * 'label' is the label above the progress bar. 00044 * 00045 * 'filename' is the name (with path) of the file being monitored. 00046 * 00047 * 'expectedSize' is the expected size of the file in bytes. 00048 **/ 00049 YDownloadProgress( YWidget * parent, 00050 const std::string & label, 00051 const std::string & filename, 00052 YFileSize_t expectedSize ); 00053 public: 00054 /** 00055 * Destructor. 00056 **/ 00057 virtual ~YDownloadProgress(); 00058 00059 /** 00060 * Returns a descriptive name of this widget class for logging, 00061 * debugging etc. 00062 **/ 00063 virtual const char * widgetClass() const { return "YDownloadProgress"; } 00064 00065 /** 00066 * Get the label (the text above the progress bar). 00067 **/ 00068 std::string label() const; 00069 00070 /** 00071 * Set the label (the text above the progress bar). 00072 * 00073 * Derived classes are free to reimplement this, but they should call this 00074 * base class method at the end of the overloaded function. 00075 **/ 00076 virtual void setLabel( const std::string & label ); 00077 00078 /** 00079 * Return the name of the file that is being monitored. 00080 **/ 00081 std::string filename() const; 00082 00083 /** 00084 * Set the name of a new file to monitor. 00085 * 00086 * Derived classes are free to reimplement this, but they should call this 00087 * base class method at the end of the overloaded function. 00088 **/ 00089 virtual void setFilename( const std::string & filename ); 00090 00091 /** 00092 * Return the expected file size. 00093 **/ 00094 YFileSize_t expectedSize() const; 00095 00096 /** 00097 * Set the expected file size. 00098 * 00099 * Derived classes are free to reimplement this, but they should call this 00100 * base class method at the end of the overloaded function. 00101 **/ 00102 virtual void setExpectedSize( YFileSize_t newSize ); 00103 00104 /** 00105 * Return the current size of the file that is being downloaded 00106 * or 0 if this file doesn't exist (yet). 00107 * 00108 * This default implementation returns the 'st_size' field of a stat() 00109 * system call on the file. This should be useful for most implementations. 00110 **/ 00111 virtual YFileSize_t currentFileSize() const; 00112 00113 /** 00114 * Return the percentage (0..100) of the file being downloaded so far. 00115 **/ 00116 int currentPercent() const; 00117 00118 /** 00119 * Alias for currentPercent(). 00120 **/ 00121 int value() const { return currentPercent(); } 00122 00123 /** 00124 * Set a property. 00125 * Reimplemented from YWidget. 00126 * 00127 * This function may throw YUIPropertyExceptions. 00128 * 00129 * This function returns 'true' if the value was successfully set and 00130 * 'false' if that value requires special handling (not in error cases: 00131 * those are covered by exceptions). 00132 **/ 00133 virtual bool setProperty( const std::string & propertyName, 00134 const YPropertyValue & val ); 00135 00136 /** 00137 * Get a property. 00138 * Reimplemented from YWidget. 00139 * 00140 * This method may throw YUIPropertyExceptions. 00141 **/ 00142 virtual YPropertyValue getProperty( const std::string & propertyName ); 00143 00144 /** 00145 * Return this class's property set. 00146 * This also initializes the property upon the first call. 00147 * 00148 * Reimplemented from YWidget. 00149 **/ 00150 virtual const YPropertySet & propertySet(); 00151 00152 00153 private: 00154 00155 ImplPtr<YDownloadProgressPrivate> priv; 00156 }; 00157 00158 00159 #endif // YDownloadProgress_h