1 #ifndef CNOID_BASE_ITEM_TREE_PANEL_DIALOG_H
2 #define CNOID_BASE_ITEM_TREE_PANEL_DIALOG_H
4 #include <cnoid/Dialog>
5 #include "exportdecl.h"
11 class ItemTreePanelBase;
21 PanelOnlyDisplayMode = 1,
22 LastValidPanelKeepingMode = 2,
24 SinglePanelSyncMode = 4
27 void setMode(
int flags);
32 template<
class TargetItemType>
35 template<
class TargetItemType>
38 std::function<QSize()> minimumSizeHintFunction)
41 typeid(TargetItemType),
42 [panelFunction](
Item* item){
return panelFunction(
static_cast<TargetItemType*
>(item)); },
43 minimumSizeHintFunction);
46 void addTopAreaWidget(QWidget* widget);
47 void updateTopAreaLayout();
49 bool setTopItem(
Item* topItem,
bool isTopVisible =
false);
51 bool setCurrentItem(
Item* item,
bool isNewItem =
false);
54 virtual void onCurrentItemChanged(
Item* item);
55 virtual void keyPressEvent(QKeyEvent* event)
override;
56 virtual void hideEvent(QHideEvent* event)
override;
63 const std::type_info& type,
65 const std::function<QSize()>& minimumSizeHintFunction);
74 ItemTreePanelBase(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
76 virtual std::string caption()
const = 0;
77 virtual bool onActivated(
Item* topItem,
Item* targetItem,
bool isNewItem) = 0;
78 virtual void onDeactivated();
90 template<
class TopItemType,
class TargetItemType>
94 ItemTreePanel(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags())
99 if(
auto derivedTopItem =
dynamic_cast<TopItemType*
>(topItem)){
100 if(
auto derivedTargetItem =
dynamic_cast<TargetItemType*
>(targetItem)){
101 return onActivated(derivedTopItem, derivedTargetItem, isNewItem);
107 virtual bool onActivated(TopItemType* topItem, TargetItemType* targetItem,
bool isNewItem) = 0;
111 template<
class TargetItemType>
115 typeid(TargetItemType),
116 [panel](
Item*){
return panel; },
117 [panel](){
return panel->minimumSizeHint(); });