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"
39VariantDelegate(
QObject* parent = 0)
47~VariantDelegate() =
default;
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());
176 propertyModel_ =
new UI::Private::PropertyModel();
184 delete propertyModel_;
193 auto prop = propertyModel_->Property(index);
196 if (!prop->IsReadOnly() && prop->Type() != UI::Private::Property::PT_Boolean)
202 updateTimer_ =
new QTimer(
this);
216 delete propertyModel_;
226 propertyModel_->SetNodeMap(nodemap);
243 return propertyModel_->NodeMap();
252 propertyModel_->RemoveNodeMap();
263 propertyModel_->SetMaxVisibility(visibility);
273 return propertyModel_->MaxVisibility();
284 return HtmlDescription(index);
296 return propertyModel_->Search(text);
305 propertyModel_->ResetSearch();
315 return propertyModel_->SearchText();
325 propertyModel_->SetSearchResultBGColor(color);
335 return propertyModel_->SearchResultBGColor();
346 return propertyModel_->Item(index)->Node();
356 for (
int i = 0; i < indexList.size(); i++)
357 ExpandProperty(indexList.at(i));
367 for (
int i = 0; i < indexList.size(); i++)
368 CollapseProperty(indexList.at(i));
378 propertyModel_->UpdateProperty(index);
387 propertyModel_->Update();
397 updateTimer_->
start(ms);
406 updateTimer_->
stop();
418 propertyModel_->ResetUpdateLock();
430 auto parentIndex = propertyModel_->parent(index);
433 ExpandProperty(parentIndex);
442 auto parentIndex = propertyModel_->parent(index);
445 CollapseProperty(parentIndex);
450 auto prop = propertyModel_->Item(index);
455 auto node = prop->Node();
458 if (!node->Description().empty())
461 txt.
append(
"<br><table>");
464 if (
typeid(*node) !=
typeid(CategoryNode))
466 txt.
append(
"<tr><td><b>Type:</b></td><td>" +
UI::CvbToQt(prop->NodeType()) +
"</td></tr>");
467 txt.
append(
"<tr><td><b>Access Mode:</b></td><td>" +
UI::CvbToQt(prop->NodeAccessMode()) +
"</td></tr>");
468 txt.
append(
"<tr><td><b>Visibility:</b></td><td>" +
UI::CvbToQt(prop->NodeVisibility()) +
"</td></tr>");
469 txt.
append(
"<tr><td><b>Caching Mode:</b></td><td>" +
UI::CvbToQt(prop->NodeCachingMode()) +
"</td></tr>");
470 if (prop->NodeIsStreamable())
471 txt.
append(
"<tr><td><b>Streamable:</b></td><td>True</td></tr>");
473 txt.
append(
"<tr><td><b>Streamable:</b></td><td>False</td></tr>");
477 switch (prop->Type())
479 case UI::Private::Property::PropertyType::PT_Integer:
480 case UI::Private::Property::PropertyType::PT_Float:
481 case UI::Private::Property::PropertyType::PT_String:
482 case UI::Private::Property::PropertyType::PT_Enumeration:
483 txt.
append(prop->HtmlDescription());
490 static const int maxColumnWidth_ = 180;
491 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:404
NodePtr Node(const QModelIndex &index)
The node of the given QModelIndex.
Definition: property_grid.hpp:344
void CollapseSearchResult(const QModelIndexList &indexList)
Collapses all nodes of given QModelIndexList as well as its parents.
Definition: property_grid.hpp:365
NodeMapPtr NodeMap()
Return the nodemap.
Definition: property_grid.hpp:241
GenApi::Visibility Visibility()
Returns the visibility of the nodemap.
Definition: property_grid.hpp:271
void ReleaseNodeMap()
Release the nodemap.
Definition: property_grid.hpp:250
void UpdateProperty(const QModelIndex &index)
Updates a given property / node.
Definition: property_grid.hpp:376
QString SearchText()
Returns the search text which is currently set.
Definition: property_grid.hpp:313
void SetVisibility(GenApi::Visibility visibility)
Set the visibility of the nodemap.
Definition: property_grid.hpp:261
QModelIndexList Search(const QString &text)
Search for displayed property name.
Definition: property_grid.hpp:294
QColor SearchResultBackgroundColor()
Returns the search result background color.
Definition: property_grid.hpp:333
void StartAutoUpdate(int ms)
Starts the automatic update of the nodes.
Definition: property_grid.hpp:395
void SetNodeMap(const NodeMapPtr &nodemap)
Set the nodemap and exchanges the model.
Definition: property_grid.hpp:224
void ExpandSearchResult(const QModelIndexList &indexList)
Expands all nodes of given QModelIndexList as well as its parents.
Definition: property_grid.hpp:354
QString HtmlFormattedDescription(const QModelIndex &index)
Returns an HTML formatted description of given node by QModelIndex.
Definition: property_grid.hpp:282
PropertyGrid(const NodeMapPtr &nodemap, QWidget *parent=nullptr)
Create a property grid.
Definition: property_grid.hpp:169
~PropertyGrid()
Destructor of property grid.
Definition: property_grid.hpp:213
void SetSearchResultBackgroundColor(QColor color)
Set the search result background color.
Definition: property_grid.hpp:323
void ResetUpdateLock()
Reset the update lock.
Definition: property_grid.hpp:416
void ResetSearch()
Reset the search text.
Definition: property_grid.hpp:303
void Update()
Updates all properties / nodes.
Definition: property_grid.hpp:385
Visibility
Feature complexity level.
Definition: genapi.hpp:235
QString CvbToQt(const Cvb::String &text) noexcept
Convenience converter for strings.
Definition: ui.hpp:254
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