Files
qt6-migration-pipeline/Lts/Common/LtsWidgets/lts_date_time_edit_rc.h
T

207 lines
5.1 KiB
C++
Executable File

#pragma once
#include "lts_widgets_export.h"
#include <QWidget>
#include <functional>
namespace Ui
{
class LtsDateTimeEditLe;
class LtsDateTimeEdit;
}
class QLineEdit;
class QShortcut;
namespace LtsWidgets
{
class LTSWIDGETS_EXPORT LtsDateTimeEdit : public QWidget
{
Q_OBJECT
Q_PROPERTY(bool autoForward READ getAutoForward WRITE setAutoForward)
Q_PROPERTY(bool editTimezone READ getEditTimezone WRITE setEditTimezone)
Q_PROPERTY(bool withButtons READ getWithButtons WRITE setWithButtons)
Q_PROPERTY(bool withSlider READ getWithSlider WRITE setWithSlider)
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
Q_PROPERTY(bool withNowButton READ withNowButton WRITE setWithNowButton)
Q_PROPERTY(bool withCheckBox READ withCheckBox WRITE setWithCheckBox)
public:
using CurrentTimeCallback = std::function<qint64()>;
explicit LtsDateTimeEdit(QWidget *parent = nullptr, bool withNowButton = true, bool withCheckBox = false);
~LtsDateTimeEdit();
bool setupUiTouch();
qint64 msecsSinceEpoch() const;
bool isEmpty() const;
bool isValidDate() const;
void setAutoForward(const bool af) { m_autoForward = af; }
bool getAutoForward() const { return m_autoForward; }
void setEditTimezone(const bool edit);
bool getEditTimezone() const { return m_editTimezone; }
void setWithButtons(const bool buttons);
bool getWithButtons() const { return m_withButtons; }
void setWithSlider(const bool slider);
bool getWithSlider() const { return m_withSlider; }
void setReadOnly(const bool readOnly);
bool isReadOnly() const { return m_readOnly; }
void setWithCheckBox(bool checkBoxEnabled);
bool withCheckBox() const { return m_withCheckBox; }
void setCheckBoxChecked(bool bChecked);
bool isCheckBoxChecked() const;
void setWithNowButton(bool nowButton);
bool withNowButton() const { return m_withNowButton; }
void setMinimumTimeMSec(qint64 msec);
qint64 minimumTimeMSec() const { return m_minTimeMSec; }
void setMaximumTimeMSec(qint64 msec);
qint64 maximumTimeMSec() const { return m_maxTimeMSec; }
void setMinMaxTimeMSec(qint64 min, qint64 max) { setMinimumTimeMSec(min); setMaximumTimeMSec(max); }
void setRetrieveCurrentTimeCallback(const CurrentTimeCallback &cb);
bool setTimezone(char tz);
char getTimezone() const;
qint64 getTimezoneAsSecs() const;
void setSubWidgetsProperties(const QString &name, const QVariant &value);
Q_SIGNALS:
void dateTimeChanged();
public Q_SLOTS:
bool setMsecsSinceEpoch(qint64 msec, bool setToNearestPossible = true);
void clear();
private:
void clearTimezone();
void setMinMaxMonth(int minMonth, int maxMonth);
bool setMonth(int month);
int getMonth() const;
bool setDay(int day);
int getDay() const;
bool setHHMMSS(int hour, int minute, int second);
int getHour() const;
int getMinute() const;
int getSecond() const;
bool setYear(int year);
int getYear() const;
bool isEmptyDay() const;
bool isEmptyHHMMSS() const;
bool isEmptyTimezone() const;
bool isEmptyMonth() const;
bool isEmptyYear() const;
bool hasFocus() const;
bool isDataAcceptable();
void showInvalidData(bool setFocus);
bool isLineEditDataAcceptable(QLineEdit *le) const;
bool isDayAcceptable() const;
bool isHHMMSSAcceptable() const;
bool isMonthAcceptable() const;
bool isYearAcceptable() const;
bool isTzAcceptable() const;
private Q_SLOTS:
void setFixedDateTime();
void setOffsetDateTime();
void setSliderValue(int val);
void valueDayChanged(const QString &str);
void fixupHHMMSS();
void valueMonthChanged(const QString &str);
void valueMonthChanged2(const QString &str);
void valueTimezoneChangedStr(const QString &str);
void valueTimezoneChangedInt(int newTimezone);
void valueYearChanged(const QString &str);
void onBackHourClicked();
void onBackMinuteClicked();
void onBackSecondClicked();
void onForwardSecondClicked();
void onForwardMinuteClicked();
void onForwardHourClicked();
void onCheckBoxChanged();
void disableControls();
void enableControls();
void enaDisaControls(bool bEnable);
void onFocusOutHHMMSS();
void onFocusOutTZ();
void onFocusOutDay();
void onFocusOutMonth();
void onFocusOutYear();
void onFocusOutBackspace();
void onFocusOut();
void onHmsWheelEvent(bool bForward, int cursorPos);
void onDayWheelEvent(bool bForward, int cursorPos);
void onMonthWheelEvent(bool bForward, int cursorPos);
void onYearWheelEvent(bool bForward, int cursorPos);
private:
Ui::LtsDateTimeEditLe *m_uiLe{nullptr};
Ui::LtsDateTimeEdit *m_uiTouch{nullptr};
QShortcut *m_scFixed = nullptr;
QShortcut *m_scOffset = nullptr;
CurrentTimeCallback m_getCurrentTimeCallback = nullptr;
qint64 m_minTimeMSec = 0;
qint64 m_maxTimeMSec = 0;
qint64 m_curTimeMSec = -1;
bool m_editTimezone = true;
bool m_autoForward = true;
bool m_withButtons = false;
bool m_withSlider = false;
bool m_readOnly = false;
bool m_withCheckBox = false;
bool m_withNowButton = false;
int m_minMonth{0};
int m_maxMonth{0};
bool m_backspacePressed = false;
bool m_recursionAvoid = false;
bool m_dateIsAcceptable = false;
};
}