qttreepropertybrowser.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the Qt Solutions component.
7 **
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** You may use this file under the terms of the BSD license as follows:
10 **
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
13 ** met:
14 ** * Redistributions of source code must retain the above copyright
15 ** notice, this list of conditions and the following disclaimer.
16 ** * Redistributions in binary form must reproduce the above copyright
17 ** notice, this list of conditions and the following disclaimer in
18 ** the documentation and/or other materials provided with the
19 ** distribution.
20 ** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
21 ** of its contributors may be used to endorse or promote products derived
22 ** from this software without specific prior written permission.
23 **
24 **
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40 
41 
42 #include "qttreepropertybrowser.h"
43 #include <QSet>
44 #include <QIcon>
45 #include <QTreeWidget>
46 #include <QItemDelegate>
47 #include <QHBoxLayout>
48 #include <QHeaderView>
49 #include <QPainter>
50 #include <QApplication>
51 #include <QFocusEvent>
52 #include <QStyle>
53 #include <QPalette>
54 
55 QT_BEGIN_NAMESPACE
56 
58 
60 {
61  QtTreePropertyBrowser* q_ptr;
62  Q_DECLARE_PUBLIC(QtTreePropertyBrowser)
63 
64 public:
66  void init(QWidget* parent);
67 
71  QWidget* createEditor(QtProperty* property, QWidget* parent) const
72  {
73  return q_ptr->createEditor(property, parent);
74  }
75  QtProperty* indexToProperty(const QModelIndex& index) const;
76  QTreeWidgetItem* indexToItem(const QModelIndex& index) const;
77  QtBrowserItem* indexToBrowserItem(const QModelIndex& index) const;
78  bool lastColumn(int column) const;
79  void disableItem(QTreeWidgetItem* item) const;
80  void enableItem(QTreeWidgetItem* item) const;
81  bool hasValue(QTreeWidgetItem* item) const;
82 
83  void slotCollapsed(const QModelIndex& index);
84  void slotExpanded(const QModelIndex& index);
85 
86  QColor calculatedBackgroundColor(QtBrowserItem* item) const;
87 
89  {
90  return m_treeWidget;
91  }
93  {
94  return m_markPropertiesWithoutValue;
95  }
96 
97  QtBrowserItem* currentItem() const;
98  void setCurrentItem(QtBrowserItem* browserItem, bool block);
99  void editItem(QtBrowserItem* browserItem);
100 
102  void slotCurrentTreeItemChanged(QTreeWidgetItem* newItem, QTreeWidgetItem*);
103 
104  QTreeWidgetItem* editedItem() const;
105 
106 private:
107  void updateItem(QTreeWidgetItem* item);
108 
109  QMap<QtBrowserItem*, QTreeWidgetItem*> m_indexToItem;
110  QMap<QTreeWidgetItem*, QtBrowserItem*> m_itemToIndex;
111 
112  QMap<QtBrowserItem*, QColor> m_indexToBackgroundColor;
113 
114  QtPropertyEditorView* m_treeWidget;
115 
116  bool m_headerVisible;
118  class QtPropertyEditorDelegate* m_delegate;
119  bool m_markPropertiesWithoutValue;
120  bool m_browserChangedBlocked;
121  QIcon m_expandIcon;
122 };
123 
124 // ------------ QtPropertyEditorView
125 class QtPropertyEditorView : public QTreeWidget
126 {
127  Q_OBJECT
128 public:
129  QtPropertyEditorView(QWidget* parent = 0);
130 
132  {
133  m_editorPrivate = editorPrivate;
134  }
135 
136  QTreeWidgetItem* indexToItem(const QModelIndex& index) const
137  {
138  return itemFromIndex(index);
139  }
140 
141 protected:
142  void keyPressEvent(QKeyEvent* event) override;
143  void mousePressEvent(QMouseEvent* event) override;
144  void drawRow(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
145 
146 private:
147  QtTreePropertyBrowserPrivate* m_editorPrivate;
148 };
149 
151  QTreeWidget(parent),
152  m_editorPrivate(0)
153 {
154  connect(header(), SIGNAL(sectionDoubleClicked(int)), this, SLOT(resizeColumnToContents(int)));
155 }
156 
157 void QtPropertyEditorView::drawRow(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
158 {
159  QStyleOptionViewItem opt = option;
160  bool hasValue = true;
161 
162  if (m_editorPrivate)
163  {
164  QtProperty* property = m_editorPrivate->indexToProperty(index);
165 
166  if (property)
167  {
168  hasValue = property->hasValue();
169  }
170  }
171 
172  if (!hasValue && m_editorPrivate->markPropertiesWithoutValue())
173  {
174  const QColor c = option.palette.color(QPalette::Dark);
175  painter->fillRect(option.rect, c);
176  opt.palette.setColor(QPalette::AlternateBase, c);
177  }
178  else
179  {
180  const QColor c = m_editorPrivate->calculatedBackgroundColor(m_editorPrivate->indexToBrowserItem(index));
181 
182  if (c.isValid())
183  {
184  painter->fillRect(option.rect, c);
185  opt.palette.setColor(QPalette::AlternateBase, c.lighter(112));
186  }
187  }
188 
189  QTreeWidget::drawRow(painter, opt, index);
190  QColor color = static_cast<QRgb>(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &opt));
191  painter->save();
192  painter->setPen(QPen(color));
193  painter->drawLine(opt.rect.x(), opt.rect.bottom(), opt.rect.right(), opt.rect.bottom());
194  painter->restore();
195 }
196 
198 {
199  switch (event->key())
200  {
201  case Qt::Key_Return:
202  case Qt::Key_Enter:
203  case Qt::Key_Space: // Trigger Edit
204  if (!m_editorPrivate->editedItem())
205  if (const QTreeWidgetItem* item = currentItem())
206  if (item->columnCount() >= 2 && ((item->flags() & (Qt::ItemIsEditable | Qt::ItemIsEnabled)) == (Qt::ItemIsEditable | Qt::ItemIsEnabled)))
207  {
208  event->accept();
209  // If the current position is at column 0, move to 1.
210  QModelIndex index = currentIndex();
211 
212  if (index.column() == 0)
213  {
214  index = index.sibling(index.row(), 1);
215  setCurrentIndex(index);
216  }
217 
218  edit(index);
219  return;
220  }
221 
222  break;
223 
224  default:
225  break;
226  }
227 
228  QTreeWidget::keyPressEvent(event);
229 }
230 
232 {
233  QTreeWidget::mousePressEvent(event);
234  QTreeWidgetItem* item = itemAt(event->pos());
235 
236  if (item)
237  {
238  if ((item != m_editorPrivate->editedItem()) && (event->button() == Qt::LeftButton)
239  && (header()->logicalIndexAt(event->pos().x()) == 1)
240  && ((item->flags() & (Qt::ItemIsEditable | Qt::ItemIsEnabled)) == (Qt::ItemIsEditable | Qt::ItemIsEnabled)))
241  {
242  editItem(item, 1);
243  }
244  else if (!m_editorPrivate->hasValue(item) && m_editorPrivate->markPropertiesWithoutValue() && !rootIsDecorated())
245  {
246  if (event->pos().x() + header()->offset() < 20)
247  {
248  item->setExpanded(!item->isExpanded());
249  }
250  }
251  }
252 }
253 
254 // ------------ QtPropertyEditorDelegate
255 class QtPropertyEditorDelegate : public QItemDelegate
256 {
257  Q_OBJECT
258 public:
259  QtPropertyEditorDelegate(QObject* parent = 0)
260  : QItemDelegate(parent), m_editorPrivate(0), m_editedItem(0), m_editedWidget(0), m_disablePainting(false)
261  {}
262 
264  {
265  m_editorPrivate = editorPrivate;
266  }
267 
268  QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
269  const QModelIndex& index) const override;
270 
271  void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option,
272  const QModelIndex& index) const override;
273 
274  void paint(QPainter* painter, const QStyleOptionViewItem& option,
275  const QModelIndex& index) const override;
276 
277  QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
278 
279  void setModelData(QWidget*, QAbstractItemModel*,
280  const QModelIndex&) const override {}
281 
282  void setEditorData(QWidget*, const QModelIndex&) const override {}
283 
284  bool eventFilter(QObject* object, QEvent* event) override;
285  void closeEditor(QtProperty* property);
286 
287  QTreeWidgetItem* editedItem() const
288  {
289  return m_editedItem;
290  }
291 
292 protected:
293 
294  void drawDecoration(QPainter* painter, const QStyleOptionViewItem& option,
295  const QRect& rect, const QPixmap& pixmap) const override;
296  void drawDisplay(QPainter* painter, const QStyleOptionViewItem& option,
297  const QRect& rect, const QString& text) const override;
298 
299 private slots:
300  void slotEditorDestroyed(QObject* object);
301 
302 private:
303  int indentation(const QModelIndex& index) const;
304 
305  using EditorToPropertyMap = QMap<QWidget*, QtProperty*>;
306  mutable EditorToPropertyMap m_editorToProperty;
307 
308  using PropertyToEditorMap = QMap<QtProperty*, QWidget*>;
309  mutable PropertyToEditorMap m_propertyToEditor;
310  QtTreePropertyBrowserPrivate* m_editorPrivate;
311  mutable QTreeWidgetItem* m_editedItem;
312  mutable QWidget* m_editedWidget;
313  mutable bool m_disablePainting;
314 };
315 
316 int QtPropertyEditorDelegate::indentation(const QModelIndex& index) const
317 {
318  if (!m_editorPrivate)
319  {
320  return 0;
321  }
322 
323  QTreeWidgetItem* item = m_editorPrivate->indexToItem(index);
324  int indent = 0;
325 
326  while (item->parent())
327  {
328  item = item->parent();
329  ++indent;
330  }
331 
332  if (m_editorPrivate->treeWidget()->rootIsDecorated())
333  {
334  ++indent;
335  }
336 
337  return indent * m_editorPrivate->treeWidget()->indentation();
338 }
339 
340 void QtPropertyEditorDelegate::slotEditorDestroyed(QObject* object)
341 {
342  if (QWidget* w = qobject_cast<QWidget*>(object))
343  {
344  const EditorToPropertyMap::iterator it = m_editorToProperty.find(w);
345 
346  if (it != m_editorToProperty.end())
347  {
348  m_propertyToEditor.remove(it.value());
349  m_editorToProperty.erase(it);
350  }
351 
352  if (m_editedWidget == w)
353  {
354  m_editedWidget = 0;
355  m_editedItem = 0;
356  }
357  }
358 }
359 
361 {
362  if (QWidget* w = m_propertyToEditor.value(property, 0))
363  {
364  w->deleteLater();
365  }
366 }
367 
368 QWidget* QtPropertyEditorDelegate::createEditor(QWidget* parent,
369  const QStyleOptionViewItem&, const QModelIndex& index) const
370 {
371  if (index.column() == 1 && m_editorPrivate)
372  {
373  QtProperty* property = m_editorPrivate->indexToProperty(index);
374  QTreeWidgetItem* item = m_editorPrivate->indexToItem(index);
375 
376  if (property && item && (item->flags() & Qt::ItemIsEnabled))
377  {
378  QWidget* editor = m_editorPrivate->createEditor(property, parent);
379 
380  if (editor)
381  {
382  editor->setAutoFillBackground(true);
383  editor->installEventFilter(const_cast<QtPropertyEditorDelegate*>(this));
384  connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*)));
385  m_propertyToEditor[property] = editor;
386  m_editorToProperty[editor] = property;
387  m_editedItem = item;
388  m_editedWidget = editor;
389  }
390 
391  return editor;
392  }
393  }
394 
395  return 0;
396 }
397 
399  const QStyleOptionViewItem& option, const QModelIndex& index) const
400 {
401  Q_UNUSED(index)
402  editor->setGeometry(option.rect.adjusted(0, 0, 0, -1));
403 }
404 
405 void QtPropertyEditorDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option,
406  const QModelIndex& index) const
407 {
408  bool hasValue = true;
409 
410  if (m_editorPrivate)
411  {
412  QtProperty* property = m_editorPrivate->indexToProperty(index);
413 
414  if (property)
415  {
416  hasValue = property->hasValue();
417  }
418  }
419 
420  QStyleOptionViewItem opt = option;
421 
422  if ((m_editorPrivate && index.column() == 0) || !hasValue)
423  {
424  QtProperty* property = m_editorPrivate->indexToProperty(index);
425 
426  if (property && property->isModified())
427  {
428  opt.font.setBold(true);
429  opt.fontMetrics = QFontMetrics(opt.font);
430  }
431  }
432 
433  QColor c;
434 
435  if (!hasValue && m_editorPrivate->markPropertiesWithoutValue())
436  {
437  c = opt.palette.color(QPalette::Dark);
438  opt.palette.setColor(QPalette::Text, opt.palette.color(QPalette::BrightText));
439  }
440  else
441  {
442  c = m_editorPrivate->calculatedBackgroundColor(m_editorPrivate->indexToBrowserItem(index));
443 
444  if (c.isValid() && (opt.features & QStyleOptionViewItemV2::Alternate))
445  {
446  c = c.lighter(112);
447  }
448  }
449 
450  if (c.isValid())
451  {
452  painter->fillRect(option.rect, c);
453  }
454 
455  opt.state &= ~QStyle::State_HasFocus;
456 
457  if (index.column() == 1)
458  {
459  QTreeWidgetItem* item = m_editorPrivate->indexToItem(index);
460 
461  if (m_editedItem && m_editedItem == item)
462  {
463  m_disablePainting = true;
464  }
465  }
466 
467  QItemDelegate::paint(painter, opt, index);
468 
469  if (option.type)
470  {
471  m_disablePainting = false;
472  }
473 
474  opt.palette.setCurrentColorGroup(QPalette::Active);
475  QColor color = static_cast<QRgb>(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &opt));
476  painter->save();
477  painter->setPen(QPen(color));
478 
479  if (!m_editorPrivate || (!m_editorPrivate->lastColumn(index.column()) && hasValue))
480  {
481  int right = (option.direction == Qt::LeftToRight) ? option.rect.right() : option.rect.left();
482  painter->drawLine(right, option.rect.y(), right, option.rect.bottom());
483  }
484 
485  painter->restore();
486 }
487 
488 void QtPropertyEditorDelegate::drawDecoration(QPainter* painter, const QStyleOptionViewItem& option,
489  const QRect& rect, const QPixmap& pixmap) const
490 {
491  if (m_disablePainting)
492  {
493  return;
494  }
495 
496  QItemDelegate::drawDecoration(painter, option, rect, pixmap);
497 }
498 
499 void QtPropertyEditorDelegate::drawDisplay(QPainter* painter, const QStyleOptionViewItem& option,
500  const QRect& rect, const QString& text) const
501 {
502  if (m_disablePainting)
503  {
504  return;
505  }
506 
507  QItemDelegate::drawDisplay(painter, option, rect, text);
508 }
509 
510 QSize QtPropertyEditorDelegate::sizeHint(const QStyleOptionViewItem& option,
511  const QModelIndex& index) const
512 {
513  return QItemDelegate::sizeHint(option, index) + QSize(3, 4);
514 }
515 
516 bool QtPropertyEditorDelegate::eventFilter(QObject* object, QEvent* event)
517 {
518  if (event->type() == QEvent::FocusOut)
519  {
520  QFocusEvent* fe = static_cast<QFocusEvent*>(event);
521 
522  if (fe->reason() == Qt::ActiveWindowFocusReason)
523  {
524  return false;
525  }
526  }
527 
528  return QItemDelegate::eventFilter(object, event);
529 }
530 
531 // -------- QtTreePropertyBrowserPrivate implementation
533  m_treeWidget(0),
534  m_headerVisible(true),
535  m_resizeMode(QtTreePropertyBrowser::Stretch),
536  m_delegate(0),
537  m_markPropertiesWithoutValue(false),
538  m_browserChangedBlocked(false)
539 {
540 }
541 
542 // Draw an icon indicating opened/closing branches
543 static QIcon drawIndicatorIcon(const QPalette& palette, QStyle* style)
544 {
545  QPixmap pix(14, 14);
546  pix.fill(Qt::transparent);
547  QStyleOption branchOption;
548  QRect r(QPoint(0, 0), pix.size());
549  branchOption.rect = QRect(2, 2, 9, 9); // ### hardcoded in qcommonstyle.cpp
550  branchOption.palette = palette;
551  branchOption.state = QStyle::State_Children;
552 
553  QPainter p;
554  // Draw closed state
555  p.begin(&pix);
556  style->drawPrimitive(QStyle::PE_IndicatorBranch, &branchOption, &p);
557  p.end();
558  QIcon rc = pix;
559  rc.addPixmap(pix, QIcon::Selected, QIcon::Off);
560  // Draw opened state
561  branchOption.state |= QStyle::State_Open;
562  pix.fill(Qt::transparent);
563  p.begin(&pix);
564  style->drawPrimitive(QStyle::PE_IndicatorBranch, &branchOption, &p);
565  p.end();
566 
567  rc.addPixmap(pix, QIcon::Normal, QIcon::On);
568  rc.addPixmap(pix, QIcon::Selected, QIcon::On);
569  return rc;
570 }
571 
573 {
574  QHBoxLayout* layout = new QHBoxLayout(parent);
575  layout->setMargin(0);
576  m_treeWidget = new QtPropertyEditorView(parent);
577  m_treeWidget->setEditorPrivate(this);
578  m_treeWidget->setIconSize(QSize(18, 18));
579  layout->addWidget(m_treeWidget);
580  parent->setFocusProxy(m_treeWidget);
581 
582  m_treeWidget->setColumnCount(2);
583  QStringList labels;
584  labels.append(QCoreApplication::translate("QtTreePropertyBrowser", "Property"));
585  labels.append(QCoreApplication::translate("QtTreePropertyBrowser", "Value"));
586  m_treeWidget->setHeaderLabels(labels);
587  m_treeWidget->setAlternatingRowColors(true);
588  m_treeWidget->setEditTriggers(QAbstractItemView::EditKeyPressed);
589  m_delegate = new QtPropertyEditorDelegate(parent);
590  m_delegate->setEditorPrivate(this);
591  m_treeWidget->setItemDelegate(m_delegate);
592  m_treeWidget->header()->setMovable(false);
593  m_treeWidget->header()->setResizeMode(QHeaderView::Stretch);
594 
595  m_expandIcon = drawIndicatorIcon(q_ptr->palette(), q_ptr->style());
596 
597  QObject::connect(m_treeWidget, SIGNAL(collapsed(const QModelIndex&)), q_ptr, SLOT(slotCollapsed(const QModelIndex&)));
598  QObject::connect(m_treeWidget, SIGNAL(expanded(const QModelIndex&)), q_ptr, SLOT(slotExpanded(const QModelIndex&)));
599  QObject::connect(m_treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), q_ptr, SLOT(slotCurrentTreeItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
600 }
601 
603 {
604  if (QTreeWidgetItem* treeItem = m_treeWidget->currentItem())
605  {
606  return m_itemToIndex.value(treeItem);
607  }
608 
609  return 0;
610 }
611 
613 {
614  const bool blocked = block ? m_treeWidget->blockSignals(true) : false;
615 
616  if (browserItem == 0)
617  {
618  m_treeWidget->setCurrentItem(0);
619  }
620  else
621  {
622  m_treeWidget->setCurrentItem(m_indexToItem.value(browserItem));
623  }
624 
625  if (block)
626  {
627  m_treeWidget->blockSignals(blocked);
628  }
629 }
630 
632 {
633  QTreeWidgetItem* item = m_treeWidget->indexToItem(index);
634  QtBrowserItem* idx = m_itemToIndex.value(item);
635 
636  if (idx)
637  {
638  return idx->property();
639  }
640 
641  return 0;
642 }
643 
645 {
646  QTreeWidgetItem* item = m_treeWidget->indexToItem(index);
647  return m_itemToIndex.value(item);
648 }
649 
650 QTreeWidgetItem* QtTreePropertyBrowserPrivate::indexToItem(const QModelIndex& index) const
651 {
652  return m_treeWidget->indexToItem(index);
653 }
654 
656 {
657  return m_treeWidget->header()->visualIndex(column) == m_treeWidget->columnCount() - 1;
658 }
659 
660 void QtTreePropertyBrowserPrivate::disableItem(QTreeWidgetItem* item) const
661 {
662  Qt::ItemFlags flags = item->flags();
663 
664  if (flags & Qt::ItemIsEnabled)
665  {
666  flags &= ~Qt::ItemIsEnabled;
667  item->setFlags(flags);
668  m_delegate->closeEditor(m_itemToIndex[item]->property());
669  const int childCount = item->childCount();
670 
671  for (int i = 0; i < childCount; i++)
672  {
673  QTreeWidgetItem* child = item->child(i);
674  disableItem(child);
675  }
676  }
677 }
678 
679 void QtTreePropertyBrowserPrivate::enableItem(QTreeWidgetItem* item) const
680 {
681  Qt::ItemFlags flags = item->flags();
682  flags |= Qt::ItemIsEnabled;
683  item->setFlags(flags);
684  const int childCount = item->childCount();
685 
686  for (int i = 0; i < childCount; i++)
687  {
688  QTreeWidgetItem* child = item->child(i);
689  QtProperty* property = m_itemToIndex[child]->property();
690 
691  if (property->isEnabled())
692  {
693  enableItem(child);
694  }
695  }
696 }
697 
698 bool QtTreePropertyBrowserPrivate::hasValue(QTreeWidgetItem* item) const
699 {
700  QtBrowserItem* browserItem = m_itemToIndex.value(item);
701 
702  if (browserItem)
703  {
704  return browserItem->property()->hasValue();
705  }
706 
707  return false;
708 }
709 
711 {
712  QTreeWidgetItem* afterItem = m_indexToItem.value(afterIndex);
713  QTreeWidgetItem* parentItem = m_indexToItem.value(index->parent());
714 
715  QTreeWidgetItem* newItem = 0;
716 
717  if (parentItem)
718  {
719  newItem = new QTreeWidgetItem(parentItem, afterItem);
720  }
721  else
722  {
723  newItem = new QTreeWidgetItem(m_treeWidget, afterItem);
724  }
725 
726  m_itemToIndex[newItem] = index;
727  m_indexToItem[index] = newItem;
728 
729  newItem->setFlags(newItem->flags() | Qt::ItemIsEditable);
730  m_treeWidget->setItemExpanded(newItem, true);
731 
732  updateItem(newItem);
733 }
734 
736 {
737  QTreeWidgetItem* item = m_indexToItem.value(index);
738 
739  if (m_treeWidget->currentItem() == item)
740  {
741  m_treeWidget->setCurrentItem(0);
742  }
743 
744  delete item;
745 
746  m_indexToItem.remove(index);
747  m_itemToIndex.remove(item);
748  m_indexToBackgroundColor.remove(index);
749 }
750 
752 {
753  QTreeWidgetItem* item = m_indexToItem.value(index);
754 
755  updateItem(item);
756 }
757 
758 void QtTreePropertyBrowserPrivate::updateItem(QTreeWidgetItem* item)
759 {
760  QtProperty* property = m_itemToIndex[item]->property();
761  QIcon expandIcon;
762 
763  if (property->hasValue())
764  {
765  QString toolTip = property->toolTip();
766 
767  if (toolTip.isEmpty())
768  {
769  toolTip = property->displayText();
770  }
771 
772  item->setToolTip(1, toolTip);
773  item->setIcon(1, property->valueIcon());
774  property->displayText().isEmpty() ? item->setText(1, property->valueText()) : item->setText(1, property->displayText());
775  }
776  else if (markPropertiesWithoutValue() && !m_treeWidget->rootIsDecorated())
777  {
778  expandIcon = m_expandIcon;
779  }
780 
781  item->setIcon(0, expandIcon);
782  item->setFirstColumnSpanned(!property->hasValue());
783  item->setToolTip(0, property->propertyName());
784  item->setStatusTip(0, property->statusTip());
785  item->setWhatsThis(0, property->whatsThis());
786  item->setText(0, property->propertyName());
787  bool wasEnabled = item->flags() & Qt::ItemIsEnabled;
788  bool isEnabled = wasEnabled;
789 
790  if (property->isEnabled())
791  {
792  QTreeWidgetItem* parent = item->parent();
793 
794  if (!parent || (parent->flags() & Qt::ItemIsEnabled))
795  {
796  isEnabled = true;
797  }
798  else
799  {
800  isEnabled = false;
801  }
802  }
803  else
804  {
805  isEnabled = false;
806  }
807 
808  if (wasEnabled != isEnabled)
809  {
810  if (isEnabled)
811  {
812  enableItem(item);
813  }
814  else
815  {
816  disableItem(item);
817  }
818  }
819 
820  m_treeWidget->viewport()->update();
821 }
822 
824 {
825  QtBrowserItem* i = item;
826  const QMap<QtBrowserItem*, QColor>::const_iterator itEnd = m_indexToBackgroundColor.constEnd();
827 
828  while (i)
829  {
830  QMap<QtBrowserItem*, QColor>::const_iterator it = m_indexToBackgroundColor.constFind(i);
831 
832  if (it != itEnd)
833  {
834  return it.value();
835  }
836 
837  i = i->parent();
838  }
839 
840  return QColor();
841 }
842 
844 {
845  QTreeWidgetItem* item = indexToItem(index);
846  QtBrowserItem* idx = m_itemToIndex.value(item);
847 
848  if (item)
849  {
850  emit q_ptr->collapsed(idx);
851  }
852 }
853 
855 {
856  QTreeWidgetItem* item = indexToItem(index);
857  QtBrowserItem* idx = m_itemToIndex.value(item);
858 
859  if (item)
860  {
861  emit q_ptr->expanded(idx);
862  }
863 }
864 
866 {
867  if (!m_browserChangedBlocked && item != currentItem())
868  {
869  setCurrentItem(item, true);
870  }
871 }
872 
873 void QtTreePropertyBrowserPrivate::slotCurrentTreeItemChanged(QTreeWidgetItem* newItem, QTreeWidgetItem*)
874 {
875  QtBrowserItem* browserItem = newItem ? m_itemToIndex.value(newItem) : 0;
876  m_browserChangedBlocked = true;
877  q_ptr->setCurrentItem(browserItem);
878  m_browserChangedBlocked = false;
879 }
880 
882 {
883  return m_delegate->editedItem();
884 }
885 
887 {
888  if (QTreeWidgetItem* treeItem = m_indexToItem.value(browserItem, 0))
889  {
890  m_treeWidget->setCurrentItem(treeItem, 1);
891  m_treeWidget->editItem(treeItem, 1);
892  }
893 }
894 
895 /*!
896  \class QtTreePropertyBrowser
897 
898  \brief The QtTreePropertyBrowser class provides QTreeWidget based
899  property browser.
900 
901  A property browser is a widget that enables the user to edit a
902  given set of properties. Each property is represented by a label
903  specifying the property's name, and an editing widget (e.g. a line
904  edit or a combobox) holding its value. A property can have zero or
905  more subproperties.
906 
907  QtTreePropertyBrowser provides a tree based view for all nested
908  properties, i.e. properties that have subproperties can be in an
909  expanded (subproperties are visible) or collapsed (subproperties
910  are hidden) state. For example:
911 
912  \image qttreepropertybrowser.png
913 
914  Use the QtAbstractPropertyBrowser API to add, insert and remove
915  properties from an instance of the QtTreePropertyBrowser class.
916  The properties themselves are created and managed by
917  implementations of the QtAbstractPropertyManager class.
918 
919  \sa QtGroupBoxPropertyBrowser, QtAbstractPropertyBrowser
920 */
921 
922 /*!
923  \fn void QtTreePropertyBrowser::collapsed(QtBrowserItem *item)
924 
925  This signal is emitted when the \a item is collapsed.
926 
927  \sa expanded(), setExpanded()
928 */
929 
930 /*!
931  \fn void QtTreePropertyBrowser::expanded(QtBrowserItem *item)
932 
933  This signal is emitted when the \a item is expanded.
934 
935  \sa collapsed(), setExpanded()
936 */
937 
938 /*!
939  Creates a property browser with the given \a parent.
940 */
942  : QtAbstractPropertyBrowser(parent)
943 {
944  d_ptr = new QtTreePropertyBrowserPrivate;
945  d_ptr->q_ptr = this;
946 
947  d_ptr->init(this);
948  connect(this, SIGNAL(currentItemChanged(QtBrowserItem*)), this, SLOT(slotCurrentBrowserItemChanged(QtBrowserItem*)));
949 }
950 
951 /*!
952  Destroys this property browser.
953 
954  Note that the properties that were inserted into this browser are
955  \e not destroyed since they may still be used in other
956  browsers. The properties are owned by the manager that created
957  them.
958 
959  \sa QtProperty, QtAbstractPropertyManager
960 */
962 {
963  delete d_ptr;
964 }
965 
966 /*!
967  \property QtTreePropertyBrowser::indentation
968  \brief indentation of the items in the tree view.
969 */
971 {
972  return d_ptr->m_treeWidget->indentation();
973 }
974 
976 {
977  d_ptr->m_treeWidget->setIndentation(i);
978 }
979 
980 /*!
981  \property QtTreePropertyBrowser::rootIsDecorated
982  \brief whether to show controls for expanding and collapsing root items.
983 */
985 {
986  return d_ptr->m_treeWidget->rootIsDecorated();
987 }
988 
990 {
991  d_ptr->m_treeWidget->setRootIsDecorated(show);
992  QMapIterator<QTreeWidgetItem*, QtBrowserItem*> it(d_ptr->m_itemToIndex);
993 
994  while (it.hasNext())
995  {
996  QtProperty* property = it.next().value()->property();
997 
998  if (!property->hasValue())
999  {
1000  d_ptr->updateItem(it.key());
1001  }
1002  }
1003 }
1004 
1005 /*!
1006  \property QtTreePropertyBrowser::alternatingRowColors
1007  \brief whether to draw the background using alternating colors.
1008  By default this property is set to true.
1009 */
1011 {
1012  return d_ptr->m_treeWidget->alternatingRowColors();
1013 }
1014 
1016 {
1017  d_ptr->m_treeWidget->setAlternatingRowColors(enable);
1018  QMapIterator<QTreeWidgetItem*, QtBrowserItem*> it(d_ptr->m_itemToIndex);
1019 }
1020 
1021 /*!
1022  \property QtTreePropertyBrowser::headerVisible
1023  \brief whether to show the header.
1024 */
1026 {
1027  return d_ptr->m_headerVisible;
1028 }
1029 
1031 {
1032  if (d_ptr->m_headerVisible == visible)
1033  {
1034  return;
1035  }
1036 
1037  d_ptr->m_headerVisible = visible;
1038  d_ptr->m_treeWidget->header()->setVisible(visible);
1039 }
1040 
1041 /*!
1042  \enum QtTreePropertyBrowser::ResizeMode
1043 
1044  The resize mode specifies the behavior of the header sections.
1045 
1046  \value Interactive The user can resize the sections.
1047  The sections can also be resized programmatically using setSplitterPosition().
1048 
1049  \value Fixed The user cannot resize the section.
1050  The section can only be resized programmatically using setSplitterPosition().
1051 
1052  \value Stretch QHeaderView will automatically resize the section to fill the available space.
1053  The size cannot be changed by the user or programmatically.
1054 
1055  \value ResizeToContents QHeaderView will automatically resize the section to its optimal
1056  size based on the contents of the entire column.
1057  The size cannot be changed by the user or programmatically.
1058 
1059  \sa setResizeMode()
1060 */
1061 
1062 /*!
1063  \property QtTreePropertyBrowser::resizeMode
1064  \brief the resize mode of setions in the header.
1065 */
1066 
1068 {
1069  return d_ptr->m_resizeMode;
1070 }
1071 
1073 {
1074  if (d_ptr->m_resizeMode == mode)
1075  {
1076  return;
1077  }
1078 
1079  d_ptr->m_resizeMode = mode;
1080  QHeaderView::ResizeMode m = QHeaderView::Stretch;
1081 
1082  switch (mode)
1083  {
1085  m = QHeaderView::Interactive;
1086  break;
1087 
1089  m = QHeaderView::Fixed;
1090  break;
1091 
1093  m = QHeaderView::ResizeToContents;
1094  break;
1095 
1097  default:
1098  m = QHeaderView::Stretch;
1099  break;
1100  }
1101 
1102  d_ptr->m_treeWidget->header()->setResizeMode(m);
1103 }
1104 
1105 /*!
1106  \property QtTreePropertyBrowser::splitterPosition
1107  \brief the position of the splitter between the colunms.
1108 */
1109 
1111 {
1112  return d_ptr->m_treeWidget->header()->sectionSize(0);
1113 }
1114 
1116 {
1117  d_ptr->m_treeWidget->header()->resizeSection(0, position);
1118 }
1119 
1120 /*!
1121  Sets the \a item to either collapse or expanded, depending on the value of \a expanded.
1122 
1123  \sa isExpanded(), expanded(), collapsed()
1124 */
1125 
1127 {
1128  QTreeWidgetItem* treeItem = d_ptr->m_indexToItem.value(item);
1129 
1130  if (treeItem)
1131  {
1132  treeItem->setExpanded(expanded);
1133  }
1134 }
1135 
1136 /*!
1137  Returns true if the \a item is expanded; otherwise returns false.
1138 
1139  \sa setExpanded()
1140 */
1141 
1143 {
1144  QTreeWidgetItem* treeItem = d_ptr->m_indexToItem.value(item);
1145 
1146  if (treeItem)
1147  {
1148  return treeItem->isExpanded();
1149  }
1150 
1151  return false;
1152 }
1153 
1154 /*!
1155  Returns true if the \a item is visible; otherwise returns false.
1156 
1157  \sa setItemVisible()
1158  \since 4.5
1159 */
1160 
1162 {
1163  if (const QTreeWidgetItem* treeItem = d_ptr->m_indexToItem.value(item))
1164  {
1165  return !treeItem->isHidden();
1166  }
1167 
1168  return false;
1169 }
1170 
1171 /*!
1172  Sets the \a item to be visible, depending on the value of \a visible.
1173 
1174  \sa isItemVisible()
1175  \since 4.5
1176 */
1177 
1179 {
1180  if (QTreeWidgetItem* treeItem = d_ptr->m_indexToItem.value(item))
1181  {
1182  treeItem->setHidden(!visible);
1183  }
1184 }
1185 
1186 /*!
1187  Sets the \a item's background color to \a color. Note that while item's background
1188  is rendered every second row is being drawn with alternate color (which is a bit lighter than items \a color)
1189 
1190  \sa backgroundColor(), calculatedBackgroundColor()
1191 */
1192 
1194 {
1195  if (!d_ptr->m_indexToItem.contains(item))
1196  {
1197  return;
1198  }
1199 
1200  if (color.isValid())
1201  {
1202  d_ptr->m_indexToBackgroundColor[item] = color;
1203  }
1204  else
1205  {
1206  d_ptr->m_indexToBackgroundColor.remove(item);
1207  }
1208 
1209  d_ptr->m_treeWidget->viewport()->update();
1210 }
1211 
1212 /*!
1213  Returns the \a item's color. If there is no color set for item it returns invalid color.
1214 
1215  \sa calculatedBackgroundColor(), setBackgroundColor()
1216 */
1217 
1219 {
1220  return d_ptr->m_indexToBackgroundColor.value(item);
1221 }
1222 
1223 /*!
1224  Returns the \a item's color. If there is no color set for item it returns parent \a item's
1225  color (if there is no color set for parent it returns grandparent's color and so on). In case
1226  the color is not set for \a item and it's top level item it returns invalid color.
1227 
1228  \sa backgroundColor(), setBackgroundColor()
1229 */
1230 
1232 {
1233  return d_ptr->calculatedBackgroundColor(item);
1234 }
1235 
1236 /*!
1237  \property QtTreePropertyBrowser::propertiesWithoutValueMarked
1238  \brief whether to enable or disable marking properties without value.
1239 
1240  When marking is enabled the item's background is rendered in dark color and item's
1241  foreground is rendered with light color.
1242 
1243  \sa propertiesWithoutValueMarked()
1244 */
1246 {
1247  if (d_ptr->m_markPropertiesWithoutValue == mark)
1248  {
1249  return;
1250  }
1251 
1252  d_ptr->m_markPropertiesWithoutValue = mark;
1253  QMapIterator<QTreeWidgetItem*, QtBrowserItem*> it(d_ptr->m_itemToIndex);
1254 
1255  while (it.hasNext())
1256  {
1257  QtProperty* property = it.next().value()->property();
1258 
1259  if (!property->hasValue())
1260  {
1261  d_ptr->updateItem(it.key());
1262  }
1263  }
1264 
1265  d_ptr->m_treeWidget->viewport()->update();
1266 }
1267 
1269 {
1270  return d_ptr->m_markPropertiesWithoutValue;
1271 }
1272 
1273 /*!
1274  \reimp
1275 */
1277 {
1278  d_ptr->propertyInserted(item, afterItem);
1279 }
1280 
1281 /*!
1282  \reimp
1283 */
1285 {
1286  d_ptr->propertyRemoved(item);
1287 }
1288 
1289 /*!
1290  \reimp
1291 */
1293 {
1294  d_ptr->propertyChanged(item);
1295 }
1296 
1297 /*!
1298  Sets the current item to \a item and opens the relevant editor for it.
1299 */
1301 {
1302  d_ptr->editItem(item);
1303 }
1304 
1305 QT_END_NAMESPACE
1306 
1307 #include "moc_qttreepropertybrowser.cpp"
1308 #include "qttreepropertybrowser.moc"
QtTreePropertyBrowserPrivate::indexToItem
QTreeWidgetItem * indexToItem(const QModelIndex &index) const
Definition: qttreepropertybrowser.cpp:650
QtPropertyEditorDelegate::setEditorData
void setEditorData(QWidget *, const QModelIndex &) const override
Definition: qttreepropertybrowser.cpp:282
QtTreePropertyBrowserPrivate::createEditor
QWidget * createEditor(QtProperty *property, QWidget *parent) const
Definition: qttreepropertybrowser.cpp:71
QtTreePropertyBrowser::ResizeMode
ResizeMode
Definition: qttreepropertybrowser.h:64
QtPropertyEditorView
Definition: qttreepropertybrowser.cpp:125
QtPropertyEditorDelegate::paint
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition: qttreepropertybrowser.cpp:405
QtTreePropertyBrowser::expanded
void expanded(QtBrowserItem *item)
QtPropertyEditorDelegate::drawDecoration
void drawDecoration(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QPixmap &pixmap) const override
Definition: qttreepropertybrowser.cpp:488
QtTreePropertyBrowser
The QtTreePropertyBrowser class provides QTreeWidget based property browser.
Definition: qttreepropertybrowser.h:51
QtTreePropertyBrowserPrivate::propertyInserted
void propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex)
Definition: qttreepropertybrowser.cpp:710
QtTreePropertyBrowser::ResizeToContents
@ ResizeToContents
Definition: qttreepropertybrowser.h:69
QtProperty::hasValue
bool hasValue() const
Definition: qtpropertybrowser.cpp:277
QtTreePropertyBrowser::calculatedBackgroundColor
QColor calculatedBackgroundColor(QtBrowserItem *item) const
Definition: qttreepropertybrowser.cpp:1231
QtTreePropertyBrowser::setResizeMode
void setResizeMode(ResizeMode mode)
Definition: qttreepropertybrowser.cpp:1072
QtTreePropertyBrowser::setIndentation
void setIndentation(int i)
Definition: qttreepropertybrowser.cpp:975
index
uint8_t index
Definition: EtherCATFrame.h:59
QtPropertyEditorView::drawRow
void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition: qttreepropertybrowser.cpp:157
QtTreePropertyBrowser::itemRemoved
void itemRemoved(QtBrowserItem *item) override
Definition: qttreepropertybrowser.cpp:1284
QtTreePropertyBrowser::setSplitterPosition
void setSplitterPosition(int position)
Definition: qttreepropertybrowser.cpp:1115
QtTreePropertyBrowserPrivate::slotCurrentBrowserItemChanged
void slotCurrentBrowserItemChanged(QtBrowserItem *item)
Definition: qttreepropertybrowser.cpp:865
QtTreePropertyBrowser::indentation
int indentation
indentation of the items in the tree view.
Definition: qttreepropertybrowser.h:55
GfxTL::On
OnOff< true > On
Definition: OnOff.h:10
QtTreePropertyBrowserPrivate
Definition: qttreepropertybrowser.cpp:59
QtAbstractPropertyBrowser
QtAbstractPropertyBrowser provides a base class for implementing property browsers.
Definition: qtpropertybrowser.h:289
QtPropertyEditorDelegate::drawDisplay
void drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const override
Definition: qttreepropertybrowser.cpp:499
QtTreePropertyBrowserPrivate::indexToProperty
QtProperty * indexToProperty(const QModelIndex &index) const
Definition: qttreepropertybrowser.cpp:631
QtPropertyEditorDelegate::setModelData
void setModelData(QWidget *, QAbstractItemModel *, const QModelIndex &) const override
Definition: qttreepropertybrowser.cpp:279
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
QtBrowserItem
The QtBrowserItem class represents a property in a property browser instance.
Definition: qtpropertybrowser.h:273
QtBrowserItem::parent
QtBrowserItem * parent() const
Definition: qtpropertybrowser.cpp:1233
QtPropertyEditorDelegate::updateEditorGeometry
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition: qttreepropertybrowser.cpp:398
QtTreePropertyBrowserPrivate::slotExpanded
void slotExpanded(const QModelIndex &index)
Definition: qttreepropertybrowser.cpp:854
QtPropertyEditorView::mousePressEvent
void mousePressEvent(QMouseEvent *event) override
Definition: qttreepropertybrowser.cpp:231
QtProperty
The QtProperty class encapsulates an instance of a property.
Definition: qtpropertybrowser.h:71
QtTreePropertyBrowser::itemChanged
void itemChanged(QtBrowserItem *item) override
Definition: qttreepropertybrowser.cpp:1292
QtTreePropertyBrowserPrivate::enableItem
void enableItem(QTreeWidgetItem *item) const
Definition: qttreepropertybrowser.cpp:679
QtTreePropertyBrowser::alternatingRowColors
bool alternatingRowColors
whether to draw the background using alternating colors. By default this property is set to true.
Definition: qttreepropertybrowser.h:57
QtPropertyEditorDelegate::QtPropertyEditorDelegate
QtPropertyEditorDelegate(QObject *parent=0)
Definition: qttreepropertybrowser.cpp:259
QtAbstractPropertyBrowser::createEditor
virtual QWidget * createEditor(QtProperty *property, QWidget *parent)
Definition: qtpropertybrowser.cpp:2096
QtTreePropertyBrowser::collapsed
void collapsed(QtBrowserItem *item)
QtTreePropertyBrowserPrivate::markPropertiesWithoutValue
bool markPropertiesWithoutValue() const
Definition: qttreepropertybrowser.cpp:92
QtAbstractPropertyBrowser::currentItemChanged
void currentItemChanged(QtBrowserItem *)
QtPropertyEditorView::indexToItem
QTreeWidgetItem * indexToItem(const QModelIndex &index) const
Definition: qttreepropertybrowser.cpp:136
QtTreePropertyBrowserPrivate::init
void init(QWidget *parent)
Definition: qttreepropertybrowser.cpp:572
QtTreePropertyBrowser::editItem
void editItem(QtBrowserItem *item)
Definition: qttreepropertybrowser.cpp:1300
QtTreePropertyBrowserPrivate::currentItem
QtBrowserItem * currentItem() const
Definition: qttreepropertybrowser.cpp:602
QtTreePropertyBrowser::setRootIsDecorated
void setRootIsDecorated(bool show)
Definition: qttreepropertybrowser.cpp:989
QtTreePropertyBrowser::setHeaderVisible
void setHeaderVisible(bool visible)
Definition: qttreepropertybrowser.cpp:1030
QtTreePropertyBrowserPrivate::setCurrentItem
void setCurrentItem(QtBrowserItem *browserItem, bool block)
Definition: qttreepropertybrowser.cpp:612
QtPropertyEditorView::setEditorPrivate
void setEditorPrivate(QtTreePropertyBrowserPrivate *editorPrivate)
Definition: qttreepropertybrowser.cpp:131
QtTreePropertyBrowser::Interactive
@ Interactive
Definition: qttreepropertybrowser.h:66
QtPropertyEditorDelegate::setEditorPrivate
void setEditorPrivate(QtTreePropertyBrowserPrivate *editorPrivate)
Definition: qttreepropertybrowser.cpp:263
QtTreePropertyBrowser::QtTreePropertyBrowser
QtTreePropertyBrowser(QWidget *parent=0)
Definition: qttreepropertybrowser.cpp:941
QtTreePropertyBrowserPrivate::editedItem
QTreeWidgetItem * editedItem() const
Definition: qttreepropertybrowser.cpp:881
QtPropertyEditorView::QtPropertyEditorView
QtPropertyEditorView(QWidget *parent=0)
Definition: qttreepropertybrowser.cpp:150
QtTreePropertyBrowser::itemInserted
void itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem) override
Definition: qttreepropertybrowser.cpp:1276
QtTreePropertyBrowser::rootIsDecorated
bool rootIsDecorated
whether to show controls for expanding and collapsing root items.
Definition: qttreepropertybrowser.h:56
QtTreePropertyBrowserPrivate::hasValue
bool hasValue(QTreeWidgetItem *item) const
Definition: qttreepropertybrowser.cpp:698
QtTreePropertyBrowser::isHeaderVisible
bool isHeaderVisible() const
Definition: qttreepropertybrowser.cpp:1025
QtPropertyEditorDelegate::closeEditor
void closeEditor(QtProperty *property)
Definition: qttreepropertybrowser.cpp:360
QtPropertyEditorDelegate
Definition: qttreepropertybrowser.cpp:255
QtTreePropertyBrowser::setItemVisible
void setItemVisible(QtBrowserItem *item, bool visible)
Definition: qttreepropertybrowser.cpp:1178
QtTreePropertyBrowser::resizeMode
ResizeMode resizeMode
the resize mode of setions in the header.
Definition: qttreepropertybrowser.h:59
QtTreePropertyBrowserPrivate::slotCollapsed
void slotCollapsed(const QModelIndex &index)
Definition: qttreepropertybrowser.cpp:843
GfxTL::Off
OnOff< false > Off
Definition: OnOff.h:11
QtBrowserItem::property
QtProperty * property() const
Definition: qtpropertybrowser.cpp:1221
QtPropertyEditorDelegate::eventFilter
bool eventFilter(QObject *object, QEvent *event) override
Definition: qttreepropertybrowser.cpp:516
QtTreePropertyBrowserPrivate::treeWidget
QtPropertyEditorView * treeWidget() const
Definition: qttreepropertybrowser.cpp:88
QtTreePropertyBrowser::isItemVisible
bool isItemVisible(QtBrowserItem *item) const
Definition: qttreepropertybrowser.cpp:1161
QtTreePropertyBrowser::Stretch
@ Stretch
Definition: qttreepropertybrowser.h:67
option
#define option(type, fn)
QtTreePropertyBrowser::propertiesWithoutValueMarked
bool propertiesWithoutValueMarked
whether to enable or disable marking properties without value.
Definition: qttreepropertybrowser.h:61
QtTreePropertyBrowser::isExpanded
bool isExpanded(QtBrowserItem *item) const
Definition: qttreepropertybrowser.cpp:1142
qttreepropertybrowser.h
QtTreePropertyBrowserPrivate::disableItem
void disableItem(QTreeWidgetItem *item) const
Definition: qttreepropertybrowser.cpp:660
QtTreePropertyBrowser::~QtTreePropertyBrowser
~QtTreePropertyBrowser() override
Definition: qttreepropertybrowser.cpp:961
QtTreePropertyBrowser::Fixed
@ Fixed
Definition: qttreepropertybrowser.h:68
QtTreePropertyBrowser::backgroundColor
QColor backgroundColor(QtBrowserItem *item) const
Definition: qttreepropertybrowser.cpp:1218
QtTreePropertyBrowserPrivate::lastColumn
bool lastColumn(int column) const
Definition: qttreepropertybrowser.cpp:655
QtTreePropertyBrowserPrivate::indexToBrowserItem
QtBrowserItem * indexToBrowserItem(const QModelIndex &index) const
Definition: qttreepropertybrowser.cpp:644
QtPropertyEditorView::keyPressEvent
void keyPressEvent(QKeyEvent *event) override
Definition: qttreepropertybrowser.cpp:197
QtTreePropertyBrowser::splitterPosition
int splitterPosition
the position of the splitter between the colunms.
Definition: qttreepropertybrowser.h:60
QtTreePropertyBrowserPrivate::slotCurrentTreeItemChanged
void slotCurrentTreeItemChanged(QTreeWidgetItem *newItem, QTreeWidgetItem *)
Definition: qttreepropertybrowser.cpp:873
QtTreePropertyBrowser::setAlternatingRowColors
void setAlternatingRowColors(bool enable)
Definition: qttreepropertybrowser.cpp:1015
armarx::transparent
QColor transparent()
Definition: StyleSheets.h:84
QtTreePropertyBrowserPrivate::editItem
void editItem(QtBrowserItem *browserItem)
Definition: qttreepropertybrowser.cpp:886
QtPropertyEditorDelegate::sizeHint
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition: qttreepropertybrowser.cpp:510
QtTreePropertyBrowserPrivate::propertyChanged
void propertyChanged(QtBrowserItem *index)
Definition: qttreepropertybrowser.cpp:751
QtTreePropertyBrowser::setPropertiesWithoutValueMarked
void setPropertiesWithoutValueMarked(bool mark)
Definition: qttreepropertybrowser.cpp:1245
QtTreePropertyBrowserPrivate::calculatedBackgroundColor
QColor calculatedBackgroundColor(QtBrowserItem *item) const
Definition: qttreepropertybrowser.cpp:823
QtTreePropertyBrowser::setBackgroundColor
void setBackgroundColor(QtBrowserItem *item, const QColor &color)
Definition: qttreepropertybrowser.cpp:1193
QtTreePropertyBrowserPrivate::QtTreePropertyBrowserPrivate
QtTreePropertyBrowserPrivate()
Definition: qttreepropertybrowser.cpp:532
QtTreePropertyBrowser::setExpanded
void setExpanded(QtBrowserItem *item, bool expanded)
Definition: qttreepropertybrowser.cpp:1126
QtAbstractPropertyBrowser::setCurrentItem
void setCurrentItem(QtBrowserItem *)
Definition: qtpropertybrowser.cpp:2197
QtTreePropertyBrowserPrivate::propertyRemoved
void propertyRemoved(QtBrowserItem *index)
Definition: qttreepropertybrowser.cpp:735
QtPropertyEditorDelegate::createEditor
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Definition: qttreepropertybrowser.cpp:368
QtPropertyEditorDelegate::editedItem
QTreeWidgetItem * editedItem() const
Definition: qttreepropertybrowser.cpp:287