annotate src/gui/widgets/optional_date.cc @ 376:5d716acb2774

gui/dialog/dialog: fix win32 build
author Paper <paper@tflc.us>
date Fri, 25 Jul 2025 12:28:38 -0400
parents ea3a74ed2ef9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
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
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
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
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
30 connect(_checkbox, &QCheckBox::stateChanged, this, [this](int state) {
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
31 SetEnabled(state == Qt::Checked);
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
32 emit DataChanged(IsEnabled(), GetDate());
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
33 });
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
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
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
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
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
55 if (!date.IsValid())
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 62
diff changeset
56 return;
51
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
57 SetDate(date.GetAsQDate());
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
58 }
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
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
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
62 return Date(_dateedit->date());
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
63 }
75c804f713b2 window: add about window,
Paper <mrpapersonic@gmail.com>
parents: 48
diff changeset
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 }