HAL  v4.5.0-131-gda71a6012
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
hal_qt_compat.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4 // Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5 // Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6 // Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #pragma once
27 
28 #include <QRect>
29 #include <QSet>
30 #include <QList>
31 #include <QVector>
32 #include <vector>
33 #include <QLayout>
34 #include <QStyleOption>
35 #include <QWidget>
36 #include <QPoint>
37 #include <QDateTime>
38 
39 namespace hal {
40  namespace QtCompat {
42 
44 
46 
47  uint qHashPoint(const QPoint& p);
48 
49  void styleOptionInit(QStyleOption& opt, QWidget* widget);
50 
51  void setMarginWidth(QLayout* layout, int marginWidth);
52 
54 
55  template<typename T> extern QSet<T> listToSet(const QList<T>& list)
56  {
57  #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
58  return QSet<T>(list.constBegin(),list.constEnd());
59  #else
60  return QSet<T>::fromList(list);
61  #endif
62  }
63 
64  template<typename T> extern QList<T> setToList(const QSet<T>& cset)
65  {
66 #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
67  return QList<T>(cset.constBegin(),cset.constEnd());
68 #else
69  return QList<T>::fromset(list);
70 #endif
71  }
72 
73  template<typename T> extern QVector<T> listToVector(const QList<T>& list)
74  {
75  #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
76  return QVector<T>(list.constBegin(),list.constEnd());
77  #else
78  return QVector<T>::fromList(list);
79  #endif
80  }
81 
82  template<typename T> extern QVector<T> stdVectorToVector(const std::vector<T>& vec)
83  {
84 #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
85  return QVector<T>(vec.begin(),vec.end());
86 #else
87  return QVector<T>::fromStdVector(vec);
88 #endif
89  }
90  }
91 }
QString dateToLocaleString(const QDateTime &dt)
QSet< T > listToSet(const QList< T > &list)
Definition: hal_qt_compat.h:55
QRect desktopAvailableGeometry()
QList< T > setToList(const QSet< T > &cset)
Definition: hal_qt_compat.h:64
QRect widgetAvailableGeometry(QWidget *widget)
uint qHashPoint(const QPoint &p)
QRect desktopScreenGeometry()
void setMarginWidth(QLayout *layout, int marginWidth)
QVector< T > listToVector(const QList< T > &list)
Definition: hal_qt_compat.h:73
QVector< T > stdVectorToVector(const std::vector< T > &vec)
Definition: hal_qt_compat.h:82
void styleOptionInit(QStyleOption &opt, QWidget *widget)
Definition: defines.h:45
QList::const_iterator constBegin() const const
QList::const_iterator constEnd() const const
QSet::const_iterator constBegin() const const
QSet::const_iterator constEnd() const const
QSet< T > fromList(const QList< T > &list)
QVector< T > fromList(const QList< T > &list)
QVector< T > fromStdVector(const std::vector< T > &vector)