/usr/share/qt3/doc/html/chart-element-cpp.html is in qt3-doc 3:3.3.8-b-8ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/tutorial2.doc:3 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>chart/element.cpp Example File</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>chart/element.cpp Example File</h1>
<pre>#include "element.h"
#include <<a href="qstringlist-h.html">qstringlist.h</a>>
#include <<a href="qtextstream-h.html">qtextstream.h</a>>
const char FIELD_SEP = ':';
const char PROPOINT_SEP = ';';
const char XY_SEP = ',';
void Element::init( double value, QColor valueColor, int valuePattern,
const <a href="qstring.html">QString</a>& label, QColor labelColor )
{
m_value = value;
m_valueColor = valueColor;
if ( valuePattern < Qt::SolidPattern || valuePattern > Qt::DiagCrossPattern )
valuePattern = Qt::SolidPattern;
m_valuePattern = valuePattern;
m_label = label;
m_labelColor = labelColor;
}
void Element::setValuePattern( int valuePattern )
{
if ( valuePattern < Qt::SolidPattern || valuePattern > Qt::DiagCrossPattern )
valuePattern = Qt::SolidPattern;
m_valuePattern = valuePattern;
}
double Element::proX( int index ) const
{
<a href="qapplication.html#Q_ASSERT">Q_ASSERT</a>(index >= 0 && index < MAX_PROPOINTS);
return m_propoints[2 * index];
}
double Element::proY( int index ) const
{
<a href="qapplication.html#Q_ASSERT">Q_ASSERT</a>(index >= 0 && index < MAX_PROPOINTS);
return m_propoints[(2 * index) + 1];
}
void Element::setProX( int index, double value )
{
<a href="qapplication.html#Q_ASSERT">Q_ASSERT</a>(index >= 0 && index < MAX_PROPOINTS);
m_propoints[2 * index] = value;
}
void Element::setProY( int index, double value )
{
<a href="qapplication.html#Q_ASSERT">Q_ASSERT</a>(index >= 0 && index < MAX_PROPOINTS);
m_propoints[(2 * index) + 1] = value;
}
QTextStream &operator<<( <a href="qtextstream.html">QTextStream</a> &s, const Element &element )
{
s << element.value() << FIELD_SEP
<< element.valueColor().name() << FIELD_SEP
<< element.valuePattern() << FIELD_SEP
<< element.labelColor().name() << FIELD_SEP;
for ( int i = 0; i < Element::MAX_PROPOINTS; ++i ) {
s << element.proX( i ) << XY_SEP << element.proY( i );
s << ( i == Element::MAX_PROPOINTS - 1 ? FIELD_SEP : PROPOINT_SEP );
}
s << element.label() << '\n';
return s;
}
QTextStream &operator>>( <a href="qtextstream.html">QTextStream</a> &s, Element &element )
{
<a href="qstring.html">QString</a> data = s.<a href="qtextstream.html#readLine">readLine</a>();
element.setValue( Element::INVALID );
int errors = 0;
bool ok;
<a href="qstringlist.html">QStringList</a> fields = QStringList::<a href="qstringlist.html#split">split</a>( FIELD_SEP, data );
if ( fields.<a href="qvaluelist.html#count">count</a>() >= 4 ) {
double value = fields[0].toDouble( &ok );
if ( !ok )
errors++;
<a href="qcolor.html">QColor</a> valueColor = QColor( fields[1] );
if ( !valueColor.<a href="qcolor.html#isValid">isValid</a>() )
errors++;
int valuePattern = fields[2].toInt( &ok );
if ( !ok )
errors++;
<a href="qcolor.html">QColor</a> labelColor = QColor( fields[3] );
if ( !labelColor.<a href="qcolor.html#isValid">isValid</a>() )
errors++;
<a href="qstringlist.html">QStringList</a> propoints = QStringList::<a href="qstringlist.html#split">split</a>( PROPOINT_SEP, fields[4] );
<a href="qstring.html">QString</a> label = data.<a href="qstring.html#section">section</a>( FIELD_SEP, 5 );
if ( !errors ) {
element.set( value, valueColor, valuePattern, label, labelColor );
int i = 0;
for ( QStringList::iterator point = propoints.<a href="qvaluelist.html#begin">begin</a>();
i < Element::MAX_PROPOINTS && point != propoints.<a href="qvaluelist.html#end">end</a>();
++i, ++point ) {
errors = 0;
<a href="qstringlist.html">QStringList</a> xy = QStringList::<a href="qstringlist.html#split">split</a>( XY_SEP, *point );
double x = xy[0].toDouble( &ok );
if ( !ok || x <= 0.0 || x >= 1.0 )
errors++;
double y = xy[1].toDouble( &ok );
if ( !ok || y <= 0.0 || y >= 1.0 )
errors++;
if ( errors )
x = y = Element::NO_PROPORTION;
element.setProX( i, x );
element.setProY( i, y );
}
}
}
return s;
}
</pre><!-- eof -->
<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright © 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt 3.3.8</div>
</table></div></address></body>
</html>
|