File indexing completed on 2024-05-19 12:26:21
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) 2016-2018 Jarosław Staniek <staniek@kde.org> 0005 Copyright (C) 2018 Dmitry Baryshev <dmitrymq@gmail.com> 0006 0007 This library is free software; you can redistribute it and/or 0008 modify it under the terms of the GNU Library General Public 0009 License as published by the Free Software Foundation; either 0010 version 2 of the License, or (at your option) any later version. 0011 0012 This library is distributed in the hope that it will be useful, 0013 but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 Library General Public License for more details. 0016 0017 You should have received a copy of the GNU Library General Public License 0018 along with this library; see the file COPYING.LIB. If not, write to 0019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0020 * Boston, MA 02110-1301, USA. 0021 */ 0022 0023 #ifndef KPROPERTYURLEDITOR_H 0024 #define KPROPERTYURLEDITOR_H 0025 0026 #include "KPropertyComposedUrl.h" 0027 #include "KPropertyWidgetsFactory.h" 0028 #include "KPropertyGenericSelectionEditor.h" 0029 0030 #include <QUrl> 0031 0032 class KPropertyUrlEditorPrivate; 0033 0034 //! Editor for Url type 0035 class KPROPERTYWIDGETS_EXPORT KPropertyUrlEditor : public KPropertyGenericSelectionEditor 0036 { 0037 Q_PROPERTY(QUrl value READ value WRITE setValue USER true) 0038 Q_OBJECT 0039 0040 public: 0041 explicit KPropertyUrlEditor(const KProperty &property, QWidget *parent = nullptr); 0042 0043 ~KPropertyUrlEditor() override; 0044 0045 virtual QUrl value() const; 0046 0047 Q_SIGNALS: 0048 void commitData(QWidget * editor); 0049 0050 public Q_SLOTS: 0051 virtual void setValue(const QUrl &value); 0052 0053 protected Q_SLOTS: 0054 void selectButtonClicked() override; 0055 0056 protected: 0057 bool eventFilter(QObject *o, QEvent *event) override; 0058 0059 private: 0060 Q_DISABLE_COPY(KPropertyUrlEditor) 0061 QScopedPointer<KPropertyUrlEditorPrivate> const d; 0062 }; 0063 0064 //! Delegate for Url and ComposedUrl types 0065 class KPROPERTYWIDGETS_EXPORT KPropertyUrlDelegate : public KPropertyEditorCreatorInterface, 0066 public KPropertyValueDisplayInterface 0067 { 0068 public: 0069 KPropertyUrlDelegate(); 0070 0071 QWidget *createEditor(int type, QWidget *parent, const QStyleOptionViewItem &option, 0072 const QModelIndex &index) const override; 0073 0074 QString valueToString(const QVariant &value, const QLocale &locale) const override; 0075 }; 0076 0077 #endif