32 #include <boost/filesystem.hpp> 38 #include <QTreeWidget> 41 #include <QTextBrowser> 42 #include <QVBoxLayout> 43 #include <QDialogButtonBox> 44 #include <QPushButton> 53 const QString& object_type,
54 const QStringList& disallowed_display_names,
55 const QStringList& disallowed_class_lookup_names,
56 QString* lookup_name_output,
57 QString* display_name_output,
61 , disallowed_display_names_( disallowed_display_names )
62 , disallowed_class_lookup_names_( disallowed_class_lookup_names )
63 , lookup_name_output_( lookup_name_output )
64 , display_name_output_( display_name_output )
69 QGroupBox* type_box =
new QGroupBox( object_type +
" Type" );
71 QTreeWidget*
tree =
new QTreeWidget;
72 tree->setHeaderHidden(
true );
75 QLabel* description_label =
new QLabel(
"Description:" );
80 QVBoxLayout* type_layout =
new QVBoxLayout;
81 type_layout->addWidget( tree );
82 type_layout->addWidget( description_label );
85 type_box->setLayout( type_layout );
91 name_box =
new QGroupBox( object_type +
" Name" );
93 QVBoxLayout* name_layout =
new QVBoxLayout;
95 name_box->setLayout( name_layout );
99 button_box_ =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
102 QVBoxLayout* main_layout =
new QVBoxLayout;
103 main_layout->addWidget( type_box );
106 main_layout->addWidget( name_box );
109 setLayout( main_layout );
112 connect( tree, SIGNAL( currentItemChanged( QTreeWidgetItem*, QTreeWidgetItem* )),
114 connect( tree, SIGNAL( itemActivated( QTreeWidgetItem*,
int )),
117 connect(
button_box_, SIGNAL( rejected() ),
this, SLOT( reject() ));
121 connect(
name_editor_, SIGNAL( textEdited(
const QString& )),
128 return( QSize(500,660) );
133 QIcon default_package_icon =
loadPixmap(
"package://rviz/icons/default_package_icon.png" );
139 std::map<QString, QTreeWidgetItem*> package_items;
141 for(
int i = 0; i < classes.size(); i++ )
143 QString lookup_name = classes[ i ];
144 QString
package = factory_->getClassPackage( lookup_name );
148 QTreeWidgetItem* package_item;
150 std::map<QString, QTreeWidgetItem*>::iterator mi;
151 mi = package_items.find(
package );
152 if( mi == package_items.end() )
154 package_item =
new QTreeWidgetItem( tree );
155 package_item->setText( 0,
package );
156 package_item->setIcon( 0, default_package_icon );
158 package_item->setExpanded(
true );
159 package_items[
package ] = package_item;
163 package_item = (*mi).second;
165 QTreeWidgetItem* class_item =
new QTreeWidgetItem( package_item );
169 class_item->setText( 0, name );
170 class_item->setWhatsThis( 0, description );
172 class_item->setData( 0, Qt::UserRole, lookup_name );
179 QString html =
"<html><body>" + selected_item->whatsThis( 0 ) +
"</body></html>";
183 QVariant user_data = selected_item->data( 0, Qt::UserRole );
184 bool selection_is_valid = user_data.isValid();
185 if( selection_is_valid )
190 QString display_name = selected_item->text( 0 );
199 name += QString::number( counter );
223 setError(
"Select a Display type." );
229 if( display_name.size() == 0 )
231 setError(
"Enter a name for the display." );
236 setError(
"Name in use. Display names must be unique." );
246 button_box_->button( QDialogButtonBox::Ok )->setToolTip( error_text );
void onDisplaySelected(QTreeWidgetItem *selected_item)
virtual QString getClassName(const QString &class_id) const =0
QString * lookup_name_output_
const QStringList & disallowed_display_names_
QString * display_name_output_
QTextBrowser * description_
void setError(const QString &error_text)
virtual QString getClassDescription(const QString &class_id) const =0
const QStringList & disallowed_class_lookup_names_
virtual QSize sizeHint() const
Abstract superclass representing the ability to get a list of class IDs and the ability to get name...
QDialogButtonBox * button_box_
void fillTree(QTreeWidget *tree)
NewObjectDialog(Factory *factory, const QString &object_type, const QStringList &disallowed_display_names, const QStringList &disallowed_class_lookup_names, QString *lookup_name_output, QString *display_name_output=0, QWidget *parent=0)
virtual QIcon getIcon(const QString &class_id) const =0
virtual QStringList getDeclaredClassIds()=0
QPixmap loadPixmap(QString url, bool fill_cache)