File indexing completed on 2024-12-22 05:01:10
0001 /* -*- c++ -*- 0002 identitylistview.h 0003 0004 This file is part of KMail, the KDE mail client. 0005 SPDX-FileCopyrightText: 2002 Marc Mutz <mutz@kde.org> 0006 SPDX-FileCopyrightText: 2007 Mathias Soeken <msoeken@tzi.de> 0007 0008 SPDX-License-Identifier: GPL-2.0-only 0009 */ 0010 0011 #pragma once 0012 0013 #include <QTreeWidget> 0014 #include <QTreeWidgetItem> 0015 0016 namespace KIdentityManagementCore 0017 { 0018 class Identity; 0019 class IdentityManager; 0020 } 0021 0022 namespace KMail 0023 { 0024 class IdentityListView; 0025 0026 /** @short A QWidgetTreeItem for use in IdentityListView 0027 * @author Marc Mutz <mutz@kde.org> 0028 **/ 0029 class IdentityListViewItem : public QTreeWidgetItem 0030 { 0031 public: 0032 IdentityListViewItem(IdentityListView *parent, const KIdentityManagementCore::Identity &ident); 0033 IdentityListViewItem(IdentityListView *parent, QTreeWidgetItem *after, const KIdentityManagementCore::Identity &ident); 0034 0035 [[nodiscard]] uint uoid() const; 0036 0037 KIdentityManagementCore::Identity &identity() const; 0038 virtual void setIdentity(const KIdentityManagementCore::Identity &ident); 0039 void redisplay(); 0040 0041 private: 0042 void init(const KIdentityManagementCore::Identity &ident); 0043 uint mUOID = 0; 0044 }; 0045 0046 /** @short A QTreeWidget for KIdentityManagementCore::Identity 0047 * @author Marc Mutz <mutz@kde.org> 0048 **/ 0049 class IdentityListView : public QTreeWidget 0050 { 0051 Q_OBJECT 0052 public: 0053 explicit IdentityListView(QWidget *parent = nullptr); 0054 ~IdentityListView() override = default; 0055 0056 public: 0057 void editItem(QTreeWidgetItem *item, int column = 0); 0058 KIdentityManagementCore::IdentityManager *identityManager() const; 0059 void setIdentityManager(KIdentityManagementCore::IdentityManager *im); 0060 0061 protected Q_SLOTS: 0062 void commitData(QWidget *editor) override; 0063 0064 Q_SIGNALS: 0065 void contextMenu(KMail::IdentityListViewItem *, const QPoint &); 0066 void rename(KMail::IdentityListViewItem *, const QString &); 0067 0068 protected: 0069 #ifndef QT_NO_DRAGANDDROP 0070 void startDrag(Qt::DropActions supportedActions) override; 0071 #endif 0072 0073 private: 0074 void slotCustomContextMenuRequested(const QPoint &); 0075 KIdentityManagementCore::IdentityManager *mIdentityManager = nullptr; 0076 }; 0077 } // namespace KMail