28 #define YUILogComponent "ui"
31 #include "YUISymbols.h"
32 #include "YDownloadProgress.h"
39 const std::string & filename,
40 YFileSize_t expectedSize )
42 , filename( filename )
43 , expectedSize( expectedSize )
48 YFileSize_t expectedSize;
53 const std::string & label,
54 const std::string & filename,
55 YFileSize_t expectedSize )
59 YUI_CHECK_NEW( priv );
89 return priv->filename;
103 return priv->expectedSize;
110 priv->expectedSize = newSize;
117 if ( priv->expectedSize == 0 )
122 if ( currentSize >= priv->expectedSize )
125 return (
int) ( (100 * currentSize ) / priv->expectedSize );
132 struct stat stat_info;
134 if ( stat( priv->filename.c_str(), & stat_info ) == 0 )
135 return (YFileSize_t) stat_info.st_size;
155 propSet.
add(
YProperty( YUIProperty_Label, YStringProperty ) );
156 propSet.
add(
YProperty( YUIProperty_Filename, YStringProperty ) );
157 propSet.
add(
YProperty( YUIProperty_ExpectedSize, YIntegerProperty ) );
158 propSet.
add(
YProperty( YUIProperty_CurrentSize, YIntegerProperty,
true ) );
159 propSet.
add(
YProperty( YUIProperty_Value, YIntegerProperty,
true ) );
174 if ( propertyName == YUIProperty_ExpectedSize )
setExpectedSize( val.integerVal() );
void add(const YProperty &prop)
Add a property to this property set.
int currentPercent() const
Return the percentage (0..100) of the file being downloaded so far.
std::string label() const
Get the label (the text above the progress bar).
A set of properties to check names and types against.
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.
bool isEmpty() const
Returns 'true' if this property set does not contain anything.
virtual void setExpectedSize(YFileSize_t newSize)
Set the expected file size.
std::string stringVal() const
Methods to get the value of this property.
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).
virtual void setLabel(const std::string &label)
Set the label (the text above the progress bar).
std::string filename() const
Return the name of the file that is being monitored.
YPropertyType type() const
Returns the type of this property value.
Class for widget properties.
virtual void setFilename(const std::string &filename)
Set the name of a new file to monitor.
virtual ~YDownloadProgress()
Destructor.
void check(const std::string &propertyName) const
Check if a property 'propertyName' exists in this property set.
virtual const YPropertySet & propertySet()
Return this class's property set.
YDownloadProgress(YWidget *parent, const std::string &label, const std::string &filename, YFileSize_t expectedSize)
Constructor.
YFileSize_t expectedSize() const
Return the expected file size.
Transport class for the value of simple properties.
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.