// // Created by Krad on 2022/3/24. // #include "DateSelectDialog.h" #include #include #include #include "components/DateSlidePickerBox.h" DateSelectDialog::DateSelectDialog(QWidget *parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) { this->setFixedSize(460, 380); QVBoxLayout* layout = new QVBoxLayout(formWidget); 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() { } QString DateSelectDialog::getSelectedValue() { return box->getSelectedValue(); } void DateSelectDialog::setSelectedValue(const QString &val) { box->setSelectedValue(val); box->resizeLabel(); } 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; } void DateSelectDialog::showEvent(QShowEvent * event) { QDialog::showEvent(event); }