diff --git a/src/gsiqt/gsiDeclQtBasic.cc b/src/gsiqt/gsiDeclQtBasic.cc deleted file mode 100644 index 86b89ebae..000000000 --- a/src/gsiqt/gsiDeclQtBasic.cc +++ /dev/null @@ -1,177 +0,0 @@ - -/* - - KLayout Layout Viewer - Copyright (C) 2006-2017 Matthias Koefferlein - - This program 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. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - - -#include "gsiQt.h" - -#include -#include -#include -#include -#include - -// ------------------------------------------------------------ -// Generic declarations for a pair - -namespace qt_gsi -{ - -template -struct pair_decl -{ - static typename qt_gsi::Converter::target_type pair_first(const QPair *pair) - { - return qt_gsi::Converter::toc (pair->first); - } - - static typename qt_gsi::Converter::target_type pair_second(const QPair *pair) - { - return qt_gsi::Converter::toc (pair->second); - } - - static void pair_set_first(QPair *pair, const typename qt_gsi::Converter::target_type &s) - { - pair->first = qt_gsi::Converter::toq (s); - } - - static void pair_set_second(QPair *pair, const typename qt_gsi::Converter::target_type &s) - { - pair->second = qt_gsi::Converter::toq (s); - } - - static bool pair_equal(const QPair *pair, const QPair &other) - { - return *pair == other; - } - - /* Not available for all types: - static bool pair_less(const QPair *pair, const QPair &other) - { - return *pair < other; - } - */ - - static QPair *pair_default_ctor() - { - return new QPair(); - } - - static QPair *pair_ctor(const typename qt_gsi::Converter::target_type &first, const typename qt_gsi::Converter::target_type &second) - { - return new QPair(qt_gsi::Converter::toq (first), qt_gsi::Converter::toq (second)); - } - - static gsi::Methods methods () - { - return - gsi::constructor("new", &pair_default_ctor, "@brief Creates a new pair") + - gsi::constructor("new", &pair_ctor, "@brief Creates a new pair from the given arguments\n@args first, second") + - gsi::method_ext("first", &pair_first, "@brief Returns the first element of the pair\n") + - gsi::method_ext("first=", &pair_set_first, "@brief Sets the first element of the pair\n@args first") + - gsi::method_ext("second", &pair_second, "@brief Returns the second element of the pair\n") + - gsi::method_ext("second=", &pair_set_second, "@brief Sets the second element of the pair\n@args second") + - gsi::method_ext("==", &pair_equal, "@brief Returns true if self is equal to the other pair\n@args other") - // not available for all types: - // gsi::method_ext("<", &pair_less, "@brief Returns true if self is less than the other pair\n@args other") - ; - } -}; - -} - -// ------------------------------------------------------------ -// Declarations for QPair - -gsi::Class > decl_QString_QPair ("QStringPair", - qt_gsi::pair_decl::methods (), - "@qt\\n@brief Represents a QPair" -); - -// ------------------------------------------------------------ -// Declarations for QPair - -gsi::Class > decl_QByteArray_QPair ("QByteArrayPair", - qt_gsi::pair_decl::methods (), - "@qt\\n@brief Represents a QPair" -); - -// ------------------------------------------------------------ -// Declarations for QPair - -gsi::Class > decl_double_QPair ("QDoublePair", - qt_gsi::pair_decl::methods (), - "@qt\\n@brief Represents a QPair" -); - -// ------------------------------------------------------------ -// Declarations for QPair - -gsi::Class > decl_double_QPointF_QPair ("QDoublePointFPair", - qt_gsi::pair_decl::methods (), - "@qt\\n@brief Represents a QPair" -); - -// ------------------------------------------------------------ -// Declarations for QPair - -gsi::Class > decl_double_QColor_QPair ("QDoubleColorPair", - qt_gsi::pair_decl::methods (), - "@qt\\n@brief Represents a QPair" -); - -// ------------------------------------------------------------ -// Declarations for QPair - -gsi::Class > decl_QHostAddress_int_QPair ("QHostAddressIntPair", - qt_gsi::pair_decl::methods (), - "@qt\\n@brief Represents a QPair" -); - -// ------------------------------------------------------------ -// Some helper functions - -namespace qt_gsi -{ - -std::vector -to_string_vector (const QStringList &sl) -{ - std::vector sv; - sv.reserve (sl.size ()); - for (QStringList::const_iterator s = sl.begin (); s != sl.end (); ++s) { - sv.push_back (tl::to_string (*s)); - } - return sv; -} - -QStringList -to_string_list (const std::vector &sv) -{ - QStringList sl; - for (std::vector::const_iterator s = sv.begin (); s != sv.end (); ++s) { - sl.push_back (tl::to_qstring (*s)); - } - return sl; -} - -} - diff --git a/src/gsiqt/gsiQt.cc b/src/gsiqt/gsiQt.cc deleted file mode 100644 index f384d4580..000000000 --- a/src/gsiqt/gsiQt.cc +++ /dev/null @@ -1,154 +0,0 @@ - -/* - - KLayout Layout Viewer - Copyright (C) 2006-2017 Matthias Koefferlein - - This program 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. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - - -#include "gsiQt.h" - -#include -#include -#include - -namespace qt_gsi -{ - -// --------------------------------------------------------------------------- -// QVariant::Type implementation -// (this type is not created automatically since QVariant is implemented implicitly) - -class QVariant_Namespace { }; - -// A dummy namespace "QVariant" -gsi::Class decl_QVariant_Namespace ("QVariant", - gsi::Methods(), - "@qt\n@brief This class represents the QVariant namespace"); - -static gsi::Enum decl_QVariant_Type_Enum ("QVariant_Type", - gsi::enum_const ("Invalid", QVariant::Invalid, "@brief Enum constant QVariant::Invalid") + - gsi::enum_const ("Bool", QVariant::Bool, "@brief Enum constant QVariant::Bool") + - gsi::enum_const ("Int", QVariant::Int, "@brief Enum constant QVariant::Int") + - gsi::enum_const ("UInt", QVariant::UInt, "@brief Enum constant QVariant::UInt") + - gsi::enum_const ("LongLong", QVariant::LongLong, "@brief Enum constant QVariant::LongLong") + - gsi::enum_const ("ULongLong", QVariant::ULongLong, "@brief Enum constant QVariant::ULongLong") + - gsi::enum_const ("Double", QVariant::Double, "@brief Enum constant QVariant::Double") + - gsi::enum_const ("Char", QVariant::Char, "@brief Enum constant QVariant::Char") + - gsi::enum_const ("Map", QVariant::Map, "@brief Enum constant QVariant::Map") + - gsi::enum_const ("List", QVariant::List, "@brief Enum constant QVariant::List") + - gsi::enum_const ("String", QVariant::String, "@brief Enum constant QVariant::String") + - gsi::enum_const ("StringList", QVariant::StringList, "@brief Enum constant QVariant::StringList") + - gsi::enum_const ("ByteArray", QVariant::ByteArray, "@brief Enum constant QVariant::ByteArray") + - gsi::enum_const ("BitArray", QVariant::BitArray, "@brief Enum constant QVariant::BitArray") + - gsi::enum_const ("Date", QVariant::Date, "@brief Enum constant QVariant::Date") + - gsi::enum_const ("Time", QVariant::Time, "@brief Enum constant QVariant::Time") + - gsi::enum_const ("DateTime", QVariant::DateTime, "@brief Enum constant QVariant::DateTime") + - gsi::enum_const ("Url", QVariant::Url, "@brief Enum constant QVariant::Url") + - gsi::enum_const ("Locale", QVariant::Locale, "@brief Enum constant QVariant::Locale") + - gsi::enum_const ("Rect", QVariant::Rect, "@brief Enum constant QVariant::Rect") + - gsi::enum_const ("RectF", QVariant::RectF, "@brief Enum constant QVariant::RectF") + - gsi::enum_const ("Size", QVariant::Size, "@brief Enum constant QVariant::Size") + - gsi::enum_const ("SizeF", QVariant::SizeF, "@brief Enum constant QVariant::SizeF") + - gsi::enum_const ("Line", QVariant::Line, "@brief Enum constant QVariant::Line") + - gsi::enum_const ("LineF", QVariant::LineF, "@brief Enum constant QVariant::LineF") + - gsi::enum_const ("Point", QVariant::Point, "@brief Enum constant QVariant::Point") + - gsi::enum_const ("PointF", QVariant::PointF, "@brief Enum constant QVariant::PointF") + - gsi::enum_const ("RegExp", QVariant::RegExp, "@brief Enum constant QVariant::RegExp") + - gsi::enum_const ("Hash", QVariant::Hash, "@brief Enum constant QVariant::Hash") + - gsi::enum_const ("LastCoreType", QVariant::LastCoreType, "@brief Enum constant QVariant::LastCoreType") + - gsi::enum_const ("Font", QVariant::Font, "@brief Enum constant QVariant::Font") + - gsi::enum_const ("Pixmap", QVariant::Pixmap, "@brief Enum constant QVariant::Pixmap") + - gsi::enum_const ("Brush", QVariant::Brush, "@brief Enum constant QVariant::Brush") + - gsi::enum_const ("Color", QVariant::Color, "@brief Enum constant QVariant::Color") + - gsi::enum_const ("Palette", QVariant::Palette, "@brief Enum constant QVariant::Palette") + - gsi::enum_const ("Icon", QVariant::Icon, "@brief Enum constant QVariant::Icon") + - gsi::enum_const ("Image", QVariant::Image, "@brief Enum constant QVariant::Image") + - gsi::enum_const ("Polygon", QVariant::Polygon, "@brief Enum constant QVariant::Polygon") + - gsi::enum_const ("Region", QVariant::Region, "@brief Enum constant QVariant::Region") + - gsi::enum_const ("Bitmap", QVariant::Bitmap, "@brief Enum constant QVariant::Bitmap") + - gsi::enum_const ("Cursor", QVariant::Cursor, "@brief Enum constant QVariant::Cursor") + - gsi::enum_const ("SizePolicy", QVariant::SizePolicy, "@brief Enum constant QVariant::SizePolicy") + - gsi::enum_const ("KeySequence", QVariant::KeySequence, "@brief Enum constant QVariant::KeySequence") + - gsi::enum_const ("Pen", QVariant::Pen, "@brief Enum constant QVariant::Pen") + - gsi::enum_const ("TextLength", QVariant::TextLength, "@brief Enum constant QVariant::TextLength") + - gsi::enum_const ("TextFormat", QVariant::TextFormat, "@brief Enum constant QVariant::TextFormat") + - gsi::enum_const ("Matrix", QVariant::Matrix, "@brief Enum constant QVariant::Matrix") + - gsi::enum_const ("Transform", QVariant::Transform, "@brief Enum constant QVariant::Transform") + - gsi::enum_const ("Matrix4x4", QVariant::Matrix4x4, "@brief Enum constant QVariant::Matrix4x4") + - gsi::enum_const ("Vector2D", QVariant::Vector2D, "@brief Enum constant QVariant::Vector2D") + - gsi::enum_const ("Vector3D", QVariant::Vector3D, "@brief Enum constant QVariant::Vector3D") + - gsi::enum_const ("Vector4D", QVariant::Vector4D, "@brief Enum constant QVariant::Vector4D") + - gsi::enum_const ("Quaternion", QVariant::Quaternion, "@brief Enum constant QVariant::Quaternion") + - gsi::enum_const ("LastGuiType", QVariant::LastGuiType, "@brief Enum constant QVariant::LastGuiType") + - gsi::enum_const ("UserType", QVariant::UserType, "@brief Enum constant QVariant::UserType") + - gsi::enum_const ("LastType", QVariant::LastType, "@brief Enum constant QVariant::LastType"), - "@qt\n@brief This class represents the QVariant::Type enum"); - -static gsi::QFlagsClass decl_QVariant_Type_Enums ("QVariant_QFlags_Type", - "@qt\n@brief This class represents the QFlags flag set"); - -// Inject the declarations into the parent -static gsi::ClassExt inject_QVariant_Type_Enum_in_parent (decl_QVariant_Type_Enum.defs ()); -static gsi::ClassExt decl_QVariant_Type_Enum_as_child (decl_QVariant_Type_Enum, "Type"); -static gsi::ClassExt decl_QVariant_Type_Enums_as_child (decl_QVariant_Type_Enums, "QFlags_Type"); - -// --------------------------------------------------------------------------- -// AbstractMethodCalledException implementation - -AbstractMethodCalledException::AbstractMethodCalledException (const char *method_name) - : tl::Exception (tl::to_string (QObject::tr ("Abstract method called (%s)")).c_str (), method_name) -{ - // .. nothing yet .. -} - -// --------------------------------------------------------------------------- -// QtObjectBase implementation - -void QtObjectBase::init(QObject *object) -{ - // This method is called whenever a QtObjectBase object is created as a GSI - // interface for a QObject. If there is a parent, we can make C++ hold the reference to that - // object, thus moving the ownership to the C++ parent. - if (object->parent ()) { - keep (); - } -} - -void QtObjectBase::init(QGraphicsItem *object) -{ - // This method is called whenever a QtObjectBase object is created as a GSI - // interface for a QGraphicsItem. If there is a parent, we can make C++ hold the reference to that - // object, thus moving the ownership to the C++ parent. - if (object->parentItem ()) { - keep (); - } -} - -void QtObjectBase::init(QGraphicsObject *object) -{ - // This method is called whenever a QtObjectBase object is created as a GSI - // interface for a QGraphicsObject. If there is a parent, we can make C++ hold the reference to that - // object, thus moving the ownership to the C++ parent. - if (object->parentItem () || object->parent ()) { - keep (); - } -} - -} - diff --git a/src/gsiqt/gsiqt.pro b/src/gsiqt/gsiqt.pro index 4c6e1857a..890459c7a 100644 --- a/src/gsiqt/gsiqt.pro +++ b/src/gsiqt/gsiqt.pro @@ -3,24 +3,15 @@ DESTDIR=$$OUT_PWD/.. include($$PWD/../klayout.pri) include(qtdecl.pro) +include($$PWD/../gsiqt_common/gsiqt_common.pri) DEFINES += MAKE_GSIQT_LIBRARY TEMPLATE = lib -SOURCES += \ - gsiQt.cc \ - gsiDeclQtBasic.cc \ - gsiQtHelper.cc - -HEADERS += \ - gsiQt.h \ - gsiQtCommon.h \ - gsiQtHelper.h - # NOTE: db is required since some bridges to db are provided (i.e db::Polygon) -INCLUDEPATH += ../tl ../gsi ../db -DEPENDPATH += ../tl ../gsi ../db +INCLUDEPATH += ../tl ../gsi ../db ../gsiqt_common +DEPENDPATH += ../tl ../gsi ../db ../gsiqt_common LIBS += -L$$DESTDIR -ltl -lgsi -ldb diff --git a/src/gsiqt5/gsiQt.h b/src/gsiqt5/gsiQt.h deleted file mode 100644 index cdf0b6ea3..000000000 --- a/src/gsiqt5/gsiQt.h +++ /dev/null @@ -1,453 +0,0 @@ - -/* - - KLayout Layout Viewer - Copyright (C) 2006-2017 Matthias Koefferlein - - This program 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. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - - -#ifndef _HDR_gsiQt -#define _HDR_gsiQt - -#include "gsiDecl.h" -#include "gsiSignals.h" -#include "gsiEnums.h" -#include "tlString.h" -#include "tlException.h" -#include "tlTypeTraits.h" -#include "tlHeap.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// contributes the WIN specific typedefs -#include - -class QGraphicsItem; -class QGraphicsObject; - -namespace qt_gsi -{ - -/** - * @brief A generic way to implement a method binding - * - * Using that way saves compile time and memory - */ -class GenericMethod : public gsi::MethodBase -{ -public: - GenericMethod (const char *name, const char *doc, bool is_const, void (*init_func)(GenericMethod *), void (*call_func)(const GenericMethod *, void *, gsi::SerialArgs &args, gsi::SerialArgs &ret)) - : gsi::MethodBase (name, doc, is_const, false), mp_init_func (init_func), mp_call_func (call_func), mp_set_callback_func (0) - { - } - - GenericMethod (const char *name, const char *doc, bool is_const, void (*init_func)(GenericMethod *), void (*call_func)(const GenericMethod *, void *, gsi::SerialArgs &args, gsi::SerialArgs &ret), void (*set_callback_func) (void *v, const gsi::Callback &cb)) - : gsi::MethodBase (name, doc, is_const, false), mp_init_func (init_func), mp_call_func (call_func), mp_set_callback_func (set_callback_func) - { - } - - virtual void initialize () - { - clear (); - (*mp_init_func) (this); - } - - virtual gsi::MethodBase *clone () const - { - return new GenericMethod (*this); - } - - virtual void call (void *cls, gsi::SerialArgs &args, gsi::SerialArgs &ret) const - { - (*mp_call_func) (this, cls, args, ret); - } - - virtual bool is_callback () const - { - return mp_set_callback_func != 0; - } - - virtual void set_callback (void *v, const gsi::Callback &cb) const - { - if (mp_set_callback_func) { - (*mp_set_callback_func) (v, cb); - } - } - -private: - void (*mp_init_func) (GenericMethod *self); - void (*mp_call_func) (const GenericMethod *self, void *cls, gsi::SerialArgs &args, gsi::SerialArgs &ret); - void (*mp_set_callback_func) (void *cls, const gsi::Callback &cb); -}; - -/** - * @brief A generic way to implement a static method binding - * - * Using that way saves compile time and memory - */ -class GenericStaticMethod : public gsi::StaticMethodBase -{ -public: - GenericStaticMethod (const char *name, const char *doc, void (*init_func)(GenericStaticMethod *), void (*call_func)(const GenericStaticMethod *self, gsi::SerialArgs &args, gsi::SerialArgs &ret)) - : gsi::StaticMethodBase (name, doc), mp_init_func (init_func), mp_call_func (call_func) - { - } - - virtual void initialize () - { - clear (); - (*mp_init_func) (this); - } - - virtual gsi::MethodBase *clone () const - { - return new GenericStaticMethod (*this); - } - - virtual void call (void *, gsi::SerialArgs &args, gsi::SerialArgs &ret) const - { - (*mp_call_func) (this, args, ret); - } - -private: - void (*mp_init_func) (GenericStaticMethod *self); - void (*mp_call_func) (const GenericStaticMethod *self, gsi::SerialArgs &args, gsi::SerialArgs &ret); -}; - -template struct Converter; - -template -class QtToCppAdaptor -{ -public: - typedef Converter converter_type; - typedef typename converter_type::target_type target_type; - typedef typename converter_type::source_type source_type; - - QtToCppAdaptor () - : mp_ref (0) - { - // .. nothing yet .. - } - - QtToCppAdaptor (const QtToCppAdaptor &d) - : m_qt (d.m_qt), mp_ref (d.mp_ref) - { - // .. nothing yet .. - } - - QtToCppAdaptor (const target_type &t) - : m_qt (converter_type::toq (t)), mp_ref (0) - { - // .. nothing yet .. - } - - QtToCppAdaptor (const target_type *t) - : m_qt (converter_type::toq (*t)), mp_ref (0) - { - // .. nothing yet .. - } - - QtToCppAdaptor (target_type &t) - : m_qt (converter_type::toq (t)), mp_ref (&t) - { - // .. nothing yet .. - } - - QtToCppAdaptor (target_type *t) - : m_qt (converter_type::toq (*t)), mp_ref (t) - { - // .. nothing yet .. - } - - ~QtToCppAdaptor () - { - if (mp_ref) { - *mp_ref = converter_type::toc (m_qt); - } - } - - source_type *ptr () - { - return &m_qt; - } - - source_type &ref () - { - return m_qt; - } - - const source_type *cptr () const - { - return &m_qt; - } - - const source_type &cref () const - { - return m_qt; - } - -private: - source_type m_qt; - target_type *mp_ref; -}; - -template -class CppToQtReadAdaptor -{ -public: - typedef Converter converter_type; - typedef typename converter_type::target_type target_type; - typedef typename converter_type::source_type source_type; - - CppToQtReadAdaptor () - : mp_ref (0) - { - // .. nothing yet .. - } - - CppToQtReadAdaptor (tl::Heap &heap, const source_type &qt) - { - mp_ref = new target_type (converter_type::toc (qt)); - heap.push (mp_ref); - } - - operator const target_type *() const - { - return mp_ref; - } - - operator const target_type &() const - { - return *mp_ref; - } - -private: - const target_type *mp_ref; - - CppToQtReadAdaptor (const CppToQtReadAdaptor &d); - CppToQtReadAdaptor &operator= (const CppToQtReadAdaptor &d); -}; - -template -class CppToQtAdaptor -{ -public: - typedef Converter converter_type; - typedef typename converter_type::target_type target_type; - typedef typename converter_type::source_type source_type; - - CppToQtAdaptor () - : mp_ref (0) - { - // .. nothing yet .. - } - - CppToQtAdaptor (const CppToQtAdaptor &d) - : m_t (d.m_t), mp_ref (d.mp_ref) - { - // .. nothing yet .. - } - - CppToQtAdaptor (const source_type &qt) - : m_t (converter_type::toc (qt)), mp_ref (0) - { - // .. nothing yet .. - } - - CppToQtAdaptor (source_type &qt) - : m_t (converter_type::toc (qt)), mp_ref (&qt) - { - // .. nothing yet .. - } - - ~CppToQtAdaptor () - { - if (mp_ref) { - *mp_ref = converter_type::toq (m_t); - } - } - - operator target_type *() - { - return &m_t; - } - - operator target_type &() - { - return m_t; - } - - operator const target_type *() const - { - return &m_t; - } - - operator const target_type &() const - { - return m_t; - } - -private: - target_type m_t; - source_type *mp_ref; -}; - -template -struct Converter -{ - typedef T source_type; - typedef T target_type; - static const T &toq (const T &v) { return v; } - static const T &toc (const T &v) { return v; } -}; - -template <> -struct Converter -{ -public: - typedef Qt::HANDLE source_type; - typedef size_t target_type; - static source_type toq (target_type c) { return source_type (c); } - static target_type toc (source_type qc) { return target_type (qc); } -}; - -template <> -struct Converter -{ -public: - typedef Q_PID source_type; - typedef size_t target_type; - static source_type toq (target_type c) { return source_type (c); } - static target_type toc (source_type qc) { return target_type (qc); } -}; - -template <> -struct Converter -{ -public: - typedef QChar source_type; - typedef unsigned int target_type; - static QChar toq (unsigned int c) { return QChar (c); } - static unsigned int toc (QChar qc) { return qc.unicode (); } -}; - -std::vector to_string_vector (const QStringList &sl); -QStringList to_string_list (const std::vector &sv); - -#ifdef _WIN32 - -template <> -struct Converter -{ -public: - typedef WId source_type; - typedef size_t target_type; - static source_type toq (target_type c) { return source_type (c); } - static target_type toc (source_type qc) { return target_type (qc); } -}; - -template <> -struct Converter -{ -public: - typedef HCURSOR source_type; - typedef size_t target_type; - static source_type toq (target_type c) { return source_type (c); } - static target_type toc (source_type qc) { return target_type (qc); } -}; - -template <> -struct Converter -{ -public: - typedef HFONT source_type; - typedef size_t target_type; - static source_type toq (target_type c) { return source_type (c); } - static target_type toc (source_type qc) { return target_type (qc); } -}; - -#endif - -class AbstractMethodCalledException - : public tl::Exception -{ -public: - AbstractMethodCalledException (const char *method_name); -}; - -class QtObjectBase - : public gsi::ObjectBase -{ -public: - void init (void *) - { - // fallback case: no particular initialization - } - - void init (QObject *object); - void init (QGraphicsItem *object); - void init (QGraphicsObject *object); -}; - -/** - * @brief An implementation helper for the "keep arg" feature - * This helper will call keep on the object or objects, hence passing - * ownership to the callee. - */ -template -inline void qt_keep (T *obj) -{ - QtObjectBase *qt_obj = dynamic_cast(obj); - if (qt_obj) { - qt_obj->keep (); - } -} - -template -inline void qt_keep (const QList &list) -{ - for (typename QList::const_iterator l = list.begin (); l != list.end (); ++l) { - qt_keep (*l); - } -} - -template -inline void qt_keep (const std::vector &list) -{ - for (typename std::vector::const_iterator l = list.begin (); l != list.end (); ++l) { - qt_keep (*l); - } -} - -// Using this macro on a variable will supress the "unused variable" or "unused argument" -// warning: -#define __SUPPRESS_UNUSED_WARNING(x) (void)(x) - -} - -#endif - diff --git a/src/gsiqt5/gsiQtCommon.h b/src/gsiqt5/gsiQtCommon.h deleted file mode 100644 index ebb74197e..000000000 --- a/src/gsiqt5/gsiQtCommon.h +++ /dev/null @@ -1,48 +0,0 @@ - -/* - - KLayout Layout Viewer - Copyright (C) 2006-2017 Matthias Koefferlein - - This program 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. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - - -#if !defined(HDR_gsiQtCommon_h) -# define HDR_gsiQtCommon_h - -# if defined _WIN32 || defined __CYGWIN__ - -# ifdef MAKE_GSIQT_LIBRARY -# define GSIQT_PUBLIC __declspec(dllexport) -# else -# define GSIQT_PUBLIC __declspec(dllimport) -# endif -# define GSIQT_LOCAL - -# else - -# if __GNUC__ >= 4 -# define GSIQT_PUBLIC __attribute__ ((visibility ("default"))) -# define GSIQT_LOCAL __attribute__ ((visibility ("hidden"))) -# else -# define GSIQT_PUBLIC -# define GSIQT_LOCAL -# endif - -# endif - -#endif diff --git a/src/gsiqt5/gsiqt5.pro b/src/gsiqt5/gsiqt5.pro index 81df94bcc..ad4780fad 100644 --- a/src/gsiqt5/gsiqt5.pro +++ b/src/gsiqt5/gsiqt5.pro @@ -3,22 +3,14 @@ DESTDIR=$$OUT_PWD/.. include($$PWD/../klayout.pri) include(qtdecl.pro) +include($$PWD/../gsiqt_common/gsiqt_common.pri) DEFINES += MAKE_GSIQT_LIBRARY TEMPLATE = lib -SOURCES += \ - gsiQt.cc \ - gsiQtBasic.cc \ - gsiQtAdditional.cc \ - -HEADERS += \ - gsiQt.h \ - gsiQtCommon.h - # NOTE: db is required since some bridges to db are provided (i.e db::Polygon) -INCLUDEPATH += ../tl ../gsi ../db -DEPENDPATH += ../tl ../gsi ../db +INCLUDEPATH += ../tl ../gsi ../db ../gsiqt_common +DEPENDPATH += ../tl ../gsi ../db ../gsiqt_common LIBS += -L$$DESTDIR -ltl -lgsi -ldb diff --git a/src/gsiqt5/gsiQtAdditional.cc b/src/gsiqt_common/gsiDeclQt5Basic.cc similarity index 99% rename from src/gsiqt5/gsiQtAdditional.cc rename to src/gsiqt_common/gsiDeclQt5Basic.cc index efdcba6f0..64e44c188 100644 --- a/src/gsiqt5/gsiQtAdditional.cc +++ b/src/gsiqt_common/gsiDeclQt5Basic.cc @@ -20,6 +20,7 @@ */ +#if QT_VERSION >= 0x050000 #include "gsiQt.h" @@ -88,11 +89,7 @@ class QUrlTwoFlagsClass : public gsi::Class, QUrlTwoFlags > { public: -#if QT_VERSION >= 0x050000 typedef typename QFlags::Int int_repr; -#else - typedef int int_repr; -#endif QUrlTwoFlagsClass (const std::string &name, const std::string &doc = std::string ()) : gsi::Class, QUrlTwoFlags > (name, methods (), doc) @@ -324,3 +321,4 @@ static gsi::ClassExt decl_QUrlTwoFlags_as_child (decl_QUrlTwoFlags, "Forma } +#endif diff --git a/src/gsiqt5/gsiQtBasic.cc b/src/gsiqt_common/gsiDeclQtBasic.cc similarity index 100% rename from src/gsiqt5/gsiQtBasic.cc rename to src/gsiqt_common/gsiDeclQtBasic.cc diff --git a/src/gsiqt5/gsiQt.cc b/src/gsiqt_common/gsiQt.cc similarity index 100% rename from src/gsiqt5/gsiQt.cc rename to src/gsiqt_common/gsiQt.cc diff --git a/src/gsiqt/gsiQt.h b/src/gsiqt_common/gsiQt.h similarity index 98% rename from src/gsiqt/gsiQt.h rename to src/gsiqt_common/gsiQt.h index b63f4dcd2..2f6da81c8 100644 --- a/src/gsiqt/gsiQt.h +++ b/src/gsiqt_common/gsiQt.h @@ -42,6 +42,11 @@ #include #include +#if QT_VERSION >= 0x050000 +// contributes the WIN specific typedefs +# include +#endif + class QGraphicsItem; class QGraphicsObject; @@ -401,6 +406,7 @@ public: static unsigned int toc (QChar qc) { return qc.unicode (); } }; +#if QT_VERSION < 0x050000 template <> struct Converter { @@ -410,6 +416,7 @@ public: static QBool toq (bool b) { return QBool (b); } static bool toc (QBool qb) { return qb; } }; +#endif std::vector to_string_vector (const QStringList &sl); QStringList to_string_list (const std::vector &sv); diff --git a/src/gsiqt/gsiQtCommon.h b/src/gsiqt_common/gsiQtCommon.h similarity index 100% rename from src/gsiqt/gsiQtCommon.h rename to src/gsiqt_common/gsiQtCommon.h diff --git a/src/gsiqt/gsiQtHelper.cc b/src/gsiqt_common/gsiQtHelper.cc similarity index 100% rename from src/gsiqt/gsiQtHelper.cc rename to src/gsiqt_common/gsiQtHelper.cc diff --git a/src/gsiqt/gsiQtHelper.h b/src/gsiqt_common/gsiQtHelper.h similarity index 100% rename from src/gsiqt/gsiQtHelper.h rename to src/gsiqt_common/gsiQtHelper.h diff --git a/src/gsiqt_common/gsiqt_common.pri b/src/gsiqt_common/gsiqt_common.pri new file mode 100644 index 000000000..30d1b661f --- /dev/null +++ b/src/gsiqt_common/gsiqt_common.pri @@ -0,0 +1,12 @@ + +SOURCES += \ + $$PWD/gsiQt.cc \ + $$PWD/gsiDeclQtBasic.cc \ + $$PWD/gsiDeclQt5Basic.cc \ + $$PWD/gsiQtHelper.cc + +HEADERS += \ + $$PWD/gsiQt.h \ + $$PWD/gsiQtCommon.h \ + $$PWD/gsiQtHelper.h + diff --git a/src/lay/lay.pro b/src/lay/lay.pro index 71b8c61b9..ad9da26fb 100644 --- a/src/lay/lay.pro +++ b/src/lay/lay.pro @@ -157,19 +157,23 @@ win32 { INCLUDEPATH += $$DESTDIR/laybasic DEPENDPATH += $$DESTDIR/laybasic -equals(HAVE_QTBINDINGS, "1") { - equals(HAVE_QT5, "1") { - INCLUDEPATH += ../gsiqt5 - DEPENDPATH += ../gsiqt5 - LIBS += -lgsiqt5 - } else { - INCLUDEPATH += ../gsiqt - DEPENDPATH += ../gsiqt - LIBS += -lgsiqt - } +# for gsiQtExternals.h: +equals(HAVE_QT5, "1") { + INCLUDEPATH += ../gsiqt5 + DEPENDPATH += ../gsiqt5 } else { - INCLUDEPATH += ../gsiqtstub - DEPENDPATH += ../gsiqtstub + INCLUDEPATH += ../gsiqt + DEPENDPATH += ../gsiqt +} + +equals(HAVE_QTBINDINGS, "1") { + INCLUDEPATH += ../gsiqt_common + DEPENDPATH += ../gsiqt_common + equals(HAVE_QT5, "1") { + LIBS += -lgsiqt5 + } else { + LIBS += -lgsiqt + } } equals(HAVE_RUBY, "1") { diff --git a/src/laybasic/laybasic.pro b/src/laybasic/laybasic.pro index 694a0e006..98bdcf3cc 100644 --- a/src/laybasic/laybasic.pro +++ b/src/laybasic/laybasic.pro @@ -276,18 +276,22 @@ INCLUDEPATH += ../tl ../gsi ../db ../rdb DEPENDPATH += ../tl ../gsi ../db ../rdb LIBS += -L$$DESTDIR -ltl -lgsi -ldb -lrdb -equals(HAVE_QTBINDINGS, "1") { - equals(HAVE_QT5, "1") { - INCLUDEPATH += ../gsiqt5 - DEPENDPATH += ../gsiqt5 - LIBS += -lgsiqt5 - } else { - INCLUDEPATH += ../gsiqt - DEPENDPATH += ../gsiqt - LIBS += -lgsiqt - } +# for gsiQtExternals.h: +equals(HAVE_QT5, "1") { + INCLUDEPATH += ../gsiqt5 + DEPENDPATH += ../gsiqt5 } else { - INCLUDEPATH += ../gsiqtstub - DEPENDPATH += ../gsiqtstub + INCLUDEPATH += ../gsiqt + DEPENDPATH += ../gsiqt +} + +equals(HAVE_QTBINDINGS, "1") { + INCLUDEPATH += ../gsiqt_common + DEPENDPATH += ../gsiqt_common + equals(HAVE_QT5, "1") { + LIBS += -lgsiqt5 + } else { + LIBS += -lgsiqt + } }