File indexing completed on 2024-05-12 05:14:39

0001 /*
0002  *  birthdaydlg.h  -  dialog to pick birthdays from address book
0003  *  Program:  kalarm
0004  *  SPDX-FileCopyrightText: 2002-2022 David Jarvie <djarvie@kde.org>
0005  *
0006  *  SPDX-License-Identifier: GPL-2.0-or-later
0007  */
0008 #pragma once
0009 
0010 #include "kalarmcalendar/kaevent.h"
0011 
0012 #include <KLineEdit>
0013 
0014 #include <QDialog>
0015 #include <QList>
0016 
0017 class QFocusEvent;
0018 class QTreeView;
0019 class CheckBox;
0020 class FontColourButton;
0021 class SoundPicker;
0022 class SpecialActionsButton;
0023 class RepetitionButton;
0024 class LateCancelSelector;
0025 class Reminder;
0026 class BLineEdit;
0027 class QSortFilterProxyModel;
0028 class QDialogButtonBox;
0029 
0030 using namespace KAlarmCal;
0031 
0032 class BirthdayDlg : public QDialog
0033 {
0034     Q_OBJECT
0035 public:
0036     explicit BirthdayDlg(QWidget* parent = nullptr);
0037     QList<KAEvent> events() const;
0038 
0039 protected Q_SLOTS:
0040     virtual void   slotOk();
0041 
0042 private Q_SLOTS:
0043     void           slotSelectionChanged();
0044     void           slotTextLostFocus();
0045     void           resizeViewColumns();
0046     void           setColours(const QColor& fg, const QColor& bg);
0047 
0048 private:
0049     void           setSortModelSelectionList();
0050 
0051     QSortFilterProxyModel* mBirthdaySortModel;   // actually a BirthdaySortModel, inherited from QSortFilterProxyModel
0052     QTreeView*             mListView;
0053     KLineEdit*             mName {nullptr};
0054     BLineEdit*             mPrefix;
0055     BLineEdit*             mSuffix;
0056     Reminder*              mReminder;
0057     SoundPicker*           mSoundPicker;
0058     FontColourButton*      mFontColourButton;
0059     CheckBox*              mConfirmAck;
0060     LateCancelSelector*    mLateCancel;
0061     SpecialActionsButton*  mSpecialActionsButton {nullptr};
0062     RepetitionButton*      mSubRepetition;
0063     QDialogButtonBox*      mButtonBox;
0064     QString                mPrefixText;   // last entered value of prefix text
0065     QString                mSuffixText;   // last entered value of suffix text
0066     KAEvent::Flags         mFlags;        // event flag bits
0067     int                    mBirthdayModel_NameColumn {-1};
0068     int                    mBirthdayModel_DateColumn {-1};
0069     int                    mBirthdayModel_DateRole {-1};
0070 };
0071 
0072 
0073 /** Line edit with a focusLost() signal. */
0074 class BLineEdit : public KLineEdit
0075 {
0076     Q_OBJECT
0077 public:
0078     explicit BLineEdit(QWidget* parent = nullptr)                       : KLineEdit(parent) {}
0079     explicit BLineEdit(const QString& text, QWidget* parent = nullptr)  : KLineEdit(text, parent) {}
0080 
0081 Q_SIGNALS:
0082     void focusLost();
0083 
0084 protected:
0085     void focusOutEvent(QFocusEvent*) override { Q_EMIT focusLost(); }
0086 };
0087 
0088 // vim: et sw=4: