File indexing completed on 2025-01-19 12:45:15
0001 /***************************************************************************** 0002 * Copyright (C) 2008 by Sebastian Trueg <trueg@kde.org> * 0003 * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> * 0004 * * 0005 * This library is free software; you can redistribute it and/or * 0006 * modify it under the terms of the GNU Library General Public * 0007 * License as published by the Free Software Foundation; either * 0008 * version 2 of the License, or (at your option) any later version. * 0009 * * 0010 * This library is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 0013 * Library General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU Library General Public License * 0016 * along with this library; see the file COPYING.LIB. If not, write to * 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * 0018 * Boston, MA 02110-1301, USA. * 0019 *****************************************************************************/ 0020 0021 #ifndef KCOMMENT_WIDGET 0022 #define KCOMMENT_WIDGET 0023 0024 #include <QString> 0025 #include <QWidget> 0026 0027 class QLabel; 0028 0029 /** 0030 * @brief Allows to edit and show a comment as part of KMetaDataWidget. 0031 */ 0032 class KCommentWidget : public QWidget 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 KDELIBS4SUPPORT_DEPRECATED explicit KCommentWidget(QWidget *parent = nullptr); 0038 ~KCommentWidget() override; 0039 0040 void setText(const QString &comment); 0041 QString text() const; 0042 0043 /** 0044 * If set to true, the comment cannot be changed by the user. 0045 * Per default read-only is disabled. 0046 */ 0047 // TODO: provide common interface class for metadatawidgets 0048 void setReadOnly(bool readOnly); 0049 bool isReadOnly() const; 0050 0051 QSize sizeHint() const override; 0052 0053 Q_SIGNALS: 0054 void commentChanged(const QString &comment); 0055 0056 protected: 0057 bool event(QEvent *event) override; 0058 0059 private Q_SLOTS: 0060 void slotLinkActivated(const QString &link); 0061 0062 private: 0063 bool m_readOnly; 0064 QLabel *m_label; 0065 QLabel *m_sizeHintHelper; // see comment in KCommentWidget::sizeHint() 0066 QString m_comment; 0067 }; 0068 0069 #endif