27 #define YUILogComponent "ui" 30 #include "YUISymbols.h" 34 typedef std::deque<std::string> StringDeque;
35 typedef std::deque<std::string>::iterator StringDequeIterator;
36 typedef std::deque<std::string>::const_iterator StringDequeConstIterator;
42 YLogViewPrivate(
const std::string & label,
int visibleLines,
int maxLines )
44 , visibleLines( visibleLines )
45 , maxLines( maxLines )
62 YUI_CHECK_NEW( priv );
92 return priv->visibleLines;
99 priv->visibleLines = newVisibleLines;
106 return priv->maxLines;
113 int linesToDelete = priv->maxLines - newMaxLines;
114 priv->maxLines = newMaxLines;
116 for (
int i=0; i < linesToDelete; i++ )
117 priv->logText.pop_front();
119 if ( linesToDelete > 0 )
129 for ( StringDequeConstIterator it = priv->logText.begin();
130 it != priv->logText.end();
136 if ( ! text.empty() )
140 if ( *(text.rbegin()) ==
'\n' )
142 text.resize( text.size() - 1 );
153 if ( priv->logText.empty() )
156 return priv->logText.back();
163 std::string text = newText;
164 std::string::size_type from = 0;
165 std::string::size_type to = 0;
170 while ( to < text.size() )
173 to = text.find(
'\n', from );
174 if ( to == std::string::npos )
180 appendLine( text.substr( from, to - from ) );
183 if ( to < text.size() )
186 appendLine( text.substr( to, text.size() - to ) );
194 YLogView::appendLine(
const std::string & line )
196 priv->logText.push_back( line );
200 priv->logText.pop_front();
212 priv->logText.clear();
220 priv->logText.clear();
227 return priv->logText.size();
232 YLogView::updateDisplay()
253 propSet.
add(
YProperty( YUIProperty_Value, YStringProperty ) );
254 propSet.
add(
YProperty( YUIProperty_LastLine, YStringProperty ) );
255 propSet.
add(
YProperty( YUIProperty_VisibleLines, YIntegerProperty ) );
256 propSet.
add(
YProperty( YUIProperty_MaxLines, YIntegerProperty ) );
257 propSet.
add(
YProperty( YUIProperty_Label, YStringProperty ) );
272 else if ( propertyName == YUIProperty_VisibleLines )
setVisibleLines ( val.integerVal() );
273 else if ( propertyName == YUIProperty_MaxLines )
setMaxLines ( val.integerVal() );
std::string logText() const
Return the entire log text as one large string of concatenated lines delimited with newlines...
bool isEmpty() const
Returns 'true' if this property set does not contain anything.
void appendLines(const std::string &text)
Append one or more lines to the log text and trigger a display update.
YLogView(YWidget *parent, const std::string &label, int visibleLines, int maxLines)
Constructor.
Transport class for the value of simple properties.
void setVisibleLines(int newVisibleLines)
Set the number of visible lines.
void add(const YProperty &prop)
Add a property to this property set.
A set of properties to check names and types against.
int lines() const
Return the current number of lines.
virtual const YPropertySet & propertySet()
Return this class's property set.
virtual void setLabel(const std::string &label)
Set the label (the caption above the log text).
void setLogText(const std::string &text)
Set (replace) the entire log text and trigger a display update.
virtual void displayLogText(const std::string &text)=0
Display the part of the log text that should be displayed.
std::string stringVal() const
Methods to get the value of this property.
virtual ~YLogView()
Destructor.
std::string lastLine() const
Return the last log line.
Class for widget properties.
int visibleLines() const
Return the number of visible lines.
int maxLines() const
Return the maximum number of lines to store.
void clearText()
Clear the log text and trigger a display update.
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
std::string label() const
Return the label (the caption above the log text).
void check(const std::string &propertyName) const
Check if a property 'propertyName' exists in this property set.
void setMaxLines(int newMaxLines)
Set the maximum number of lines to store.
YPropertyType type() const
Returns the type of this property value.
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.