00001
00002
00003
00004
00005
00006
00007 #ifndef FORMAT_DATE_TIME_H
00008 #define FORMAT_DATE_TIME_H
00009
00010 #include "CoordUnitsDate.h"
00011 #include "CoordUnitsTime.h"
00012 #include <QDateTime>
00013 #include <QHash>
00014 #include <QString>
00015 #include <QStringList>
00016 #include <QValidator>
00017
00018 typedef QHash<CoordUnitsDate, QString> FormatDate;
00019 typedef QHash<CoordUnitsTime, QString> FormatTime;
00020
00021 typedef QHash<CoordUnitsDate, QStringList> FormatsDate;
00022 typedef QHash<CoordUnitsTime, QStringList> FormatsTime;
00023
00025 class FormatDateTime {
00026 public:
00028 FormatDateTime();
00029
00031 QString formatOutput (CoordUnitsDate coordUnitsDate,
00032 CoordUnitsTime coordUnitsTime,
00033 double value) const;
00034
00037 QValidator::State parseInput (CoordUnitsDate coordUnitsDate,
00038 CoordUnitsTime coordUnitsTime,
00039 const QString &stringUntrimmed,
00040 double &value) const;
00041
00042 private:
00043
00044 bool ambiguityBetweenDateAndTime (CoordUnitsDate coordUnitsDate,
00045 CoordUnitsTime coordUnitsTime,
00046 const QString &string) const;
00047 void dateTimeLookup (const FormatsDate &formatsDate,
00048 const FormatsTime &formatsTime,
00049 CoordUnitsDate coordUnitsDate,
00050 CoordUnitsTime coordUnitsTime,
00051 const QString &string,
00052 bool useQDateTimeElseQRegExp,
00053 double &value,
00054 bool &success) const;
00055 void loadFormatsFormat();
00056 void loadFormatsParseAcceptable();
00057 void loadFormatsParseIncomplete();
00058
00059
00060 FormatDate m_formatsDateFormat;
00061 FormatTime m_formatsTimeFormat;
00062
00063
00064 FormatsDate m_formatsDateParseAcceptable;
00065 FormatsTime m_formatsTimeParseAcceptable;
00066
00067
00068
00069
00070 FormatsDate m_formatsDateParseIncomplete;
00071 FormatsTime m_formatsTimeParseIncomplete;
00072 };
00073
00074 #endif // FORMAT_DATE_TIME_H