QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
qetutils.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef QETUTILS_H
19#define QETUTILS_H
20
21#include <QMargins>
22#include <QWeakPointer>
23
24class QGraphicsItem;
25
29namespace QETUtils
30{
31 QString marginsToString(const QMargins &margins);
32 QMargins marginsFromString(const QString &string);
33 qreal graphicsHandlerSize(QGraphicsItem *item);
34
35 bool sortBeginIntString(const QString &str_a, const QString &str_b);
36
37 template <typename T>
38 QVector<QWeakPointer<T>> sharedVectorToWeak(const QVector<QSharedPointer<T>> &vector)
39 {
40 QVector<QWeakPointer<T>> return_vector;
41 for (const auto shared : vector) {
42 return_vector.append(shared.toWeakRef());
43 }
44 return return_vector;
45 }
46
47
48 template <typename T>
49 QVector<QSharedPointer<T>> weakVectorToShared(const QVector<QWeakPointer<T>> &vector)
50 {
51 QVector<QSharedPointer<T>> return_vector;
52 for (const auto weak : vector) {
53 return_vector.append(weak.toStrongRef());
54 }
55 return return_vector;
56 }
57}
58
59#endif // QETUTILS_H
Definition qetutils.h:30
QString marginsToString(const QMargins &margins)
QETUtils::marginsToString.
Definition qetutils.cpp:30
bool sortBeginIntString(const QString &str_a, const QString &str_b)
QETUtils::sortBeginIntString Sort the string str_a and str_b and take in count if string begin with a...
Definition qetutils.cpp:106
QVector< QWeakPointer< T > > sharedVectorToWeak(const QVector< QSharedPointer< T > > &vector)
Definition qetutils.h:38
qreal graphicsHandlerSize(QGraphicsItem *item)
QETUtils::graphicsHandlerSize.
Definition qetutils.cpp:70
QMargins marginsFromString(const QString &string)
QETUtils::marginsFromString.
Definition qetutils.cpp:49
QVector< QSharedPointer< T > > weakVectorToShared(const QVector< QWeakPointer< T > > &vector)
Definition qetutils.h:49