File indexing completed on 2023-10-01 08:24:26
0001 /* 0002 SPDX-FileCopyrightText: 2008 Sebastian Trueg <trueg@kde.org> 0003 SPDX-FileCopyrightText: 2009 Peter Penz <peter.penz@gmx.at> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KCOMMENT_WIDGET 0009 #define KCOMMENT_WIDGET 0010 0011 #include <QString> 0012 #include <QWidget> 0013 0014 class QLabel; 0015 0016 /** 0017 * @brief Allows to edit and show a comment as part of KMetaDataWidget. 0018 */ 0019 class KCommentWidget : public QWidget 0020 { 0021 Q_OBJECT 0022 0023 public: 0024 explicit KCommentWidget(QWidget *parent = nullptr); 0025 ~KCommentWidget() override; 0026 0027 void setText(const QString &comment); 0028 QString text() const; 0029 0030 /** 0031 * If set to true, the comment cannot be changed by the user. 0032 * Per default read-only is disabled. 0033 */ 0034 // TODO: provide common interface class for metadatawidgets 0035 void setReadOnly(bool readOnly); 0036 bool isReadOnly() const; 0037 0038 QSize sizeHint() const override; 0039 0040 Q_SIGNALS: 0041 void commentChanged(const QString &comment); 0042 0043 protected: 0044 bool event(QEvent *event) override; 0045 0046 private Q_SLOTS: 0047 void slotLinkActivated(const QString &link); 0048 0049 private: 0050 bool m_readOnly = false; 0051 QLabel *const m_label; 0052 QLabel *const m_sizeHintHelper; // see comment in KCommentWidget::sizeHint() 0053 QString m_comment; 0054 }; 0055 0056 #endif