File indexing completed on 2025-01-05 04:26:48

0001 /*
0002  * Replacement fot QT Bindings that were removed from QT5
0003  * Copyright (C) 2020  Pedro de Carvalho Gomes <pedrogomes81@gmail.com>
0004  *
0005  * This program 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 3 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, see <http://www.gnu.org/licenses/>.
0017  */
0018 
0019 #ifndef COREIODEVICE_H
0020 #define COREIODEVICE_H
0021 
0022 #include "QtBinding.h"
0023 
0024 #include <QIODevice>
0025 
0026 namespace QtBindings
0027 {
0028     namespace Core
0029     {
0030         class IODevice : public QObject, public QtBindings::Base<IODevice>
0031         {
0032         Q_OBJECT
0033         public:
0034             enum OpenModeFlag {
0035                 NotOpen = QIODevice::NotOpen,
0036                 ReadOnly = QIODevice::ReadOnly,
0037                 WriteOnly = QIODevice::WriteOnly,
0038                 ReadWrite = QIODevice::ReadOnly | WriteOnly,
0039                 Append = QIODevice::Append,
0040                 Truncate = QIODevice::Truncate,
0041                 Text = QIODevice::Text,
0042                 Unbuffered = QIODevice::Unbuffered,
0043                 // The following are not presetn at QT5.8 - Add as value for backward compatibility
0044                 NewOnly = 0x0040,
0045                 ExistingOnly = 0x0080
0046             };
0047             Q_FLAG(OpenModeFlag);
0048             IODevice();
0049             IODevice(const IODevice &other);
0050             ~IODevice();
0051             IODevice &operator=(const IODevice &other);
0052             static void installJSType( QJSEngine *engine );
0053         };
0054 
0055         /* MOC does not support nested classes - Had to hack it out */
0056         class OpenMode : public QObject, public QIODevice::OpenMode
0057         {
0058         Q_OBJECT
0059         public:
0060             Q_INVOKABLE OpenMode();
0061             Q_INVOKABLE OpenMode(const OpenMode& other);
0062             Q_INVOKABLE OpenMode(QIODevice::OpenMode flags);
0063             Q_INVOKABLE ~OpenMode();
0064             Q_INVOKABLE operator Int();
0065             OpenMode &operator=(const OpenMode& other);
0066         };
0067     }
0068 }
0069 Q_DECLARE_METATYPE(QtBindings::Core::IODevice)
0070 Q_DECLARE_METATYPE(QtBindings::Core::OpenMode)
0071 
0072 #endif //COREIODEVICE_H