20 #include <QHBoxLayout>
22 #include <QMessageBox>
23 #include <QToolButton>
30 , m_textLabel(new QLabel)
31 , m_pixmapLabel(new QLabel)
35 setMouseTracking(
true);
36 setAutoFillBackground(
true);
38 auto layout =
new QHBoxLayout;
39 layout->setContentsMargins(4, 0, 0, 0);
41 auto button =
new QToolButton;
42 button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred));
43 button->setText(QLatin1String(
" . . . "));
44 button->setToolTip(
"Open selector");
47 layout->addStretch(1);
48 layout->addWidget(button);
49 setFocusPolicy(Qt::StrongFocus);
50 setAttribute(Qt::WA_InputMethodEnabled);
72 throw std::runtime_error(
"Error. Wrong variant type (ExternalProperty is required).");
76 pixmap.fill(prop.color());
77 m_textLabel->setText(QString::fromStdString(prop.text()));
Base class for all custom variant editors.
void setCallback(std::function< void(const QVariant &)> callback)
ExternalPropertyEditor(QWidget *parent=nullptr)
void update_components() override
Should update widget components from m_data, if necessary.
std::function< void(const QVariant &)> m_callback
Property to carry text, color and identifier.
Event filter to prevent loss of the focus.
void warning(QWidget *parent, const QString &title, const QString &text, const QString &detailedText)
MVVM_VIEWMODEL_EXPORT int DefaultPixmapSize()
Returns int value corresponding to pixmap in standard Qt table/tree decorations.
MVVM_MODEL_EXPORT bool IsExtPropertyVariant(const Variant &variant)
Returns true in the case of ExternalProperty based variant.
materialitems.h Collection of materials to populate MaterialModel.