File indexing completed on 2024-04-28 12:29:12
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) 2012 Friedrich W. H. Kossebau <kossebau@kde.org> 0005 Copyright (C) 2015 Jarosław Staniek <staniek@kde.org> 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 KPROPERTY_DATEEDIT_H 0024 #define KPROPERTY_DATEEDIT_H 0025 0026 #include "KPropertyWidgetsFactory.h" 0027 #include <QDateEdit> 0028 0029 class KPROPERTYWIDGETS_EXPORT KPropertyDateEditor : public QDateEdit 0030 { 0031 Q_OBJECT 0032 Q_PROPERTY(QVariant value READ value WRITE setValue USER true) 0033 0034 public: 0035 KPropertyDateEditor(const KProperty* prop, QWidget* parent); 0036 ~KPropertyDateEditor() override; 0037 0038 QVariant value() const; 0039 0040 Q_SIGNALS: 0041 void commitData(QWidget* editor); 0042 0043 public Q_SLOTS: 0044 void setValue(const QVariant& value); 0045 0046 protected: 0047 void paintEvent(QPaintEvent *event) override; 0048 0049 protected Q_SLOTS: 0050 void onDateChanged(); 0051 0052 private: 0053 Q_DISABLE_COPY(KPropertyDateEditor) 0054 class Private; 0055 Private * const d; 0056 }; 0057 0058 class KPROPERTYWIDGETS_EXPORT KPropertyDateDelegate : public KPropertyEditorCreatorInterface, 0059 public KPropertyValueDisplayInterface 0060 { 0061 public: 0062 KPropertyDateDelegate(); 0063 0064 QString valueToString(const QVariant &value, const QLocale &locale) const override; 0065 0066 QWidget *createEditor(int type, QWidget *parent, const QStyleOptionViewItem &option, 0067 const QModelIndex &index) const override; 0068 }; 0069 0070 #endif