Gazebo Gui

API Reference

8.3.0
Helpers.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 #ifndef GZ_GUI_HELPERS_HH_
18 #define GZ_GUI_HELPERS_HH_
19 
20 #include <string>
21 
22 #include "gz/gui/Enums.hh"
23 #include "gz/gui/Export.hh"
24 
25 namespace gz::gui
26 {
31  GZ_GUI_VISIBLE
33 
41  GZ_GUI_VISIBLE
43  const std::string &_type = "");
44 
50  GZ_GUI_VISIBLE
51  void rangeFromKey(const std::string &_key, double &_min, double &_max);
52 
57  GZ_GUI_VISIBLE
59 
67  GZ_GUI_VISIBLE
68  std::string uniqueFilePath(const std::string &_pathAndName,
69  const std::string &_extension);
70 
77  GZ_GUI_VISIBLE
79 
87  GZ_GUI_VISIBLE
89 
96  GZ_GUI_VISIBLE
98 
105  GZ_GUI_VISIBLE
107 
114  template<class T>
115  T findFirstByProperty(const QList<T> _list, const char *_key,
116  QVariant _value)
117  {
118  if (nullptr == _key)
119  return nullptr;
120 
121  for (const auto &w : _list)
122  {
123  if (nullptr == w)
124  continue;
125 
126  if (w->property(_key) == _value)
127  return w;
128  }
129  return nullptr;
130  }
131 } // namespace gz::gui
132 #endif // GZ_GUI_HELPERS_HH_