File indexing completed on 2024-11-17 04:40:41
0001 /* 0002 This file is part of Akonadi Contact. 0003 0004 SPDX-FileCopyrightText: 2009 Tobias Koenig <tokoe@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #pragma once 0010 0011 #include <QLineEdit> 0012 0013 #include <QStyledItemDelegate> 0014 0015 #include "contactcompletionmodel_p.h" 0016 #include <Akonadi/Item> 0017 0018 #include <memory> 0019 0020 namespace Akonadi 0021 { 0022 class ContactLineEdit : public QLineEdit 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 explicit ContactLineEdit(bool isReference, Akonadi::ContactCompletionModel::Columns column, QWidget *parent = nullptr); 0028 0029 bool isReference() const; 0030 Akonadi::Item completedItem() const; 0031 0032 Q_SIGNALS: 0033 void completed(QWidget *widget); 0034 0035 private: 0036 void completed(const QModelIndex &index); 0037 void slotTextEdited(); 0038 bool mIsReference; 0039 Akonadi::Item mItem; 0040 }; 0041 0042 class ContactGroupEditorDelegatePrivate; 0043 0044 class ContactGroupEditorDelegate : public QStyledItemDelegate 0045 { 0046 Q_OBJECT 0047 0048 public: 0049 explicit ContactGroupEditorDelegate(QAbstractItemView *view, QObject *parent = nullptr); 0050 ~ContactGroupEditorDelegate() override; 0051 0052 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0053 0054 void setEditorData(QWidget *editor, const QModelIndex &index) const override; 0055 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override; 0056 0057 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0058 0059 QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0060 0061 bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override; 0062 0063 private: 0064 void completed(QWidget *widget); 0065 void setFirstColumnAsCurrent(); 0066 0067 private: 0068 std::unique_ptr<ContactGroupEditorDelegatePrivate> const d; 0069 }; 0070 }