Files
GUI/src/DateSelectDialog.cpp
2022-05-09 15:30:36 +08:00

52 lines
1.3 KiB
C++

//
// Created by Krad on 2022/3/24.
//
#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);
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);
}