/* Copyright 2006-2020 The QElectroTech Team This file is part of QElectroTech. QElectroTech is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. QElectroTech is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with QElectroTech. If not, see . */ #ifndef _QET_H #define _QET_H #include #include #include class QActionGroup; /** This file provides useful functions and enums that may be used from anywhere else within the QElectroTech application. */ namespace QET { /// QElectroTech version (as string, used to mark projects and elements XML documents) const QString version = "0.80"; /// QElectroTech displayed version const QString displayedVersion = "0.80-DEV"; QString license(); //Describe the current state of a graphic item enum GraphicsItemState { GIOK, /// findInDomElement(const QDomElement &, const QString &); QList findInDomElement(const QDomElement &, const QString &, const QString &); QList forbiddenCharacters(); QString stringToFileName(const QString &); QString escapeSpaces(const QString &); QString unescapeSpaces(const QString &); QString joinWithSpaces(const QStringList &); QStringList splitWithSpaces(const QString &); QString diagramAreaToString(const QET::DiagramArea &); QET::DiagramArea diagramAreaFromString(const QString &); qreal round(qreal, qreal); qreal correctAngle(const qreal &); bool compareCanonicalFilePaths(const QString &, const QString &); bool writeXmlFile(QDomDocument &xml_doc, const QString &filepath, QString * error_message= nullptr); bool writeToFile (QDomDocument &xml_doc, QFile *file, QString *error_message = nullptr); bool eachStrIsEqual (const QStringList &qsl); QActionGroup *depthActionGroup(QObject *parent = nullptr); } Q_DECLARE_METATYPE(QET::DepthOption) class Qet : public QObject { Q_OBJECT public: ///This enum lists the various available endings for line primitives when drawing an electrical element. enum EndType { None, ///< Regular line Simple, ///< Base-less triangle Triangle, ///< Triangle Circle, ///< Circle Diamond ///< Diamond }; Q_ENUM (EndType) static QString endTypeToString(const Qet::EndType &); static Qet::EndType endTypeFromString(const QString &); /// Orientation (used for electrical elements and their terminals) enum Orientation {North, East, South, West}; Q_ENUM (Orientation) static Qet::Orientation nextOrientation(Qet::Orientation); static Qet::Orientation previousOrientation(Qet::Orientation); static Qet::Orientation orientationFromString (const QString &); static QString orientationToString (Qet::Orientation); static bool surLeMemeAxe (Qet::Orientation, Qet::Orientation); static bool isOpposed (Qet::Orientation a, Qet::Orientation b); static bool isHorizontal (Qet::Orientation); static bool isVertical (Qet::Orientation); }; #endif