Ignition Gui

API Reference

5.0.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 IGNITION_GUI_HELPERS_HH_
18 #define IGNITION_GUI_HELPERS_HH_
19 
20 #include <string>
21 
22 #include "ignition/gui/Enums.hh"
23 #include "ignition/gui/Export.hh"
24 
25 namespace ignition
26 {
27  namespace gui
28  {
33  IGNITION_GUI_VISIBLE
35 
43  IGNITION_GUI_VISIBLE
45  const std::string &_type = "");
46 
52  IGNITION_GUI_VISIBLE
53  void rangeFromKey(const std::string &_key, double &_min, double &_max);
54 
59  IGNITION_GUI_VISIBLE
61 
69  IGNITION_GUI_VISIBLE
70  std::string uniqueFilePath(const std::string &_pathAndName,
71  const std::string &_extension);
72 
79  IGNITION_GUI_VISIBLE
81 
88  template<class T>
89  T findFirstByProperty(const QList<T> _list, const char *_key,
90  QVariant _value)
91  {
92  for (const auto &w : _list)
93  {
94  if (w->property(_key) == _value)
95  return w;
96  }
97  return nullptr;
98  }
99  }
100 }
101 #endif
StringType
String types.
Definition: Enums.hh:46
std::string uniqueFilePath(const std::string &_pathAndName, const std::string &_extension)
Generates a path for a file which doesn&#39;t collide with existing files, by appending numbers to it (i...
StringType stringTypeFromKey(const std::string &_key)
Returns the string type for a given key. For example, the key "innerxml" has a PLAIN_TEXT type while ...
void rangeFromKey(const std::string &_key, double &_min, double &_max)
Returns the range for a given key. For example, the key "transparency" returns min == 0...
STL class.
QStringList worldNames()
The main window&#39;s "worldNames" property may be filled with a list of the names of all worlds currentl...
std::string unitFromKey(const std::string &_key, const std::string &_type="")
Returns the unit for a given key. For example, the key "mass" returns "kg".
T findFirstByProperty(const QList< T > _list, const char *_key, QVariant _value)
Returns the first element on a QList which matches the given property.
Definition: Helpers.hh:89
std::string humanReadable(const std::string &_key)
Create a human readable key, capitalizing the first letter and removing characters like "_"...
Definition: Application.hh:40