leocad/qt/lc_qpropertiestree.h

208 lines
5.7 KiB
C
Raw Normal View History

#pragma once
2013-08-09 06:57:18 +02:00
#include "lc_array.h"
2013-08-09 06:57:18 +02:00
struct lcPartProperties;
class lcQPropertiesTreeDelegate;
enum lcPropertyWidgetMode
{
LC_PROPERTY_WIDGET_EMPTY,
LC_PROPERTY_WIDGET_PIECE,
LC_PROPERTY_WIDGET_CAMERA,
LC_PROPERTY_WIDGET_LIGHT,
LC_PROPERTY_WIDGET_MULTIPLE
};
2013-08-09 06:57:18 +02:00
class lcQPropertiesTree : public QTreeWidget
{
Q_OBJECT
public:
lcQPropertiesTree(QWidget *parent = 0);
QSize sizeHint() const override;
2013-08-09 06:57:18 +02:00
QTreeWidgetItem *indexToItem(const QModelIndex &index) const
{
return itemFromIndex(index);
}
void Update(const lcArray<lcObject*>& Selection, lcObject* Focus);
2013-08-09 06:57:18 +02:00
QWidget *createEditor(QWidget *parent, QTreeWidgetItem *item) const;
bool lastColumn(int column) const;
enum
{
PropertyTypeRole = Qt::UserRole,
PropertyValueRole
};
enum PropertyType
{
PropertyGroup,
2014-05-03 03:22:24 +02:00
PropertyBool,
2013-08-09 06:57:18 +02:00
PropertyFloat,
2023-08-04 22:26:29 +02:00
PropertyFloatReadOnly,
PropertyFloatLightSpotSize,
2023-08-07 13:08:13 +02:00
PropertyFloatLightSpotFalloff,
PropertyStep,
2013-08-09 06:57:18 +02:00
PropertyString,
2023-09-02 05:46:29 +02:00
PropertyStringList,
2023-08-07 13:08:13 +02:00
PropertyLightFormat,
2023-08-04 22:26:29 +02:00
PropertyLightShape,
PropertyLightColor,
2013-08-09 06:57:18 +02:00
PropertyColor,
PropertyPart
};
protected slots:
2014-05-03 03:22:24 +02:00
void slotToggled(bool value);
2013-08-09 06:57:18 +02:00
void slotReturnPressed();
void slotSetValue(int value);
void slotColorButtonClicked();
2023-08-27 20:17:07 +02:00
void LightColorButtonClicked();
2013-08-09 06:57:18 +02:00
protected:
void keyPressEvent(QKeyEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
2013-08-09 06:57:18 +02:00
void updateColorEditor(QPushButton *editor, int value) const;
2023-08-27 20:17:07 +02:00
void UpdateLightColorEditor(QPushButton* Editor, QColor Color) const;
2013-08-09 06:57:18 +02:00
QTreeWidgetItem *addProperty(QTreeWidgetItem *parent, const QString& label, PropertyType propertyType);
void SetEmpty();
void SetPiece(const lcArray<lcObject*>& Selection, lcObject* Focus);
void SetCamera(lcObject* Focus);
void SetLight(lcObject* Focus);
void SetMultiple();
2013-08-09 06:57:18 +02:00
2023-08-13 15:15:52 +02:00
lcLightType mLightType;
2023-08-04 22:26:29 +02:00
int mLightShape;
2023-08-07 13:08:13 +02:00
bool mPOVRayLight;
2023-08-04 22:26:29 +02:00
lcPropertyWidgetMode mWidgetMode;
lcObject* mFocus;
2013-08-09 06:57:18 +02:00
2023-08-27 20:17:07 +02:00
lcQPropertiesTreeDelegate* mDelegate;
2013-08-09 06:57:18 +02:00
QIcon m_expandIcon;
QIcon m_checkedIcon;
QIcon m_uncheckedIcon;
QTreeWidgetItem *partPosition;
QTreeWidgetItem *partPositionX;
QTreeWidgetItem *partPositionY;
QTreeWidgetItem *partPositionZ;
QTreeWidgetItem *partRotation;
QTreeWidgetItem *partRotationX;
QTreeWidgetItem *partRotationY;
QTreeWidgetItem *partRotationZ;
QTreeWidgetItem *partVisibility;
QTreeWidgetItem *partShow;
QTreeWidgetItem *partHide;
QTreeWidgetItem *partAppearance;
QTreeWidgetItem *partColor;
QTreeWidgetItem *partID;
QTreeWidgetItem *cameraPosition;
QTreeWidgetItem *cameraPositionX;
QTreeWidgetItem *cameraPositionY;
QTreeWidgetItem *cameraPositionZ;
QTreeWidgetItem *cameraTarget;
QTreeWidgetItem *cameraTargetX;
QTreeWidgetItem *cameraTargetY;
QTreeWidgetItem *cameraTargetZ;
QTreeWidgetItem *cameraUp;
QTreeWidgetItem *cameraUpX;
QTreeWidgetItem *cameraUpY;
QTreeWidgetItem *cameraUpZ;
QTreeWidgetItem *cameraSettings;
2014-05-03 03:22:24 +02:00
QTreeWidgetItem *cameraOrtho;
2013-08-09 06:57:18 +02:00
QTreeWidgetItem *cameraFOV;
QTreeWidgetItem *cameraNear;
QTreeWidgetItem *cameraFar;
QTreeWidgetItem *cameraName;
2023-08-04 22:26:29 +02:00
2023-08-07 13:08:13 +02:00
QTreeWidgetItem *lightConfiguration;
2023-08-04 22:26:29 +02:00
QTreeWidgetItem *lightPosition;
QTreeWidgetItem *lightPositionX;
QTreeWidgetItem *lightPositionY;
QTreeWidgetItem *lightPositionZ;
QTreeWidgetItem *lightTarget;
QTreeWidgetItem *lightTargetX;
QTreeWidgetItem *lightTargetY;
QTreeWidgetItem *lightTargetZ;
QTreeWidgetItem *lightColor;
QTreeWidgetItem *lightColorIcon;
QTreeWidgetItem *lightColorR;
QTreeWidgetItem *lightColorG;
QTreeWidgetItem *lightColorB;
QTreeWidgetItem *lightProperties;
2023-08-07 13:08:13 +02:00
QTreeWidgetItem *lightDiffuse;
2023-08-04 22:26:29 +02:00
QTreeWidgetItem *lightSpecular;
QTreeWidgetItem *lightCutoff;
QTreeWidgetItem *lightEnableCutoff;
QTreeWidgetItem *lightExponent;
2023-09-02 05:46:29 +02:00
QTreeWidgetItem *mLightTypeItem;
2023-08-04 22:26:29 +02:00
QTreeWidgetItem *lightSpotSize;
QTreeWidgetItem *lightShape;
QTreeWidgetItem *lightFactorA;
QTreeWidgetItem *lightFactorB;
QTreeWidgetItem *lightName;
2023-08-07 13:08:13 +02:00
QTreeWidgetItem *lightFormat;
QTreeWidgetItem *lightShadowless;
QTreeWidgetItem *lightAreaGridRows;
QTreeWidgetItem *lightAreaGridColumns;
QTreeWidgetItem *lightSpotFalloff;
QTreeWidgetItem *lightSpotTightness;
2013-08-09 06:57:18 +02:00
};
2016-05-08 04:16:52 +02:00
class lcQPropertiesTreeDelegate : public QItemDelegate
{
Q_OBJECT
public:
lcQPropertiesTreeDelegate(QObject *parent = 0)
: QItemDelegate(parent), m_treeWidget(0), m_editedItem(0), m_editedWidget(0), m_disablePainting(false)
{}
void setTreeWidget(lcQPropertiesTree *treeWidget)
{
m_treeWidget = treeWidget;
}
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
void setModelData(QWidget *, QAbstractItemModel *, const QModelIndex &) const override {}
void setEditorData(QWidget *, const QModelIndex &) const override {}
bool eventFilter(QObject *object, QEvent *event) override;
2016-05-08 04:16:52 +02:00
QTreeWidgetItem *editedItem() const
{
return m_editedItem;
}
QWidget *editor() const
{
return m_editedWidget;
}
protected:
void drawDecoration(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QPixmap &pixmap) const override;
void drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const override;
2016-05-08 04:16:52 +02:00
private slots:
void slotEditorDestroyed(QObject *object);
private:
int indentation(const QModelIndex &index) const;
lcQPropertiesTree *m_treeWidget;
mutable QTreeWidgetItem *m_editedItem;
mutable QWidget *m_editedWidget;
mutable bool m_disablePainting;
};