| 1 | /* Copyright (C) 2016 - 2017 Dan Chapman <[email protected]> |
| 2 | |
| 3 | This file is part of Dekko email client for Ubuntu devices |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU General Public License as |
| 7 | published by the Free Software Foundation; either version 2 of |
| 8 | the License or (at your option) version 3 |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | #include "Introspector.h" |
| 19 | |
| 20 | #include <QMetaObject> |
| 21 | |
| 22 | Introspector::Introspector (QObject * parent) : QObject (parent) { } |
| 23 | |
| 24 | QObject * Introspector::qmlSingletonProvider (QQmlEngine * qmlEngine, QJSEngine * jsEngine) { |
| 25 | Q_UNUSED (qmlEngine) |
| 26 | Q_UNUSED (jsEngine) |
| 27 | return new Introspector; |
| 28 | } |
| 29 | |
| 30 | bool Introspector::inherits (QObject * object, QObject * reference) { |
| 31 | bool ret = false; |
| 32 | if (object != Q_NULLPTR && reference != Q_NULLPTR) { |
| 33 | const QString objectClass = QString::fromLatin1 (object->metaObject ()->className ()); |
| 34 | const QString referenceClass = QString::fromLatin1 (reference->metaObject ()->className ()); |
| 35 | ret = (objectClass == referenceClass); |
| 36 | if (!ret) { |
| 37 | ret = object->inherits (reference->metaObject ()->className ()); |
| 38 | } |
| 39 | } |
| 40 | return ret; |
| 41 | } |
| 42 | |
| 43 | QQuickWindow * Introspector::window (QQuickItem * item) { |
| 44 | return (item != Q_NULLPTR ? item->window () : Q_NULLPTR); |
| 45 | } |