File indexing completed on 2024-11-24 04:39:28
0001 /* 0002 This file is part of Contact Editor. 0003 0004 SPDX-FileCopyrightText: 2016 eyeOS S.L.U., a Telefonica company, sales@eyeos.com 0005 SPDX-FileCopyrightText: 2016-2020 Laurent Montel <montel.org> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #pragma once 0011 0012 #include <KContacts/Address> 0013 #include <QWidget> 0014 0015 class QStackedWidget; 0016 class QCheckBox; 0017 class KLineEdit; 0018 class QComboBox; 0019 class QPushButton; 0020 0021 namespace Akonadi 0022 { 0023 class SelectAddressTypeComboBox; 0024 0025 class AddressLocationWidget : public QWidget 0026 { 0027 Q_OBJECT 0028 public: 0029 enum Mode { CreateAddress = 0, ModifyAddress }; 0030 0031 explicit AddressLocationWidget(QWidget *parent = nullptr); 0032 ~AddressLocationWidget() override; 0033 0034 void setAddress(const KContacts::Address &address); 0035 [[nodiscard]] KContacts::Address address() const; 0036 0037 void slotModifyAddress(const KContacts::Address &address, int currentIndex); 0038 0039 void clear(); 0040 0041 void setReadOnly(bool readOnly); 0042 0043 [[nodiscard]] bool wasChanged() const; 0044 Q_SIGNALS: 0045 void addNewAddress(const KContacts::Address &address); 0046 void updateAddress(const KContacts::Address &address, int index); 0047 void updateAddressCanceled(); 0048 void removeAddress(int index); 0049 0050 private: 0051 void slotChanged(); 0052 void slotAddAddress(); 0053 void slotUpdateAddress(); 0054 void slotRemoveAddress(); 0055 void slotCancelModifyAddress(); 0056 void fillCountryCombo(); 0057 void switchMode(); 0058 void reset(); 0059 KContacts::Address mAddress; 0060 QCheckBox *mPreferredCheckBox = nullptr; 0061 KLineEdit *mPOBoxEdit = nullptr; 0062 KLineEdit *mLocalityEdit = nullptr; 0063 KLineEdit *mRegionEdit = nullptr; 0064 KLineEdit *mPostalCodeEdit = nullptr; 0065 KLineEdit *mStreetEdit = nullptr; 0066 QComboBox *mCountryCombo = nullptr; 0067 QPushButton *mAddAddress = nullptr; 0068 QPushButton *mRemoveAddress = nullptr; 0069 QPushButton *mModifyAddress = nullptr; 0070 QPushButton *mCancelAddress = nullptr; 0071 QStackedWidget *mButtonStack = nullptr; 0072 SelectAddressTypeComboBox *mTypeCombo = nullptr; 0073 int mCurrentAddress = -1; 0074 Mode mCurrentMode; 0075 bool mWasChanged = false; 0076 }; 0077 0078 }