Mercurial > minori
annotate src/gui/widgets/optional_date.cc @ 378:5912dafc6e28
anime: add poster cache
:)
| author | Paper <paper@tflc.us> |
|---|---|
| date | Wed, 05 Nov 2025 12:50:35 -0500 |
| parents | ea3a74ed2ef9 |
| children |
| rev | line source |
|---|---|
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
1 #include "gui/widgets/optional_date.h" |
| 51 | 2 #include "core/date.h" |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
3 #include <QCheckBox> |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
4 #include <QDateEdit> |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
5 #include <QHBoxLayout> |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
6 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
7 OptionalDate::OptionalDate(QWidget *parent) |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
8 { |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
9 OptionalDate(false, parent); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
10 } |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
11 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
12 OptionalDate::OptionalDate(bool enabled, QWidget *parent) : QWidget(parent) |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
13 { |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
14 QHBoxLayout *layout = new QHBoxLayout(this); |
| 62 | 15 layout->setContentsMargins(0, 0, 0, 0); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
16 |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
17 _checkbox = new QCheckBox(this); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
18 _checkbox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
19 |
|
48
e613772f41d5
statistics.cpp: show requests made
Paper <mrpapersonic@gmail.com>
parents:
47
diff
changeset
|
20 layout->addWidget(_checkbox, 0, Qt::AlignVCenter); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
21 |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
22 _dateedit = new QDateEdit(this); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
23 _dateedit->setDisplayFormat("yyyy-MM-dd"); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
24 _dateedit->setCalendarPopup(true); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
25 _dateedit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
26 |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
27 layout->addWidget(_dateedit); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
28 |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
29 SetEnabled(enabled); |
| 51 | 30 connect(_checkbox, &QCheckBox::stateChanged, this, [this](int state) { |
| 31 SetEnabled(state == Qt::Checked); | |
| 32 emit DataChanged(IsEnabled(), GetDate()); | |
| 33 }); | |
| 63 | 34 connect(_dateedit, &QDateEdit::dateChanged, this, [this](QDate) { emit DataChanged(IsEnabled(), GetDate()); }); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
35 } |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
36 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
37 void OptionalDate::SetEnabled(bool enabled) |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
38 { |
| 51 | 39 _checkbox->setCheckState(enabled ? Qt::Checked : Qt::Unchecked); |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
40 _dateedit->setEnabled(enabled); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
41 } |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
42 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
43 bool OptionalDate::IsEnabled() |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
44 { |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
45 return _dateedit->isEnabled(); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
46 } |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
47 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
48 void OptionalDate::SetDate(QDate date) |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
49 { |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
50 _dateedit->setDate(date); |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
51 } |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
52 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
53 void OptionalDate::SetDate(Date date) |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
54 { |
| 63 | 55 if (!date.IsValid()) |
| 56 return; | |
| 51 | 57 SetDate(date.GetAsQDate()); |
| 58 } | |
| 59 | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
60 Date OptionalDate::GetDate() |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
61 { |
| 51 | 62 return Date(_dateedit->date()); |
| 63 } | |
| 64 | |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
65 QDateEdit *OptionalDate::GetDateEdit() |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
66 { |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
67 return _dateedit; |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
68 } |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
69 |
|
370
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
70 QCheckBox *OptionalDate::GetCheckBox() |
|
ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
Paper <paper@tflc.us>
parents:
236
diff
changeset
|
71 { |
|
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
72 return _checkbox; |
|
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
73 } |
