Choreonoid  1.8
ItemPropertyWidget.h
Go to the documentation of this file.
1 #ifndef CNOID_BASE_ITEM_PROPERTY_WIDGET_H
2 #define CNOID_BASE_ITEM_PROPERTY_WIDGET_H
3 
4 #include <QWidget>
5 #include <functional>
6 #include "exportdecl.h"
7 
8 namespace cnoid {
9 
10 class Item;
11 class PutPropertyFunction;
12 class MenuManager;
13 
14 class CNOID_EXPORT ItemPropertyWidget : public QWidget
15 {
16 public:
17  ItemPropertyWidget(QWidget* parent = nullptr);
19 
20  template<class ItemType>
21  void setPropertyFunction(std::function<void(ItemType* item, PutPropertyFunction& putProperty)> func){
22  setPropertyFunction_(
23  typeid(ItemType),
24  [func](Item* item, PutPropertyFunction& putProperty){
25  func(static_cast<ItemType*>(item), putProperty);
26  });
27  };
28 
29  bool hasPropertyFunctionFor(Item* item) const;
30 
31  void setCurrentItem(Item* item);
32  void updateProperties();
33  void resetColumnSizes();
34  void setOperationMenu(MenuManager& menuManager);
35 
36  class Impl;
37 
38 protected:
39  void keyPressEvent(QKeyEvent* event);
40 
41 private:
42  void setPropertyFunction_(
43  const std::type_info& type, std::function<void(Item* item, PutPropertyFunction& putProperty)> func);
44 
45  Impl* impl;
46 };
47 
48 }
49 
50 #endif
cnoid::ItemPropertyWidget
Definition: ItemPropertyWidget.h:14
cnoid::PutPropertyFunction
Definition: PutPropertyFunction.h:51
cnoid::ItemPropertyWidget::setPropertyFunction
void setPropertyFunction(std::function< void(ItemType *item, PutPropertyFunction &putProperty)> func)
Definition: ItemPropertyWidget.h:21
cnoid::MenuManager
Definition: MenuManager.h:14
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::Item
Definition: Item.h:29