X-Git-Url: https://vaikene.ee/gitweb/pswgen11.html?a=blobdiff_plain;f=src%2Fapps%2FScosTime%2Fgui.h;h=90f33c2f90edf3e269acf84c022e355ce79d0d30;hb=8c1076918aee67a8d6adae31fc14156c9779d471;hp=fe6b5e3f3dcad059f2b9c6d0f6983bf1570c4d26;hpb=51afea61c3cf72248b2998f6874a354b49ed12ca;p=evaf
diff --git a/src/apps/ScosTime/gui.h b/src/apps/ScosTime/gui.h
index fe6b5e3..90f33c2 100644
--- a/src/apps/ScosTime/gui.h
+++ b/src/apps/ScosTime/gui.h
@@ -28,10 +28,73 @@
class QLineEdit;
class QComboBox;
+class QRegExp;
+class QPushButton;
namespace eVaf {
namespace ScosTime {
+namespace Internal {
+
+/**
+ * SCOS date/time class
+ */
+class DateTime
+{
+public:
+
+ /**
+ * Creates an invalid date/time value
+ */
+ DateTime() {}
+
+ /**
+ * Creates a date/time value from the string.
+ * @param s Input string
+ * @param epoch Epoch
+ *
+ * The input string can be:
+ * @li Date/time in ISO format yyyy-MM-ddThh:mm[:ss[.zzz]]
+ * @li Date/time in ASD format yyyy.ddd.hh.mm[.ss[.zzz]]
+ * @li CUC hex string cccccccc[ffff]
+ *
+ * If the string is invalid, creates an invalid date/time value.
+ */
+ DateTime(String const & s, String const & epoch);
+
+ /**
+ * Returns true if the date/time value is valid.
+ */
+ bool isValid() const { return mDateTime.isValid(); }
+
+ /**
+ * Returns the date/time value a string in the ISO format yyyy-MM-ddThh:mm:ss.zzz
+ */
+ QString asIsoString() const;
+
+ /**
+ * Returns the date/time value as a string in the ASD format yyyy.ddd.hh.mm.ss.zzz
+ */
+ QString asAsdString() const;
+
+ /**
+ * Returns the date/time value as a CUC hex string in the format ccccccccffff
+ */
+ QString asCucHexString() const;
+
+
+private:
+
+ /// Date/time value
+ QDateTime mDateTime;
+
+ /// Epoch
+ QDateTime mEpoch;
+
+};
+
+} // namespace eVaf::ScosTime::Internal
+
/**
* Graphical User Interface for the ScosTime application.
*
@@ -42,6 +105,20 @@ class Module : public Plugins::iPlugin
Q_OBJECT
Q_INTERFACES(eVaf::Plugins::iPlugin)
+ enum DateTimeType
+ {
+ InvalidDateTime,
+ AsdDateTime,
+ IsoDateTime
+ };
+
+ enum ValidEntry
+ {
+ NoValidEntry,
+ DateTimeEntry,
+ CUCEntry
+ };
+
public:
Module();
@@ -57,24 +134,45 @@ public:
private slots:
+ void epochChanged(QString const & s);
+
void dateTimeClicked();
- void hexClicked();
+ void dateTimeEdited(QString const & s);
+
+ void cucHexEdited(QString const & s);
private: // Methods
- QDateTime strToDateTime(QString const & s) const;
+ DateTimeType getDateTimeType(QString const & s) const;
+
+ QDateTime strToDateTime(QString const & s, DateTimeType type) const;
+
+ QString dateTimeToAsdStr(QDateTime const & tm) const;
+
+ void setDateTimeFromCucHex(QString const & s);
+
+ void setCucHexFromDateTime(QString const & s, DateTimeType type);
+
private: // Members
/// Flag indicating that the module is ready
bool mReady;
+ /// Last valid entry (field modified by the user)
+ ValidEntry mLastValidEntry;
+
+ /// Regular expressions
+ QRegExp * rxIsoDateTime;
+ QRegExp * rxAsdDateTime;
+
/// Widgets on the screen
QComboBox * wEpoch;
QLineEdit * wDateTime;
- QLineEdit * wHex;
+ QPushButton * wConvertDateTime;
+ QLineEdit * wCucHex;
};