/usr/include/choreonoid-1.1/cnoid/src/Base/ItemTreeView.h is in libcnoid-dev 1.1.0+dfsg-6.1+b4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | /**
@author Shin'ichiro Nakaoka
*/
#ifndef CNOID_GUIBASE_ITEM_TREE_VIEW_H_INCLUDED
#define CNOID_GUIBASE_ITEM_TREE_VIEW_H_INCLUDED
#include "ItemList.h"
#include "SignalProxy.h"
#include <cnoid/View>
#include <QAbstractItemModel>
#include "exportdecl.h"
namespace cnoid {
class RootItem;
class ItemTreeViewImpl;
/**
@if jp
アイテムツリーを表示するウィンドウ
@endif
*/
class CNOID_EXPORT ItemTreeView : public View
{
Q_OBJECT
public:
static void initialize(ExtensionManager* ext);
static ItemTreeView* mainInstance();
ItemTreeView(RootItem* rootItem, bool showRoot = false);
~ItemTreeView();
RootItem* rootItem();
void showRoot(bool show);
/**
@if jp
選択状態になっているアイテムのうち、指定した型に適合するものを取得する。
@endif
*/
template <class ItemType> inline ItemList<ItemType> selectedItems() {
ItemList<ItemType> items;
getSelectedItems(items);
return items;
}
template <class ItemType> inline ItemType* selectedItem(bool fromMultiItems = false) {
return selectedItems<ItemType>().toSingle(fromMultiItems).get();
}
/**
@if jp
topItem 以下のサブツリーにおける選択状態アイテムのリストを得る。
topItem は選択されていてもリストには含まれない。
@endif
*/
template <class ItemType> inline ItemList<ItemType> selectedSubItems(ItemPtr topItem) {
ItemList<ItemType> items;
extractSelectedItemsOfSubTree(topItem, items);
return items;
}
template <class ItemType> inline ItemType* selectedSubItem(ItemPtr topItem, bool fromMultiItems = false) {
return selectedSubItems<ItemType>(topItem).toSingle(fromMultiItems).get();
}
bool isItemSelected(ItemPtr item);
bool selectItem(ItemPtr item, bool select = true);
void clearSelection();
/**
@if jp
チェック状態になっているアイテムのうち、指定した型に適合するものを取得する。
@endif
*/
template <class ItemType> inline ItemList<ItemType> checkedItems() {
ItemList<ItemType> items;
getCheckedItems(items);
return items;
}
bool isItemChecked(ItemPtr item);
bool checkItem(ItemPtr item, bool check);
/**
@if jp
アイテムの選択状態が変化したときに発行されるシグナル。
@endif
*/
SignalProxy< boost::signal<void(const ItemList<Item>&)> > sigSelectionChanged();
/**
@if jp
アイテムの選択状態が変化したか、ツリーの構造が変化したときに発行されるシグナル。
アイテム間の親子関係もみるようなハンドラはこのシグナルと接続するとよい。
@endif
*/
SignalProxy< boost::signal<void(const ItemList<Item>&)> > sigSelectionOrTreeChanged();
SignalProxy< boost::signal<void(Item* item, bool isChecked)> > sigCheckToggled();
SignalProxy< boost::signal<void(bool isChecked)> > sigCheckToggled(Item* targetItem);
protected:
virtual bool storeState(Archive& archive);
virtual bool restoreState(const Archive& archive);
private:
ItemTreeViewImpl* impl;
void getSelectedItems(ItemListBase& items);
void getCheckedItems(ItemListBase& items);
void extractSelectedItemsOfSubTree(ItemPtr topItem, ItemListBase& items);
private Q_SLOTS:
void onRowsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
void onRowsInserted(const QModelIndex& parent, int start, int end);
};
}
#endif
|