diff --git a/src/gsiqt/gsiQt.cc b/src/gsiqt/gsiQt.cc index ec84ffde5..f384d4580 100644 --- a/src/gsiqt/gsiQt.cc +++ b/src/gsiqt/gsiQt.cc @@ -117,39 +117,6 @@ AbstractMethodCalledException::AbstractMethodCalledException (const char *method // .. nothing yet .. } -// --------------------------------------------------------------------------- -// QtNativeClass implementation - -namespace -{ - /** - * @brief A tiny watcher object linking QObject and gsi::ObjectBase - * This object is hooked into the watched object's child list to watch it's lifetime. - */ - class QtWatcherObject - : public QObject, public gsi::ObjectBase - { - public: - QtWatcherObject (QObject *parent) - : QObject (parent), gsi::ObjectBase () - { - // .. nothing yet .. - } - }; -} - -/** - * @brief Attaches a watcher object to a native QObject - */ -gsi::ObjectBase *get_watcher_object (QObject *qobject, bool required) -{ - QtWatcherObject *watcher = qobject->findChild (); - if (! watcher && required) { - watcher = new QtWatcherObject (qobject); - } - return watcher; -} - // --------------------------------------------------------------------------- // QtObjectBase implementation diff --git a/src/gsiqt/gsiQtHelper.cc b/src/gsiqt/gsiQtHelper.cc new file mode 100644 index 000000000..24fa8977f --- /dev/null +++ b/src/gsiqt/gsiQtHelper.cc @@ -0,0 +1,41 @@ + +/* + + 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 "gsiQtHelper.h" + +namespace qt_gsi +{ + +/** + * @brief Attaches a watcher object to a native QObject + */ +gsi::ObjectBase *get_watcher_object (QObject *qobject, bool required) +{ + QtWatcherObject *watcher = qobject->findChild (); + if (! watcher && required) { + watcher = new QtWatcherObject (qobject); + } + return watcher; +} + +} + diff --git a/src/gsiqt/gsiQtHelper.h b/src/gsiqt/gsiQtHelper.h new file mode 100644 index 000000000..9dab7ed55 --- /dev/null +++ b/src/gsiqt/gsiQtHelper.h @@ -0,0 +1,54 @@ +/* + + 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_gsiQtHelper_h) +# define HDR_gsiQtHelper_h + +#include "gsiDecl.h" + +#include + +namespace qt_gsi +{ + +gsi::ObjectBase *get_watcher_object (QObject *qobject, bool required); + +/** + * @brief A tiny watcher object linking QObject and gsi::ObjectBase + * This object is hooked into the watched object's child list to watch it's lifetime. + */ +class QtWatcherObject + : public QObject, public gsi::ObjectBase +{ +Q_OBJECT + +public: + QtWatcherObject (QObject *parent) + : QObject (parent), gsi::ObjectBase () + { + // .. nothing yet .. + } +}; + +} + +#endif diff --git a/src/gsiqt/gsiqt.pro b/src/gsiqt/gsiqt.pro index c1fc345ef..4c6e1857a 100644 --- a/src/gsiqt/gsiqt.pro +++ b/src/gsiqt/gsiqt.pro @@ -11,10 +11,12 @@ TEMPLATE = lib SOURCES += \ gsiQt.cc \ gsiDeclQtBasic.cc \ + gsiQtHelper.cc HEADERS += \ gsiQt.h \ - gsiQtCommon.h + gsiQtCommon.h \ + gsiQtHelper.h # NOTE: db is required since some bridges to db are provided (i.e db::Polygon) INCLUDEPATH += ../tl ../gsi ../db