1 #ifndef CNOID_BASE_ITEM_TREE_WIDGET_H
2 #define CNOID_BASE_ITEM_TREE_WIDGET_H
8 #include "exportdecl.h"
10 class QTreeWidgetItem;
35 template<
class ItemType>
37 Item* findOrCreateRootItem();
38 template<
class ItemType>
41 void setRootItem(
Item* item);
42 void setRootItemUpdateFunction(std::function<
Item*(
bool doCreate)> func);
45 void setRootItemVisible(
bool on);
46 bool isRootItemVisible()
const;
48 void setDragDropEnabled(
bool on);
49 void setCheckColumnShown(
bool on);
51 template<
class ItemType>
55 [func](
Item* item,
bool isTopLevelItemCandidate){
56 return func(
static_cast<ItemType*
>(item), isTopLevelItemCandidate);
62 QBrush foreground()
const;
63 void setForeground(
const QBrush& brush);
64 QBrush background()
const;
65 void setBackground(
const QBrush& brush);
67 void setFont(
const QFont& font);
69 void setIcon(
const QIcon& icon);
70 void setToolTip(
const std::string& toolTip);
71 void setStatusTip(
const std::string& statusTip);
72 void setNameEditable(
bool on);
74 QTreeWidgetItem* item;
78 template<
class ItemType>
83 return func(
static_cast<ItemType*
>(item), display);
87 template<
class ItemType>
89 std::function<
bool(ItemType* item,
Item* parentItem)> func){
90 customizePositionAcceptance_(
92 [func](
Item* item,
Item* parentItem){
93 return func(
static_cast<ItemType*
>(item), parentItem);
97 bool checkPositionAcceptance(
Item* item,
Item* parentItem)
const;
99 void customizeRootContextMenu(std::function<
void(
MenuManager& menuManager)> func);
101 template<
class ItemType>
104 customizeContextMenu_(
107 func(
static_cast<ItemType*
>(item), menuManager, menuFunction);
111 void updateTreeWidgetItems();
112 void setExpanded(
Item* item,
bool on =
true);
113 void editItemName(
Item* item);
120 void setSelectionSyncGroup(
const std::string&
id);
126 return getSelectedItems();
130 bool selectOnly(
Item* item);
132 void selectAllItems();
133 void clearSelection();
134 void setSelectedItemsChecked(
bool on);
135 void toggleSelectedItemChecks();
136 void cutSelectedItems();
137 void copySelectedItems();
138 void copySelectedItemsWithSubTrees();
139 bool pasteItems(
bool doCheckPositionAcceptance =
true);
140 bool checkPastable(
Item* pasteParentItem)
const;
142 bool storeState(
Archive& archive);
143 bool restoreState(
const Archive& archive);
146 void customizeVisibility_(
147 const std::type_info& type, std::function<
bool(
Item* item,
bool isTopLevelItemCandidate)> func);
148 void customizeDisplay_(
149 const std::type_info& type, std::function<
void(
Item* item, Display& display)> func);
150 void customizePositionAcceptance_(
151 const std::type_info& type, std::function<
bool(
Item* item,
Item* parentItem)> func);
152 void customizeContextMenu_(
153 const std::type_info& type,