Improved special field handling in text element.
[jspeed] / src / textelement.h
index 02e34f8..ec4f7f1 100644 (file)
@@ -30,6 +30,7 @@ class TextElement : public GraphicsElement
 {
 public:
     enum Attribute {XPOS, YPOS, DATA, FORMAT, WIDTH, ALIGN, COLOR, SIZE, FONT, ATTRIBUTE_COUNT};
+    enum Field {TRIP, TOTAL, SPEED, MAXSPEED, AVGSPEED, UNIT, SPEEDUNIT, FIELD_COUNT};
     TextElement(Reader* reader);
     virtual bool setAttribute(QString const& name, QString const& value);
     virtual void addToScene(GraphicsScene* scene);
@@ -37,7 +38,8 @@ public:
 
 private:
     void updateHtml(QString const& data);
-    bool replaceSpecialField(QString& value);
+    void replaceSpecialFields(QString& value);
+    void replaceValue(QString& value, Field field, QString const& replace);
     QString formatString(double val);
     QGraphicsTextItem* element_;
     QString data_;
@@ -45,7 +47,7 @@ private:
     QString align_;
     int fontSize_;
     QString fontFile_;
-    bool hasSpecialField_;
+    QList<Field> specialFields_;
 };
 
 #endif