32 #include <QVBoxLayout> 33 #include <QTreeWidget> 57 tree_widget_->setContextMenuPolicy(Qt::CustomContextMenu);
60 QObject::connect(
tree_widget_, SIGNAL(customContextMenuRequested(
const QPoint&)),
63 QObject::connect(
tree_widget_, SIGNAL(itemActivated(QTreeWidgetItem*,
int)),
66 auto *main_layout =
new QVBoxLayout();
68 main_layout->setContentsMargins(0,0,0,0);
69 setLayout(main_layout);
81 qWarning(
"ProfileTreeWidget: Cannot change the profile database.");
89 QObject::connect(
db_, SIGNAL(profileModified(
int)),
91 QObject::connect(
db_, SIGNAL(profileAdded(
int)),
93 QObject::connect(
db_, SIGNAL(nodesAdded(
int)),
119 for (
auto key : keys) {
128 qWarning(
"Invald profile for key %d.", profile_key);
136 item->setText(0, profile.
name());
143 addNode(item, profile, child_key);
162 qWarning(
"Invalid node for key %d", node_key);
167 item->setText(0, node.
name());
170 parent->addChild(item);
173 for (
auto child_key : node.
childKeys()) {
174 addNode(item, profile, child_key);
182 auto menu =
new QMenu(
this);
183 auto expand_all_action = menu->addAction(
"Expand All");
184 QObject::connect(expand_all_action, SIGNAL(triggered()),
187 auto collapse_all_action = menu->addAction(
"Collapse All");
188 QObject::connect(collapse_all_action, SIGNAL(triggered()),
192 QObject::connect(menu, SIGNAL(aboutToHide()), menu, SLOT(deleteLater()));
195 qWarning(
"No item under mouse");
199 qWarning(
"node %d--%d", profile_key, node_key);
201 qWarning(
"Unknown item type: %d", item->type());
217 return "<INVALID KEY>";
222 return profile.
name();
230 if (
items_.count(key) == 0) {
239 if (
items_.count(key) == 0) {