File indexing completed on 2024-04-28 04:21:18

0001 // SPDX-FileCopyrightText: 2014-2022 Jesper K. Pedersen <blackie@kde.org>
0002 //
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004 
0005 #ifndef BIRTHDAYPAGE_H
0006 #define BIRTHDAYPAGE_H
0007 
0008 // Qt includes
0009 #include <QDate>
0010 #include <QMap>
0011 #include <QWidget>
0012 
0013 // Qt classes
0014 class QLineEdit;
0015 class QComboBox;
0016 class QTableWidget;
0017 class QFont;
0018 class QCalendarWidget;
0019 class QPushButton;
0020 class QTableWidgetItem;
0021 class QLabel;
0022 
0023 // KDE classes
0024 class KPageWidgetItem;
0025 
0026 namespace Settings
0027 {
0028 
0029 class BirthdayPage : public QWidget
0030 {
0031     Q_OBJECT
0032 
0033 public Q_SLOTS:
0034     void pageChange(KPageWidgetItem *page);
0035     void discardChanges();
0036     void saveSettings();
0037 
0038 private Q_SLOTS:
0039     void changeCategory(int index);
0040     void resetCategory();
0041     void editDate(int row, int);
0042     QDate parseDate(QString date);
0043     void checkDateInput(QString date);
0044     void checkDate();
0045     void setDate(const QDate &date);
0046     void removeDate();
0047 
0048 public:
0049     BirthdayPage(QWidget *parent);
0050     void reload();
0051 
0052 private: // Functions
0053     QString textForDate(const QDate &date) const;
0054     void disableCalendar();
0055 
0056 private: // Variables
0057     QLineEdit *m_filter;
0058     QComboBox *m_categoryBox;
0059     QTableWidget *m_dataView;
0060     QTableWidgetItem *m_lastItem = nullptr;
0061     QFont m_font;
0062     QFont m_boldFont;
0063     QLineEdit *m_dateInput;
0064     QCalendarWidget *m_calendar;
0065     QPushButton *m_unsetButton;
0066     QString m_noDateString;
0067     QMap<QString, QMap<QString, QDate>> m_changedData;
0068     QLabel *m_birthdayOfLabel;
0069     QStringList m_dateFormats;
0070 };
0071 
0072 }
0073 
0074 #endif // BIRTHDAYPAGE_H