32 #include <boost/filesystem.hpp>
38 #include <QTreeWidget>
41 #include <QTextBrowser>
42 #include <QVBoxLayout>
43 #include <QDialogButtonBox>
44 #include <QPushButton>
52 const QString& object_type,
53 const QStringList& disallowed_display_names,
54 const QStringList& disallowed_class_lookup_names,
55 QString* lookup_name_output,
56 QString* display_name_output,
60 , disallowed_display_names_(disallowed_display_names)
61 , disallowed_class_lookup_names_(disallowed_class_lookup_names)
62 , lookup_name_output_(lookup_name_output)
63 , display_name_output_(display_name_output)
68 QGroupBox* type_box =
new QGroupBox(object_type +
" Type");
70 QTreeWidget*
tree =
new QTreeWidget;
71 tree->setHeaderHidden(
true);
74 QLabel* description_label =
new QLabel(
"Description:");
79 QVBoxLayout* type_layout =
new QVBoxLayout;
80 type_layout->addWidget(
tree);
81 type_layout->addWidget(description_label);
84 type_box->setLayout(type_layout);
87 QGroupBox* name_box =
nullptr;
90 name_box =
new QGroupBox(object_type +
" Name");
92 QVBoxLayout* name_layout =
new QVBoxLayout;
94 name_box->setLayout(name_layout);
98 button_box_ =
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal);
100 QVBoxLayout* main_layout =
new QVBoxLayout;
101 main_layout->addWidget(type_box);
104 main_layout->addWidget(name_box);
107 setLayout(main_layout);
113 connect(
button_box_, &QDialogButtonBox::rejected,
this, &NewObjectDialog::reject);
123 return (QSize(500, 660));
128 QIcon default_package_icon =
loadPixmap(
"package://rviz/icons/default_package_icon.png");
134 std::map<QString, QTreeWidgetItem*> package_items;
136 for (
int i = 0; i < classes.size(); i++)
138 QString lookup_name = classes[i];
139 QString
package = factory_->getClassPackage(lookup_name);
143 QTreeWidgetItem* package_item;
145 std::map<QString, QTreeWidgetItem*>::iterator mi;
146 mi = package_items.find(
package);
147 if (mi == package_items.end())
149 package_item =
new QTreeWidgetItem(
tree);
150 package_item->setText(0,
package);
151 package_item->setIcon(0, default_package_icon);
153 package_item->setExpanded(
true);
154 package_items[
package] = package_item;
158 package_item = (*mi).second;
160 QTreeWidgetItem* class_item =
new QTreeWidgetItem(package_item);
164 class_item->setText(0, name);
167 class_item->setData(0, Qt::UserRole, lookup_name);
174 QString html =
"<html><body>" + selected_item->whatsThis(0) +
"</body></html>";
178 QVariant user_data = selected_item->data(0, Qt::UserRole);
179 bool selection_is_valid = user_data.isValid();
180 if (selection_is_valid)
185 QString display_name = selected_item->text(0);
194 name += QString::number(counter);
224 if (display_name.size() == 0)
226 setError(
"Enter a name for the display.");
231 setError(
"Name in use. Display names must be unique.");
241 button_box_->button(QDialogButtonBox::Ok)->setToolTip(error_text);