4#pragma warning(disable : 4800)
5#pragma warning(disable : 4251)
6#pragma warning(disable : 4244)
7#pragma warning(disable : 4127)
9#include <QStyledItemDelegate>
10#include <QSignalMapper>
12#include <QApplication>
17#include "../global.hpp"
18#include "../genapi/node_map.hpp"
19#include "../genapi/genapi.hpp"
20#include "_detail/detail_property_model.hpp"
39explicit VariantDelegate(
QObject* parent = 0)
41 , finishedMapper_(nullptr)
53 auto prop =
static_cast<UI::Private::Property*
>(index.internalPointer());
58 case UI::Private::Property::PT_Boolean:
59 case UI::Private::Property::PT_Category:
60 case UI::Private::Property::PT_Command:
61 case UI::Private::Property::PT_Enumeration:
62 case UI::Private::Property::PT_Float:
63 case UI::Private::Property::PT_Integer:
64 case UI::Private::Property::PT_String:
65 editor = prop->CreateEditor(parent);
70 QObject::connect(editor, SIGNAL(editingFinished()), finishedMapper_, SLOT(map()));
71 finishedMapper_->setMapping(editor, editor);
93 auto data = index.model()->data(index, Qt::EditRole);
94 if (data.type() == QVariant::UserType)
96 data =
static_cast<UI::Private::Property*
>(index.internalPointer())->EditorData(editor);
99 model->
setData(index, data, Qt::EditRole);
116 auto prop =
static_cast<UI::Private::Property*
>(index.internalPointer());
117 if (prop->Type() == UI::Private::Property::PT_Category)
123 if (index.column() == 0)
124 painter->
drawLine(option.rect.topRight(), option.rect.bottomRight());
127 painter->
drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
171 , propertyModel_(nullptr)
172 , updateTimer_(nullptr)
178 propertyModel_ =
new UI::Private::PropertyModel();
186 delete propertyModel_;
195 auto prop = propertyModel_->Property(index);
198 if (!prop->IsReadOnly() && prop->Type() != UI::Private::Property::PT_Boolean)
204 updateTimer_ =
new QTimer(
this);
219 delete propertyModel_;
229 propertyModel_->SetNodeMap(nodemap);
246 return propertyModel_->NodeMap();
255 propertyModel_->RemoveNodeMap();
266 propertyModel_->SetMaxVisibility(visibility);
276 return propertyModel_->MaxVisibility();
287 return HtmlDescription(index);
299 return propertyModel_->Search(text);
308 propertyModel_->ResetSearch();
318 return propertyModel_->SearchText();
328 propertyModel_->SetSearchResultBGColor(color);
338 return propertyModel_->SearchResultBGColor();
349 return propertyModel_->Item(index)->Node();
359 for (
int i = 0; i < indexList.size(); i++)
360 ExpandProperty(indexList.at(i));
370 for (
int i = 0; i < indexList.size(); i++)
371 CollapseProperty(indexList.at(i));
381 propertyModel_->UpdateProperty(index);
390 propertyModel_->Update();
400 updateTimer_->
start(ms);
409 updateTimer_->
stop();
421 propertyModel_->ResetUpdateLock();
433 auto parentIndex = propertyModel_->parent(index);
436 ExpandProperty(parentIndex);
445 auto parentIndex = propertyModel_->parent(index);
448 CollapseProperty(parentIndex);
453 auto prop = propertyModel_->Item(index);
458 auto node = prop->Node();
461 if (!node->Description().empty())
464 txt.
append(
"<br><table>");
467 if (
typeid(node) !=
typeid(CategoryNodePtr))
469 txt.
append(
"<tr><td><b>Type:</b></td><td>" +
UI::CvbToQt(prop->NodeType()) +
"</td></tr>");
470 txt.
append(
"<tr><td><b>Access Mode:</b></td><td>" +
UI::CvbToQt(prop->NodeAccessMode()) +
"</td></tr>");
471 txt.
append(
"<tr><td><b>Visibility:</b></td><td>" +
UI::CvbToQt(prop->NodeVisibility()) +
"</td></tr>");
472 txt.
append(
"<tr><td><b>Caching Mode:</b></td><td>" +
UI::CvbToQt(prop->NodeCachingMode()) +
"</td></tr>");
473 if (prop->NodeIsStreamable())
474 txt.
append(
"<tr><td><b>Streamable:</b></td><td>True</td></tr>");
476 txt.
append(
"<tr><td><b>Streamable:</b></td><td>False</td></tr>");
480 switch (prop->Type())
484 case UI::Private::Property::PropertyType::PT_Integer:
485 case UI::Private::Property::PropertyType::PT_Float:
486 case UI::Private::Property::PropertyType::PT_String:
487 case UI::Private::Property::PropertyType::PT_Enumeration:
488 txt.
append(prop->HtmlDescription());
496 static const int maxColumnWidth_ = 180;
497 UI::Private::PropertyModel* propertyModel_;
View to display a device's nodemap.
Definition: property_grid.hpp:157
void StopAutoUpdate()
Stops the automatic update of the nodes.
Definition: property_grid.hpp:407
NodePtr Node(const QModelIndex &index)
The node of the given QModelIndex.
Definition: property_grid.hpp:347
void CollapseSearchResult(const QModelIndexList &indexList)
Collapses all nodes of given QModelIndexList as well as its parents.
Definition: property_grid.hpp:368
NodeMapPtr NodeMap()
Return the nodemap.
Definition: property_grid.hpp:244
GenApi::Visibility Visibility()
Returns the visibility of the nodemap.
Definition: property_grid.hpp:274
void ReleaseNodeMap()
Release the nodemap.
Definition: property_grid.hpp:253
void UpdateProperty(const QModelIndex &index)
Updates a given property / node.
Definition: property_grid.hpp:379
QString SearchText()
Returns the search text which is currently set.
Definition: property_grid.hpp:316
void SetVisibility(GenApi::Visibility visibility)
Set the visibility of the nodemap.
Definition: property_grid.hpp:264
QModelIndexList Search(const QString &text)
Search for displayed property name.
Definition: property_grid.hpp:297
QColor SearchResultBackgroundColor()
Returns the search result background color.
Definition: property_grid.hpp:336
void StartAutoUpdate(int ms)
Starts the automatic update of the nodes.
Definition: property_grid.hpp:398
void SetNodeMap(const NodeMapPtr &nodemap)
Set the nodemap and exchanges the model.
Definition: property_grid.hpp:227
void ExpandSearchResult(const QModelIndexList &indexList)
Expands all nodes of given QModelIndexList as well as its parents.
Definition: property_grid.hpp:357
QString HtmlFormattedDescription(const QModelIndex &index)
Returns an HTML formatted description of given node by QModelIndex.
Definition: property_grid.hpp:285
PropertyGrid(const NodeMapPtr &nodemap, QWidget *parent=nullptr)
Create a property grid.
Definition: property_grid.hpp:169
void SetSearchResultBackgroundColor(QColor color)
Set the search result background color.
Definition: property_grid.hpp:326
void ResetUpdateLock()
Reset the update lock.
Definition: property_grid.hpp:419
void ResetSearch()
Reset the search text.
Definition: property_grid.hpp:306
void Update()
Updates all properties / nodes.
Definition: property_grid.hpp:388
Visibility
Feature complexity level.
Definition: genapi.hpp:235
QString CvbToQt(const Cvb::String &text) noexcept
Convenience converter for strings.
Definition: ui.hpp:253
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24
void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
void commitData(QWidget *editor)
virtual bool setData(const QModelIndex &index, const QVariant &value, int role)
void clicked(const QModelIndex &index)
void edit(const QModelIndex &index)
void setSelectionMode(QAbstractItemView::SelectionMode mode)
void setItemDelegate(QAbstractItemDelegate *delegate)
const QColor & color() const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * parent() const const
void drawLine(const QLineF &line)
void fillRect(const QRectF &rectangle, const QBrush &brush)
void setPen(const QColor &color)
const QBrush & brush(QPalette::ColorGroup group, QPalette::ColorRole role) const const
QString & append(QChar ch)
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const const override
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const const override
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const const override
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const const override
int columnWidth(int column) const const
void resizeColumnToContents(int column)
void setColumnWidth(int column, int width)
void setExpanded(const QModelIndex &index, bool expanded)
virtual void setModel(QAbstractItemModel *model) override