File indexing completed on 2024-04-28 05:11:31
0001 /* 0002 SPDX-FileCopyrightText: 2010 Casey Link <unnamedrambler@gmail.com> 0003 SPDX-FileCopyrightText: 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include <Libkdepim/MultiplyingLine> 0011 #include <PimCommonAkonadi/AddresseeLineEdit> 0012 0013 #include <KCalendarCore/Attendee> 0014 0015 #include <QCheckBox> 0016 #include <QToolButton> 0017 0018 class QKeyEvent; 0019 0020 namespace IncidenceEditorNG 0021 { 0022 class AttendeeData; 0023 0024 class AttendeeComboBox : public QToolButton 0025 { 0026 Q_OBJECT 0027 public: 0028 explicit AttendeeComboBox(QWidget *parent); 0029 0030 void addItem(const QIcon &icon, const QString &text); 0031 void addItems(const QStringList &texts); 0032 0033 [[nodiscard]] int currentIndex() const; 0034 0035 Q_SIGNALS: 0036 void rightPressed(); 0037 void leftPressed(); 0038 void itemChanged(); 0039 0040 public Q_SLOTS: 0041 /** Clears the combobox, removing all items. */ 0042 void clear(); 0043 void setCurrentIndex(int index); 0044 0045 protected: 0046 void keyPressEvent(QKeyEvent *ev) override; 0047 0048 private: 0049 void slotActionTriggered(); 0050 QMenu *mMenu = nullptr; 0051 QList<QPair<QString, QIcon>> mList; 0052 int mCurrentIndex = -1; 0053 }; 0054 0055 class AttendeeLineEdit : public PimCommon::AddresseeLineEdit 0056 { 0057 Q_OBJECT 0058 public: 0059 explicit AttendeeLineEdit(QWidget *parent); 0060 0061 Q_SIGNALS: 0062 void deleteMe(); 0063 void leftPressed(); 0064 void rightPressed(); 0065 void upPressed(); 0066 void downPressed(); 0067 0068 protected: 0069 void keyPressEvent(QKeyEvent *ev) override; 0070 }; 0071 0072 class AttendeeLine : public KPIM::MultiplyingLine 0073 { 0074 Q_OBJECT 0075 public: 0076 enum AttendeeActions { EventActions, TodoActions }; 0077 0078 explicit AttendeeLine(QWidget *parent); 0079 ~AttendeeLine() override = default; 0080 0081 void activate() override; 0082 bool isActive() const override; 0083 0084 bool isEmpty() const override; 0085 void clear() override; 0086 0087 bool isModified() const override; 0088 void clearModified() override; 0089 0090 KPIM::MultiplyingLineData::Ptr data() const override; 0091 void setData(const KPIM::MultiplyingLineData::Ptr &data) override; 0092 0093 void fixTabOrder(QWidget *previous) override; 0094 QWidget *tabOut() const override; 0095 0096 void setCompletionMode(KCompletion::CompletionMode) override; 0097 0098 int setColumnWidth(int w) override; 0099 0100 void aboutToBeDeleted() override; 0101 bool canDeleteLineEdit() const override; 0102 0103 void setActions(AttendeeActions actions); 0104 0105 Q_SIGNALS: 0106 void changed(); 0107 void changed(const KCalendarCore::Attendee &oldAttendee, const KCalendarCore::Attendee &newAttendee); 0108 void editingFinished(KPIM::MultiplyingLine *); 0109 0110 private: 0111 void slotTextChanged(const QString &); 0112 void slotHandleChange(); 0113 void slotComboChanged(); 0114 void dataFromFields(); 0115 void fieldsFromData(); 0116 0117 AttendeeComboBox *mRoleCombo = nullptr; 0118 AttendeeComboBox *mStateCombo = nullptr; 0119 AttendeeComboBox *mResponseCombo = nullptr; 0120 AttendeeLineEdit *mEdit = nullptr; 0121 QSharedPointer<AttendeeData> mData; 0122 QString mUid; 0123 bool mModified; 0124 }; 0125 }