File indexing completed on 2024-05-12 05:39:54

0001 /***************************************************************************
0002  *  Copyright (C) 2020 by Renaud Guezennec                               *
0003  *   http://www.rolisteam.org/contact                                      *
0004  *                                                                         *
0005  *   This software is free software; you can redistribute it and/or modify *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 #ifndef CONVERTIONHELPER_H
0021 #define CONVERTIONHELPER_H
0022 
0023 #include <QColor>
0024 #include <QDataStream>
0025 #include <QFont>
0026 #include <QImage>
0027 #include <QPointF>
0028 #include <QRectF>
0029 #include <QSize>
0030 #include <QPainterPath>
0031 
0032 #include "controller/view_controller/sharednotecontroller.h"
0033 #include "data/charactervision.h"
0034 #include "media/mediatype.h"
0035 #include "mindmap/data/mindmaptypes.h"
0036 #include "network/networkmessagewriter.h"
0037 #include <core_global.h>
0038 
0039 namespace Helper
0040 {
0041 template <typename T>
0042 void variantToType(const T& val, NetworkMessageWriter& msg)
0043 {
0044     msg.string32(val);
0045 }
0046 
0047 template <>
0048 CORE_EXPORT void variantToType<bool>(const bool& val, NetworkMessageWriter& msg);
0049 template <>
0050 CORE_EXPORT void variantToType<qreal>(const qreal& val, NetworkMessageWriter& msg);
0051 template <>
0052 CORE_EXPORT void variantToType<int>(const int& val, NetworkMessageWriter& msg);
0053 template <>
0054 CORE_EXPORT void variantToType<Core::ScaleUnit>(const Core::ScaleUnit& val, NetworkMessageWriter& msg);
0055 template <>
0056 CORE_EXPORT void variantToType<Core::PermissionMode>(const Core::PermissionMode& val, NetworkMessageWriter& msg);
0057 template <>
0058 CORE_EXPORT void variantToType<Core::GridPattern>(const Core::GridPattern& val, NetworkMessageWriter& msg);
0059 template <>
0060 CORE_EXPORT void variantToType<Core::Layer>(const Core::Layer& val, NetworkMessageWriter& msg);
0061 template <>
0062 CORE_EXPORT void variantToType<Core::VisibilityMode>(const Core::VisibilityMode& val, NetworkMessageWriter& msg);
0063 template <>
0064 CORE_EXPORT void variantToType<QColor>(const QColor& val, NetworkMessageWriter& msg);
0065 template <>
0066 CORE_EXPORT void variantToType<QImage>(const QImage& val, NetworkMessageWriter& msg);
0067 template <>
0068 CORE_EXPORT void variantToType<QPointF>(const QPointF& val, NetworkMessageWriter& msg);
0069 template <>
0070 CORE_EXPORT void variantToType<QRectF>(const QRectF& val, NetworkMessageWriter& msg);
0071 template <>
0072 CORE_EXPORT void variantToType<quint16>(const quint16& val, NetworkMessageWriter& msg);
0073 template <>
0074 CORE_EXPORT void variantToType<QByteArray>(const QByteArray& val, NetworkMessageWriter& msg);
0075 template <>
0076 CORE_EXPORT void variantToType<QFont>(const QFont& val, NetworkMessageWriter& msg);
0077 template <>
0078 CORE_EXPORT void variantToType<std::vector<QPointF>>(const std::vector<QPointF>& val, NetworkMessageWriter& msg);
0079 template <>
0080 CORE_EXPORT void variantToType<CharacterVision::SHAPE>(const CharacterVision::SHAPE& shape, NetworkMessageWriter& msg);
0081 template <>
0082 CORE_EXPORT void variantToType<QSize>(const QSize& size, NetworkMessageWriter& msg);
0083 template <>
0084 CORE_EXPORT void variantToType<ParticipantModel::Permission>(const ParticipantModel::Permission& perm,
0085                                                              NetworkMessageWriter& msg);
0086 template <>
0087 CORE_EXPORT void variantToType<mindmap::ArrowDirection>(const mindmap::ArrowDirection& perm, NetworkMessageWriter& msg);
0088 template <>
0089 CORE_EXPORT void variantToType<QPainterPath>(const QPainterPath& val, NetworkMessageWriter& msg);
0090 } // namespace Helper
0091 
0092 #endif // CONVERTIONHELPER_H