[Core] Make PropertyItem column usage more clear
- Renamed dataProperty -> dataPropertyName because the function returns variants for the property name. - Add an enum for the column to remove magic numbers
This commit is contained in:
@@ -295,7 +295,7 @@ int PropertyItem::childCount() const
|
||||
|
||||
int PropertyItem::columnCount() const
|
||||
{
|
||||
return 2;
|
||||
return PropertyItem::ColumnCount;
|
||||
}
|
||||
|
||||
void PropertyItem::setReadOnly(bool ro)
|
||||
@@ -649,7 +649,7 @@ void PropertyItem::setPropertyValue(const QString& value)
|
||||
setPropertyValue(value.toStdString());
|
||||
}
|
||||
|
||||
QVariant PropertyItem::dataProperty(int role) const
|
||||
QVariant PropertyItem::dataPropertyName(int role) const
|
||||
{
|
||||
if (role == Qt::ForegroundRole && linked) {
|
||||
return QVariant::fromValue(QColor(0x20, 0xaa, 0x20)); // NOLINT
|
||||
@@ -742,9 +742,8 @@ QVariant PropertyItem::dataValue(int role) const
|
||||
|
||||
QVariant PropertyItem::data(int column, int role) const
|
||||
{
|
||||
// property name
|
||||
if (column == 0) {
|
||||
return dataProperty(role);
|
||||
if (column == PropertyItem::NameColumn) {
|
||||
return dataPropertyName(role);
|
||||
}
|
||||
|
||||
return dataValue(role);
|
||||
|
||||
@@ -130,6 +130,12 @@ class GuiExport PropertyItem: public QObject, public ExpressionBinding
|
||||
PROPERTYITEM_HEADER
|
||||
|
||||
public:
|
||||
enum Column {
|
||||
NameColumn = 0,
|
||||
ValueColumn = 1,
|
||||
ColumnCount
|
||||
};
|
||||
|
||||
~PropertyItem() override;
|
||||
|
||||
/** Sets the current property objects. */
|
||||
@@ -216,7 +222,7 @@ protected:
|
||||
void onChange() override;
|
||||
|
||||
private:
|
||||
QVariant dataProperty(int role) const;
|
||||
QVariant dataPropertyName(int role) const;
|
||||
QVariant dataValue(int role) const;
|
||||
QString toString(const Py::Object&) const;
|
||||
QString asNone(const Py::Object&) const;
|
||||
|
||||
Reference in New Issue
Block a user