23 #include <QCloseEvent>
24 #include <QDockWidget>
25 #include <QSignalMapper>
32 using boost::property_tree::ptree;
37 m_signal_mapper =
new QSignalMapper(
this);
38 connect(m_signal_mapper, SIGNAL(mapped(QString
const&)),
this, SIGNAL(ItemTriggered(QString
const&)));
47 void PTreeMenu::AddAllAction()
49 m_action_all =
new QAction(
"All...",
this);
50 connect(m_action_all, SIGNAL(triggered()), m_signal_mapper, SLOT(map()));
51 m_signal_mapper->setMapping(m_action_all, m_path);
52 addAction(m_action_all);
59 for (
auto action : actions()) {
60 m_signal_mapper->removeMappings(action);
85 OpenPTreeInternal(pt, depth);
93 void PTreeMenu::OpenPTreeInternal(boost::property_tree::ptree
const& pt,
int remaining_depth)
98 if (remaining_depth != 0) {
99 for (
auto const & subtree : pt) {
100 if (subtree.second.empty()) {
103 QString item_name = QString::fromStdString(subtree.first);
104 QString item_path = (m_path ==
"") ? item_name : m_path +
'.' + item_name;
106 if (remaining_depth > 1 || remaining_depth == -1) {
108 menu->OpenPTreeInternal(subtree.second,
109 (remaining_depth == -1) ? -1 : remaining_depth - 1);
113 connect(menu, SIGNAL(ItemTriggered(QString
const&)),
114 this, SIGNAL(ItemTriggered(QString
const&)));
116 QAction* action =
new QAction(item_name +
"...",
this);
117 connect(action, SIGNAL(triggered()), m_signal_mapper, SLOT(map()));
118 m_signal_mapper->setMapping(action, item_path);
virtual bool InternalSave()
virtual ~PTreeMenu()
Destructor does not do a thing, except be virtual.
virtual bool IsOpened() const
Test whether menu is in opened state.
see the online Qt documentation
virtual bool InternalIsClean() const
virtual void InternalForceClose()
Interface for PTreeEditorWindow.
Abstract class that represents the ability be in closed or opened state, and, if the latter...
see the online Qt documentation
bool OpenPTree(boost::property_tree::ptree const &pt, int depth=-1)
Open a ptree.
bool SaveAndClose()
Try to save this object (and its children) and, if successful, close them all.
PTreeMenu(QString const &title, QString const &path_prefix=QString(), QWidget *parent=0)
Namespace for generic graphical shell for simulators.