File indexing completed on 2024-04-28 05:43:25

0001 /***************************************************************************
0002  *   Copyright (C) 2002 Lucijan Busch <lucijan@gmx.at>                     *
0003  *   Copyright (C) 2006 David Saxton <david@bluehaze.org>                  *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  ***************************************************************************/
0010 
0011 #ifndef PROPERTYSUBEDITOR_H
0012 #define PROPERTYSUBEDITOR_H
0013 
0014 #include <QWidget>
0015 
0016 class Variant;
0017 typedef Variant Property;
0018 
0019 //! The base class for all editors used in PropertyEditor.
0020 
0021 class PropertySubEditor : public QWidget
0022 {
0023     Q_OBJECT
0024 
0025 public:
0026     PropertySubEditor(QWidget *parent, Property *property);
0027     ~PropertySubEditor() override;
0028 
0029     bool eventFilter(QObject *watched, QEvent *e) override;
0030     Property *property() const
0031     {
0032         return m_property;
0033     }
0034 
0035     /**
0036      * Sets \a w as editor 's widget, ie the widget which events are
0037      * filtered and which is resized. If \a focusProxy is not 0, it will be
0038      * used as focus proxy instead of \a w.
0039      */
0040     void setWidget(QWidget *w, QWidget *focusProxy = nullptr);
0041     /**
0042      * \sa m_leaveTheSpaceForRevertButton description.
0043      */
0044     bool leavesTheSpaceForRevertButton() const
0045     {
0046         return m_leaveTheSpaceForRevertButton;
0047     }
0048 
0049 protected:
0050     void resizeEvent(QResizeEvent *ev) override;
0051 
0052     Property *m_property;
0053     QWidget *m_childWidget;
0054     /**
0055      * true if there should be left space at the right hand for the Revert
0056      * Button. false by default. Integer editor (spinbox) sets this to true
0057      * to avoid spin arrows clicking inconvenience.
0058      */
0059     bool m_leaveTheSpaceForRevertButton;
0060 };
0061 
0062 #endif