Akonadi Contacts

imagewidget.h
1 /*
2  This file is part of Contact Editor.
3 
4  SPDX-FileCopyrightText: 2009 Tobias Koenig <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #ifndef IMAGEWIDGET_H
10 #define IMAGEWIDGET_H
11 
12 #include <kcontacts/picture.h>
13 
14 #include <QPoint>
15 #include <QPushButton>
16 
17 namespace KContacts {
18 class Addressee;
19 }
20 
21 class ImageLoader;
22 
23 class ImageWidget : public QPushButton
24 {
25  Q_OBJECT
26 
27 public:
28  enum Type {
29  Photo,
30  Logo
31  };
32 
33  explicit ImageWidget(Type type, QWidget *parent = nullptr);
34  ~ImageWidget() override;
35 
36  void loadContact(const KContacts::Addressee &contact);
37  void storeContact(KContacts::Addressee &contact) const;
38 
39  void setReadOnly(bool readOnly);
40 
41 protected:
42  // image drop handling
43  void dragEnterEvent(QDragEnterEvent *event) override;
44  void dropEvent(QDropEvent *event) override;
45 
46  // image drag handling
47  void mousePressEvent(QMouseEvent *event) override;
48  void mouseMoveEvent(QMouseEvent *event) override;
49 
50  // context menu handling
51  void contextMenuEvent(QContextMenuEvent *event) override;
52 
53 private:
54  void updateView();
55 
56  void changeImage();
57  void changeUrl();
58  void saveImage();
59  void deleteImage();
60  ImageLoader *imageLoader();
61 
62  KContacts::Picture mPicture;
63  QPoint mDragStartPos;
64  ImageLoader *mImageLoader = nullptr;
65  Type mType;
66  bool mHasImage;
67  bool mReadOnly;
68 };
69 
70 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Sep 25 2020 23:09:17 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.