File indexing completed on 2024-05-19 05:21:25
0001 /* 0002 This file is part of the KDE Kontact Plugin Interface Library. 0003 0004 SPDX-FileCopyrightText: 2003 Cornelius Schumacher <schumacher@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 #pragma once 0009 0010 #include "kontactinterface_export.h" 0011 0012 #include <QWidget> 0013 0014 class QMouseEvent; 0015 class QDragEnterEvent; 0016 class QDropEvent; 0017 0018 namespace KontactInterface 0019 { 0020 /** 0021 * @short Base class for summary widgets in Kontact. 0022 * 0023 * This class should be used as base class when creating new 0024 * summary widgets for the Summary View plugin in Kontact. 0025 */ 0026 class KONTACTINTERFACE_EXPORT Summary : public QWidget 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 /** 0032 * Creates a new summary widget. 0033 * 0034 * @param parent The parent widget. 0035 */ 0036 explicit Summary(QWidget *parent); 0037 0038 /** 0039 * Destroys the summary widget. 0040 */ 0041 ~Summary() override; 0042 0043 /** 0044 * Returns the logical height of summary widget. 0045 * 0046 * This is used to calculate how much vertical space relative 0047 * to other summary widgets this widget will use in the summary view. 0048 */ 0049 [[nodiscard]] virtual int summaryHeight() const; 0050 0051 /** 0052 * Creates a heading for a typical summary view with an icon and a heading. 0053 * 0054 * @param parent The parent widget. 0055 * @param icon The name of the icon. 0056 * @param heading The text of the header. 0057 */ 0058 [[nodiscard]] QWidget *createHeader(QWidget *parent, const QString &icon, const QString &heading); 0059 0060 /** 0061 * Returns a list of names identifying configuration modules for this summary widget. 0062 * 0063 * @note The names have to be suitable for being passed to KCMultiDialog::addModule(). 0064 */ 0065 [[nodiscard]] virtual QStringList configModules() const; 0066 0067 public Q_SLOTS: 0068 /** 0069 * This method is called whenever the configuration has been changed. 0070 */ 0071 virtual void configChanged(); 0072 0073 /** 0074 * This method is called if the displayed information should be updated. 0075 * 0076 * @param force true if the update was requested by the user 0077 */ 0078 virtual void updateSummary(bool force = false); 0079 0080 Q_SIGNALS: 0081 /** 0082 * This signal can be emitted to signaling that an action is going on. 0083 * The @p message will be shown in the status bar. 0084 */ 0085 void message(const QString &message); 0086 0087 /** 0088 * @internal 0089 * 0090 * This signal is emitted whenever a summary widget has been dropped on 0091 * this summary widget. 0092 */ 0093 void summaryWidgetDropped(QWidget *target, QObject *object, int alignment); 0094 0095 protected: 0096 void mousePressEvent(QMouseEvent *) override; 0097 void mouseMoveEvent(QMouseEvent *) override; 0098 void dragEnterEvent(QDragEnterEvent *) override; 0099 void dropEvent(QDropEvent *) override; 0100 0101 private: 0102 //@cond PRIVATE 0103 class SummaryPrivate; 0104 std::unique_ptr<SummaryPrivate> const d; 0105 //@endcond 0106 }; 0107 0108 }