From ea318d1431c89e647598c510c4245c6571aa5f46 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 26 Jan 2012 23:32:43 -0600 Subject: Update to latest tqt3 automated conversion --- doc/html/tutorial2-03.html | 76 +++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'doc/html/tutorial2-03.html') diff --git a/doc/html/tutorial2-03.html b/doc/html/tutorial2-03.html index bbc193b80..1aa7f23c6 100644 --- a/doc/html/tutorial2-03.html +++ b/doc/html/tutorial2-03.html @@ -40,10 +40,10 @@ access for data elements.
    private:
 
        double m_value;
-        TQColor m_valueColor;
+        TQColor m_valueColor;
         int m_valuePattern;
-        TQString m_label;
-        TQColor m_labelColor;
+        TQString m_label;
+        TQColor m_labelColor;
         double m_propoints[2 * MAX_PROPOINTS];
 

Each element has a value. Each value is displayed graphically with a @@ -52,26 +52,26 @@ with them; the label is drawn using the label color and for each type of chart has a (relative) position stored in the m_propoints array.

-

    #include <qcolor.h>
-    #include <qnamespace.h>
-    #include <qstring.h>
-    #include <qvaluevector.h>
+
    #include <ntqcolor.h>
+    #include <ntqnamespace.h>
+    #include <ntqstring.h>
+    #include <ntqvaluevector.h>
 

Although the Element class is a purely internal data class, it #includes four TQt classes. TQt is often perceived as a purely GUI toolkit, but it provides many non-GUI classes to support most aspects -of application programming. We use qcolor.h so that we can hold the -paint color and text color in the Element class. The use of qnamespace.h is slightly obscure. Most TQt classes are derived from the -TQt superclass which contains various -enumerations. The Element class does not derive from TQt, so we need to include qnamespace.h to have access to +of application programming. We use ntqcolor.h so that we can hold the +paint color and text color in the Element class. The use of ntqnamespace.h is slightly obscure. Most TQt classes are derived from the +TQt superclass which contains various +enumerations. The Element class does not derive from TQt, so we need to include ntqnamespace.h to have access to the TQt enum names. An alternative approach would have been to have -made Element a TQt subclass. We include qstring.h to make use of TQt's Unicode strings. As a convenience we +made Element a TQt subclass. We include ntqstring.h to make use of TQt's Unicode strings. As a convenience we will typedef a vector container for Elements, which is why we -pull in the qvaluevector.h header. +pull in the ntqvaluevector.h header.

    typedef TQValueVector<Element> ElementVector;
 

TQt provides a number of containers, some value based like -TQValueVector, and others pointer based. (See Collection Classes.) Here we've just typedefed one container +TQValueVector, and others pointer based. (See Collection Classes.) Here we've just typedefed one container type; we will keep each data set of elements in one ElementVector.

    const double EPSILON = 0.0000001; // Must be > INVALID.
 
@@ -114,8 +114,8 @@ and dynamically resized it depending on how many chart types are available.

        Element( double value = INVALID, TQColor valueColor = TQt::gray,
                  int valuePattern = TQt::SolidPattern,
-                 const TQString& label = TQString::null,
-                 TQColor labelColor = TQt::black ) {
+                 const TQString& label = TQString::null,
+                 TQColor labelColor = TQt::black ) {
             init( value, valueColor, valuePattern, label, labelColor );
             for ( int i = 0; i < MAX_PROPOINTS * 2; ++i )
                 m_propoints[i] = NO_PROPORTION;
@@ -136,7 +136,7 @@ with the isValid() function.
 
 
    double Element::proX( int index ) const
     {
-        Q_ASSERT(index >= 0 && index < MAX_PROPOINTS);
+        Q_ASSERT(index >= 0 && index < MAX_PROPOINTS);
         return m_propoints[2 * index];
     }
 
@@ -153,8 +153,8 @@ index; (see Debugging).

(Extracts from element.h.)

-

    TQTextStream &operator<<( TQTextStream&, const Element& );
-    TQTextStream &operator>>( TQTextStream&, Element& );
+
    TQTextStream &operator<<( TQTextStream&, const Element& );
+    TQTextStream &operator>>( TQTextStream&, Element& );
 

To make our Element class more self-contained we provide overloads for the << and >> operators so that Elements may be written to @@ -167,10 +167,10 @@ filter the data using a scripting language.

    #include "element.h"
 
-    #include <qstringlist.h>
-    #include <qtextstream.h>
+    #include <ntqstringlist.h>
+    #include <ntqtextstream.h>
 
-

Our implementation of the operators requires the inclusion of qtextstream.h and qstringlist.h. +

Our implementation of the operators requires the inclusion of ntqtextstream.h and ntqstringlist.h.

    const char FIELD_SEP = ':';
     const char PROPOINT_SEP = ';';
     const char XY_SEP = ',';
@@ -190,7 +190,7 @@ label text. For example:
  
 

There's no problem having whitespace and field separators in label text due to the way we read Element data. -

    TQTextStream &operator<<( TQTextStream &s, const Element &element )
+

    TQTextStream &operator<<( TQTextStream &s, const Element &element )
     {
         s << element.value() << FIELD_SEP
           << element.valueColor().name() << FIELD_SEP
@@ -210,39 +210,39 @@ text due to the way we read Element data.
 

Writing elements is straight-forward. Each member is written followed by a field separator. The points are written as comma separated (XY_SEP) x, y pairs, each pair separated by the PROPOINT_SEP separator. The final field is the label followed by a newline. -

    TQTextStream &operator>>( TQTextStream &s, Element &element )
+

    TQTextStream &operator>>( TQTextStream &s, Element &element )
     {
-        TQString data = s.readLine();
+        TQString data = s.readLine();
         element.setValue( Element::INVALID );
 
         int errors = 0;
         bool ok;
 
-        TQStringList fields = TQStringList::split( FIELD_SEP, data );
-        if ( fields.count() >= 4 ) {
+        TQStringList fields = TQStringList::split( FIELD_SEP, data );
+        if ( fields.count() >= 4 ) {
             double value = fields[0].toDouble( &ok );
             if ( !ok )
                 errors++;
-            TQColor valueColor = TQColor( fields[1] );
-            if ( !valueColor.isValid() )
+            TQColor valueColor = TQColor( fields[1] );
+            if ( !valueColor.isValid() )
                 errors++;
             int valuePattern = fields[2].toInt( &ok );
             if ( !ok )
                 errors++;
-            TQColor labelColor = TQColor( fields[3] );
-            if ( !labelColor.isValid() )
+            TQColor labelColor = TQColor( fields[3] );
+            if ( !labelColor.isValid() )
                 errors++;
-            TQStringList propoints = TQStringList::split( PROPOINT_SEP, fields[4] );
-            TQString label = data.section( FIELD_SEP, 5 );
+            TQStringList propoints = TQStringList::split( PROPOINT_SEP, fields[4] );
+            TQString label = data.section( FIELD_SEP, 5 );
 
             if ( !errors ) {
                 element.set( value, valueColor, valuePattern, label, labelColor );
                 int i = 0;
-                for ( TQStringList::iterator point = propoints.begin();
-                    i < Element::MAX_PROPOINTS && point != propoints.end();
+                for ( TQStringList::iterator point = propoints.begin();
+                    i < Element::MAX_PROPOINTS && point != propoints.end();
                     ++i, ++point ) {
                     errors = 0;
-                    TQStringList xy = TQStringList::split( XY_SEP, *point );
+                    TQStringList xy = TQStringList::split( XY_SEP, *point );
                     double x = xy[0].toDouble( &ok );
                     if ( !ok || x <= 0.0 || x >= 1.0 )
                         errors++;
@@ -261,9 +261,9 @@ separator. The final field is the label followed by a newline.
     }
 

To read an element we read one record (i.e. one line). We break the -data into fields using TQStringList::split(). Because it is possible +data into fields using TQStringList::split(). Because it is possible that a label will contain FIELD_SEP characters we use -TQString::section() to extract all the text from the last field to the +TQString::section() to extract all the text from the last field to the end of the line. If there are enough fields and the value, colors and pattern data is valid we use Element::set() to write this data into the element; otherwise we leave the element INVALID. We then -- cgit v1.2.1