/** * @file ScosTime/gui.h * @brief GUI for the ScosTime application * @author Enar Vaikene * * Copyright (c) 2012 Enar Vaikene * * This file is part of the eVaf C++ cross-platform application development framework. * * This file can be used under the terms of the GNU General Public License * version 3.0 as published by the Free Software Foundation and appearing in * the file LICENSE included in the packaging of this file. Please review the * the following information to ensure the GNU General Public License version * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. * * Alternatively, this file may be used in accordance with the Commercial License * Agreement provided with the Software. */ #ifndef __SCOSTIME_GUI_H # define __SCOSTIME_GUI_H #include #include #include #include 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. * * This module adds a GUI window to the ScosTime application using the SdiWindow module. */ class Module : public Plugins::iPlugin { Q_OBJECT Q_INTERFACES(eVaf::Plugins::iPlugin) enum DateTimeType { InvalidDateTime, AsdDateTime, IsoDateTime }; enum ValidEntry { NoValidEntry, DateTimeEntry, CUCEntry }; public: Module(); virtual ~Module(); virtual bool init(const QString & args); virtual void done(); virtual bool isReady() const { return mReady; } private slots: void epochChanged(QString const & s); void dateTimeClicked(); void dateTimeEdited(QString const & s); void cucHexEdited(QString const & s); private: // Methods 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; QPushButton * wConvertDateTime; QLineEdit * wCucHex; }; } // namespace eVaf::ScosTime } // namespace eVaf #endif // gui.h