property_tree_with_help.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #include <QTextBrowser>
31 
34 
36 
37 namespace rviz
38 {
39 PropertyTreeWithHelp::PropertyTreeWithHelp(QWidget* parent) : QSplitter(parent)
40 {
41  setOrientation(Qt::Vertical);
42 
44 
45  help_ = new QTextBrowser;
46  help_->setOpenExternalLinks(true);
47 
48  addWidget(property_tree_);
49  addWidget(help_);
50 
51  setStretchFactor(0, 1000);
52  setCollapsible(0, false);
53 
54  QList<int> _sizes;
55  _sizes.push_back(1000);
56  _sizes.push_back(1);
57  setSizes(_sizes);
58 
61 }
62 
64 {
65  if (property)
66  {
67  QString body_text = property->getDescription();
68  QString heading = property->getName();
69  body_text.replace("\n", "<br>");
70  QString html = "<html><body><strong>" + heading + "</strong><br>" + body_text + "</body></html>";
71  help_->setHtml(html);
72  }
73  else
74  {
75  help_->setHtml("");
76  }
77 }
78 
80 {
81  property_tree_->save(config.mapMakeChild("Property Tree Widget"));
82 
83  QList<int> _sizes = sizes();
84  config.mapSetValue("Tree Height", _sizes.at(0));
85  config.mapSetValue("Help Height", _sizes.at(1));
86 }
87 
89 {
90  property_tree_->load(config.mapGetChild("Property Tree Widget"));
91 
92  int tree_height;
93  int help_height;
94  if (config.mapGetInt("Tree Height", &tree_height) && config.mapGetInt("Help Height", &help_height))
95  {
96  QList<int> _sizes;
97  _sizes.push_back(tree_height);
98  _sizes.push_back(help_height);
99  setSizes(_sizes);
100  }
101 }
102 
103 } // end namespace rviz
rviz::PropertyTreeWithHelp::showHelpForProperty
void showHelpForProperty(const Property *property)
Definition: property_tree_with_help.cpp:63
rviz::PropertyTreeWidget::load
void load(const Config &config)
Read state from the given Config.
Definition: property_tree_widget.cpp:172
property.h
rviz::PropertyTreeWidget::currentPropertyChanged
void currentPropertyChanged(const Property *new_current_property)
rviz::Property
A single element of a property tree, with a name, value, description, and possibly children.
Definition: property.h:100
rviz
Definition: add_display_dialog.cpp:54
property_tree_widget.h
rviz::PropertyTreeWithHelp::save
void save(Config config) const
Write state to the given Config.
Definition: property_tree_with_help.cpp:79
rviz::PropertyTreeWidget::save
void save(Config config) const
Write state to the given Config.
Definition: property_tree_widget.cpp:135
property_tree_with_help.h
rviz::PropertyTreeWithHelp::load
void load(const Config &config)
Read state from the given Config.
Definition: property_tree_with_help.cpp:88
rviz::PropertyTreeWithHelp::property_tree_
PropertyTreeWidget * property_tree_
Definition: property_tree_with_help.h:65
rviz::PropertyTreeWithHelp::help_
QTextBrowser * help_
Definition: property_tree_with_help.h:66
rviz::PropertyTreeWidget
Definition: property_tree_widget.h:55
rviz::PropertyTreeWithHelp::PropertyTreeWithHelp
PropertyTreeWithHelp(QWidget *parent=nullptr)
Definition: property_tree_with_help.cpp:39
config
config
rviz::Config
Configuration data storage class.
Definition: config.h:124


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Dec 13 2024 03:31:02