28 #define YUILogComponent "ui" 31 #include "YUISymbols.h" 32 #include "YDownloadProgress.h" 40 const string & filename,
41 YFileSize_t expectedSize )
43 , filename( filename )
44 , expectedSize( expectedSize )
49 YFileSize_t expectedSize;
55 const string & filename,
56 YFileSize_t expectedSize )
60 YUI_CHECK_NEW( priv );
90 return priv->filename;
104 return priv->expectedSize;
111 priv->expectedSize = newSize;
118 if ( priv->expectedSize == 0 )
123 if ( currentSize >= priv->expectedSize )
126 return (
int) ( (100 * currentSize ) / priv->expectedSize );
133 struct stat stat_info;
135 if ( stat( priv->filename.c_str(), & stat_info ) == 0 )
136 return (YFileSize_t) stat_info.st_size;
156 propSet.
add(
YProperty( YUIProperty_Label, YStringProperty ) );
157 propSet.
add(
YProperty( YUIProperty_Filename, YStringProperty ) );
158 propSet.
add(
YProperty( YUIProperty_ExpectedSize, YIntegerProperty ) );
159 propSet.
add(
YProperty( YUIProperty_CurrentSize, YIntegerProperty,
true ) );
160 propSet.
add(
YProperty( YUIProperty_Value, YIntegerProperty,
true ) );
175 if ( propertyName == YUIProperty_ExpectedSize )
setExpectedSize( val.integerVal() );
std::string filename() const
Return the name of the file that is being monitored.
bool isEmpty() const
Returns 'true' if this property set does not contain anything.
virtual YFileSize_t currentFileSize() const
Return the current size of the file that is being downloaded or 0 if this file doesn't exist (yet)...
Transport class for the value of simple properties.
void add(const YProperty &prop)
Add a property to this property set.
A set of properties to check names and types against.
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
virtual void setExpectedSize(YFileSize_t newSize)
Set the expected file size.
virtual void setLabel(const std::string &label)
Set the label (the text above the progress bar).
virtual void setFilename(const std::string &filename)
Set the name of a new file to monitor.
virtual ~YDownloadProgress()
Destructor.
YDownloadProgress(YWidget *parent, const std::string &label, const std::string &filename, YFileSize_t expectedSize)
Constructor.
std::string stringVal() const
Methods to get the value of this property.
Class for widget properties.
std::string label() const
Get the label (the text above the progress bar).
YFileSize_t expectedSize() const
Return the expected file size.
virtual const YPropertySet & propertySet()
Return this class's property set.
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
void check(const std::string &propertyName) const
Check if a property 'propertyName' exists in this property set.
int currentPercent() const
Return the percentage (0..100) of the file being downloaded so far.
YPropertyType type() const
Returns the type of this property value.