60 #include <QCoreApplication>
66 #include <QStaticStringData>
67 #include <QStringData>
68 #include <QStringDataPtr>
71 #include "../ifc/ifcdef.h"
72 #include "../vproperty_p.h"
87 if (m_lineTypes.empty())
94 if (tmpIndex < 0 || tmpIndex >= m_indexList.count())
99 if (column == DPC_Data && Qt::DisplayRole == role)
101 return m_indexList.at(tmpIndex);
103 else if (column == DPC_Data && Qt::EditRole == role)
114 const QAbstractItemDelegate *delegate)
118 QComboBox *lineTypeEditor =
new QComboBox(parent);
120 #if defined(Q_OS_MAC)
122 lineTypeEditor->setIconSize(QSize(m_iconWidth-= 2 ,m_iconHeight-= 2));
125 lineTypeEditor->setIconSize(QSize(m_iconWidth, m_iconHeight));
127 lineTypeEditor->clear();
128 lineTypeEditor->setMinimumWidth(140);
129 lineTypeEditor->setLocale(parent->locale());
132 while (i != m_lineTypes.constEnd())
134 const QString lineType = QVariant(i.key()).toString();
135 lineTypeEditor->addItem(createIcon(lineType), i.value(), QVariant(i.key()));
139 connect(lineTypeEditor,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
this,
148 const QComboBox *lineTypeEditor = qobject_cast<const QComboBox*>(editor);
151 return lineTypeEditor->currentIndex();
159 this->m_lineTypes = lineTypes;
162 while (i != lineTypes.constEnd())
164 m_indexList.append(i.key());
177 int tmpIndex = value.toInt();
179 if (tmpIndex < 0 || tmpIndex >= m_indexList.count())
195 return QStringLiteral(
"lineType");
207 while (i != lineTypes.constEnd())
209 m_indexList.append(i.key());
212 return m_indexList.indexOf(lineType);
225 QPixmap pixmap(m_iconWidth, m_iconHeight);
226 pixmap.fill(Qt::black);
228 QBrush brush(Qt::black);
229 QPen pen(brush, 2.5, style);
231 QPainter painter(&pixmap);
232 painter.fillRect(QRect(1, 1, m_iconWidth-2, m_iconHeight-2), QColor(Qt::white));
233 if (style != Qt::NoPen)
236 painter.drawLine(0, m_iconHeight/2, m_iconWidth, m_iconHeight/2);
239 return QIcon(pixmap);
static int indexOfLineType(const QMap< QString, QString > &styles, const QString &style)
virtual QMap< QString, QString > getLineTypes() const
Get the settings. This function has to be implemented in a subclass in order to have an effect.
virtual void setValue(const QVariant &value) Q_DECL_OVERRIDE
Sets the value of the property.
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const Q_DECL_OVERRIDE
Clones this property.
void currentIndexChanged(int index)
QIcon createIcon(const QString &type)
virtual QString type() const Q_DECL_OVERRIDE
Returns a string containing the type of the property.
virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE
Gets the data from the widget.
virtual QVariant data(int column=DPC_Name, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE
Get the data how it should be displayed.
LineTypeProperty(const QString &name)
Constructor.
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &options, const QAbstractItemDelegate *delegate) Q_DECL_OVERRIDE
Returns an editor widget, or NULL if it doesn't supply one.
virtual void setLineTypes(const QMap< QString, QString > &styles)
Sets the line styles.
QVariant VariantValue
The property's value. This does not have to be used by subclasses, but it makes sense in cases where ...
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const
Clones this property.
VPropertyPrivate * d_ptr
The protected structure holding the member variables (to assure binary compatibility)
virtual QVariant data(int column=DPC_Name, int role=Qt::DisplayRole) const
Get the data how it should be displayed.
Qt::PenStyle lineTypeToPenStyle(const QString &lineType)
LineStyle return pen style for current line style.