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

0001 /***************************************************************************
0002  *   Copyright (C) 2002 Lucijan Busch <lucijan@gmx.at>                     *
0003  *   Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>            *
0004  *   Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl>                     *
0005  *   Copyright (C) 2006 David Saxton <david@bluehaze.org>                  *
0006  *                                                                         *
0007  *   This program is free software; you can redistribute it and/or modify  *
0008  *   it under the terms of the GNU General Public License as published by  *
0009  *   the Free Software Foundation; either version 2 of the License, or     *
0010  *   (at your option) any later version.                                   *
0011  ***************************************************************************/
0012 
0013 #ifndef PROPERTYEDITORITEM_H
0014 #define PROPERTYEDITORITEM_H
0015 
0016 //#include <q3listview.h>
0017 // #include <q3asciidict.h>
0018 // #include <q3ptrlist.h>
0019 // #include <q3dict.h>
0020 
0021 #include "property.h"
0022 
0023 // #include <q3listview.h>
0024 #include <QTableWidget>
0025 
0026 #define PropertyEditorItem_BranchBoxSize 9
0027 
0028 /** This class is a subclass of K3ListViewItem which is associated to a property.
0029     It also takes care of drawing custom contents.
0030  **/
0031 //! An item in PropertyEditorItem associated to a property
0032 class PropertyEditorItem : public QObject, public QTableWidgetItem // K3ListViewItem
0033 {
0034     Q_OBJECT
0035 
0036 public:
0037     // typedef Q3AsciiDict<PropertyEditorItem> Dict; // 2018.08.13 - unused
0038 
0039     /**
0040      * Creates a PropertyEditorItem child of \a parent, associated to
0041      * \a property. Within property editor, items are created in
0042      * PropertyEditor::fill(), every time the buffer is updated. It
0043      * \a property has not desctiption set, its name (i.e. not i18n'ed) is
0044      * reused.
0045      */
0046     PropertyEditorItem(PropertyEditorItem *parent, Property *property);
0047 
0048     /**
0049      * Creates PropertyEditor Top Item which is necessary for drawing all
0050      * branches.
0051      */
0052     PropertyEditorItem(/*K3ListView */ QTableWidget *parent, const QString &text);
0053 
0054     ~PropertyEditorItem() override;
0055 
0056     /**
0057      * \return property's name.
0058      */
0059     QString name() const
0060     {
0061         return m_property->id();
0062     }
0063     /**
0064      * \return properties's type.
0065      */
0066     Variant::Type::Value type()
0067     {
0068         return m_property->type();
0069     }
0070     /**
0071      * \return a pointer to the property associated to this item.
0072      */
0073     Property *property()
0074     {
0075         return m_property;
0076     }
0077     /**
0078      * Updates text on of this item, for current property value. If
0079      * \a alsoParent is true, parent item (if present) is also updated.
0080      */
0081     virtual void updateValue(bool alsoParent = true);
0082 
0083     //      virtual void paintFocus ( QPainter * p, const QColorGroup & cg, const QRect & r );
0084 
0085 protected slots:
0086     virtual void propertyValueChanged();
0087 
0088 protected:
0089     /**
0090      * Reimplemented from K3ListViewItem to draw custom contents. Properties
0091      * names are wriiten in bold if modified. Also takes care of drawing
0092      * borders around the cells as well as pixmaps or colors if necessary.
0093      */
0094     //      virtual void paintCell(QPainter *p, const QColorGroup & cg, int column, int width, int align);
0095     /**
0096      * Reimplemented from K3ListViewItem to hide the top item.
0097      */
0098     //      virtual void setup();
0099 
0100 private:
0101     Property *m_property;
0102 };
0103 
0104 #endif