1 /** |
|
2 * Utils.cpp is part of bmsapp. |
|
3 * |
|
4 * See https://www.qtcentre.org/threads/17295-How-to-put-empty-value-in-QDateEdit |
|
5 * |
|
6 * bmsapp is free software: you can redistribute it and/or modify |
|
7 * it under the terms of the GNU General Public License as published by |
|
8 * the Free Software Foundation, either version 3 of the License, or |
|
9 * (at your option) any later version. |
|
10 * |
|
11 * bmsapp is distributed in the hope that it will be useful, |
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 * GNU General Public License for more details. |
|
15 * |
|
16 * You should have received a copy of the GNU General Public License |
|
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
18 */ |
|
19 #include "nulldateedit.h" |
|
20 |
|
21 |
|
22 NullDateEdit::NullDateEdit(const QDate& date, QWidget* parent) |
|
23 : QDateEdit(date, parent) |
|
24 { |
|
25 this->setSpecialValueText("Null"); |
|
26 } |
|
27 |
|
28 NullDateEdit::NullDateEdit(QWidget* parent) |
|
29 : QDateEdit(parent) |
|
30 { |
|
31 this->setSpecialValueText("Null"); |
|
32 } |
|
33 |
|
34 NullDateEdit::~NullDateEdit() |
|
35 { |
|
36 } |
|
37 |
|
38 void NullDateEdit::clear() |
|
39 { |
|
40 this->setDate(this->minimumDate()); |
|
41 } |
|
42 |
|
43 QDate NullDateEdit::nullDate() const |
|
44 { |
|
45 if (date() == this->minimumDate()) |
|
46 return QDate(); |
|
47 return date(); |
|
48 } |
|
49 |
|
50 void NullDateEdit::setDate(const QDate & date) |
|
51 { |
|
52 if (date.isNull()) |
|
53 QDateEdit::setDate(this->minimumDate()); |
|
54 QDateEdit::setDate(date); |
|
55 } |
|