Engauge Digitizer 2
Loading...
Searching...
No Matches
FormatDateTime.h
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5 ******************************************************************************************************/
6
7#ifndef FORMAT_DATE_TIME_H
8#define FORMAT_DATE_TIME_H
9
10#include "CoordUnitsDate.h"
11#include "CoordUnitsTime.h"
12#include <QDateTime>
13#include <QHash>
14#include <QString>
15#include <QStringList>
16#include <QValidator>
17
20
23
26 public:
29
31 QString formatOutput (CoordUnitsDate coordUnitsDate,
32 CoordUnitsTime coordUnitsTime,
33 double value) const;
34
37 QValidator::State parseInput (CoordUnitsDate coordUnitsDate,
38 CoordUnitsTime coordUnitsTime,
40 double &value) const;
41
42 private:
43
44 bool ambiguityBetweenDateAndTime (CoordUnitsDate coordUnitsDate,
45 CoordUnitsTime coordUnitsTime,
46 const QString &string) const;
47 void dateTimeLookup (const FormatsDate &formatsDate,
49 CoordUnitsDate coordUnitsDate,
50 CoordUnitsTime coordUnitsTime,
51 const QString &string,
53 double &value, // Set only if useQDateTimeElseQRegExp=success=true
54 bool &success) const;
55 void loadFormatsFormat();
56 void loadFormatsParseAcceptable();
57 void loadFormatsParseIncomplete();
58
59 // For formatting output
60 FormatDate m_formatsDateFormat;
61 FormatTime m_formatsTimeFormat;
62
63 // For parsing input, using built in Qt date/time parsing according to QDateTime
64 FormatsDate m_formatsDateParseAcceptable;
65 FormatsTime m_formatsTimeParseAcceptable;
66
67 // For parsing input, after input has been found to not be Acceptable. Regular expressions are used since Qt date/time
68 // parsing of Intermediate strings does not work. Example, 'J' and 'Ja' would be rejected although they are typed
69 // in the process of entering 'Jan' for the month
70 FormatsDate m_formatsDateParseIncomplete;
71 FormatsTime m_formatsTimeParseIncomplete;
72};
73
74#endif // FORMAT_DATE_TIME_H
CoordUnitsDate
CoordUnitsTime
const int INNER_RADIUS_MIN
QHash< CoordUnitsDate, QStringList > FormatsDate
QHash< CoordUnitsTime, QStringList > FormatsTime
QHash< CoordUnitsTime, QString > FormatTime
QHash< CoordUnitsDate, QString > FormatDate
Input parsing and output formatting for date/time values.
FormatDateTime()
Single constructor.
QValidator::State parseInput(CoordUnitsDate coordUnitsDate, CoordUnitsTime coordUnitsTime, const QString &stringUntrimmed, double &value) const
Parse the input string into a time value.
QString formatOutput(CoordUnitsDate coordUnitsDate, CoordUnitsTime coordUnitsTime, double value) const
Format the date/time value according to date/time format settings.