File indexing completed on 2024-04-21 04:41:01

0001 /* This file is part of the KDE project
0002    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
0003    Copyright (C) 2004  Alexander Dymo <cloudtemple@mskat.net>
0004    Copyright (C) 2008-2016 Jarosław Staniek <staniek@kde.org>
0005 
0006    This library is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU Library General Public
0008    License as published by the Free Software Foundation; either
0009    version 2 of the License, or (at your option) any later version.
0010 
0011    This library is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014    Library General Public License for more details.
0015 
0016    You should have received a copy of the GNU Library General Public License
0017    along with this library; see the file COPYING.LIB.  If not, write to
0018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019  * Boston, MA 02110-1301, USA.
0020 */
0021 
0022 #ifndef KPROPERTY_STRINGEDIT_H
0023 #define KPROPERTY_STRINGEDIT_H
0024 
0025 #include "KPropertyWidgetsFactory.h"
0026 
0027 #include <QLineEdit>
0028 
0029 class KPROPERTYWIDGETS_EXPORT KPropertyStringEditor : public QLineEdit
0030 {
0031     Q_OBJECT
0032     Q_PROPERTY(QString value READ value WRITE setValue USER true)
0033 public:
0034     explicit KPropertyStringEditor(QWidget *parent = nullptr);
0035 
0036     ~KPropertyStringEditor() override;
0037 
0038     QString value() const;
0039 
0040 Q_SIGNALS:
0041     void commitData( QWidget * editor );
0042 
0043 public Q_SLOTS:
0044     void setValue(const QString& value);
0045 
0046 private Q_SLOTS:
0047     void slotTextChanged( const QString & text );
0048 
0049 private:
0050     Q_DISABLE_COPY(KPropertyStringEditor)
0051     class Private;
0052     Private * const d;
0053 };
0054 
0055 class KPROPERTYWIDGETS_EXPORT KPropertyStringDelegate : public KPropertyEditorCreatorInterface,
0056                                                         public KPropertyValuePainterInterface,
0057                                                         public KPropertyValueDisplayInterface
0058 {
0059 public:
0060     KPropertyStringDelegate();
0061 
0062     QWidget *createEditor(int type, QWidget *parent, const QStyleOptionViewItem &option,
0063                           const QModelIndex &index) const override;
0064 
0065     void paint(QPainter *painter,
0066                const QStyleOptionViewItem &option, const QModelIndex &index) const override;
0067 
0068     QString valueToString(const QVariant& value, const QLocale &locale) const override;
0069 };
0070 
0071 #endif