Add date onlyBackward limit.
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "DateSelectDialog.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QDate>
|
||||
#include "components/DateSlidePickerBox.h"
|
||||
DateSelectDialog::DateSelectDialog(QWidget *parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) {
|
||||
this->setFixedSize(460, 380);
|
||||
@@ -11,7 +13,12 @@ DateSelectDialog::DateSelectDialog(QWidget *parent, Qt::WindowFlags f) : GUIForm
|
||||
box = new DateSlidePickerBox(formWidget);
|
||||
box->setObjectName("slider_one");
|
||||
box->setSelectedValue("1990-01-01");
|
||||
lbl_error = new QLabel(this);
|
||||
lbl_error->setObjectName("warn");
|
||||
lbl_error->setVisible(false);
|
||||
lbl_error->setText(tr("Date exceeded!"));
|
||||
layout->addWidget(box);
|
||||
layout->addWidget(lbl_error);
|
||||
}
|
||||
|
||||
DateSelectDialog::~DateSelectDialog() {
|
||||
@@ -19,6 +26,7 @@ DateSelectDialog::~DateSelectDialog() {
|
||||
}
|
||||
|
||||
QString DateSelectDialog::getSelectedValue() {
|
||||
|
||||
return box->getSelectedValue();
|
||||
}
|
||||
|
||||
@@ -28,6 +36,13 @@ void DateSelectDialog::setSelectedValue(const QString &val) {
|
||||
}
|
||||
|
||||
bool DateSelectDialog::updateReferenceData() {
|
||||
if (onlyBackward){
|
||||
QDate v = QDate::fromString(box->getSelectedValue(),"yyyy-MM-dd");
|
||||
bool flag = QDate::currentDate()>=v;
|
||||
this->setFixedHeight(flag? 380:410);
|
||||
lbl_error->setVisible(!flag);
|
||||
return flag;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "dialogs/GUIFormBaseDialog.h"
|
||||
class DateSlidePickerBox;
|
||||
class QLabel;
|
||||
class DateSelectDialog:public GUIFormBaseDialog{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -15,9 +16,14 @@ public:
|
||||
QString getSelectedValue();
|
||||
void setSelectedValue(const QString& val);
|
||||
void showEvent(QShowEvent *) override;
|
||||
void setOnlyBackward(bool val){
|
||||
onlyBackward = val;
|
||||
}
|
||||
protected:
|
||||
bool updateReferenceData() override;
|
||||
DateSlidePickerBox* box;
|
||||
QLabel* lbl_error = nullptr;
|
||||
bool onlyBackward = true;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user