ArnLib  4.0.x
Active Registry Network
ArnQmlMQt.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2022 Michael Wiklund.
2 // All rights reserved.
3 // Contact: arnlib@wiklunden.se
4 //
5 // This file is part of the ArnLib - Active Registry Network.
6 // Parts of ArnLib depend on Qt and/or other libraries that have their own
7 // licenses. Usage of these other libraries is subject to their respective
8 // license agreements.
9 //
10 // The MIT License (MIT) Usage
11 // Permission is hereby granted, free of charge, to any person obtaining a
12 // copy of this file to deal in its contained Software without restriction,
13 // including without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to permit
15 // persons to whom the Software is furnished to do so, subject to the
16 // following conditions:
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software in this file.
19 //
20 // GNU Lesser General Public License Usage
21 // This file may be used under the terms of the GNU Lesser General Public
22 // License version 2.1 as published by the Free Software Foundation and
23 // appearing in the file LICENSE_LGPL.txt included in the packaging of this
24 // file. In addition, as a special exception, you may use the rights described
25 // in the Nokia Qt LGPL Exception version 1.1, included in the file
26 // LGPL_EXCEPTION.txt in this package.
27 //
28 // GNU General Public License Usage
29 // Alternatively, this file may be used under the terms of the GNU General Public
30 // License version 3.0 as published by the Free Software Foundation and appearing
31 // in the file LICENSE_GPL.txt included in the packaging of this file.
32 //
33 // Other Usage
34 // Alternatively, this file may be used in accordance with the terms and conditions
35 // contained in a signed written agreement between you and Michael Wiklund.
36 //
37 // This program is distributed in the hope that it will be useful, but WITHOUT ANY
38 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
39 // PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
40 //
41 
42 #include "ArnInc/ArnQmlMQt.hpp"
43 
44 
45 namespace Arn {
46 
48  : QObject(parent)
49 {
50 }
51 
52 
54 {
55 }
56 
57 
59 {
60  return static_cast<QmlMQtObject*>( parent());
61 }
62 
63 
65 {
66  setParent( parent);
67  emit parentChanged( this);
68 }
69 
70 
71 QML_LIST_PROPERTY<QObject> QmlMQtObject::data()
72 {
73  return QML_LIST_PROPERTY<QObject>( this, arnNullptr, data_append, data_count, data_at, data_clear);
74 }
75 
76 
77 void QmlMQtObject::data_append( QML_LIST_PROPERTY<QObject>* prop, QObject* obj)
78 {
79  if (!obj) return;
80 
81  QmlMQtObject* that = static_cast<QmlMQtObject*>( prop->object);
82  obj->setParent( that);
83 }
84 
85 
86 ARN_SIZETYPE QmlMQtObject::data_count( QML_LIST_PROPERTY<QObject>* prop)
87 {
88  QmlMQtObject* that = static_cast<QmlMQtObject*>( prop->object);
89  return that->children().count();
90 }
91 
92 
93 QObject* QmlMQtObject::data_at( QML_LIST_PROPERTY<QObject>* prop, ARN_SIZETYPE index)
94 {
95  QmlMQtObject* that = static_cast<QmlMQtObject*>( prop->object);
96  if ((index >= 0) && (index < that->children().count()))
97  return that->children().at( index);
98  else
99  return arnNullptr;
100 }
101 
102 
103 void QmlMQtObject::data_clear(QML_LIST_PROPERTY<QObject>* prop)
104 {
105  QmlMQtObject* that = static_cast<QmlMQtObject*>( prop->object);
106  const QObjectList& children = that->children();
107  int childCount = children.count();
108  for (int index = 0; index < childCount; ++index)
109  children.at(0)->setParent( arnNullptr);
110 }
111 
112 
114 {
115 }
116 
117 
119 {
120  emit completed();
121 }
122 
123 } // Arn::
void parentChanged(QmlMQtObject *obj)
virtual ~QmlMQtObject()
Definition: ArnQmlMQt.cpp:53
#define ARN_SIZETYPE
Definition: ArnCompat.hpp:75
virtual void componentComplete()
Definition: ArnQmlMQt.cpp:118
static void data_clear(QML_LIST_PROPERTY< QObject > *prop)
Definition: ArnQmlMQt.cpp:103
QmlMQtObject parent
Definition: ArnQmlMQt.hpp:63
static QObject * data_at(QML_LIST_PROPERTY< QObject > *prop, ARN_SIZETYPE index)
Definition: ArnQmlMQt.cpp:93
void setParentItem(QmlMQtObject *parent)
Definition: ArnQmlMQt.cpp:64
static ARN_SIZETYPE data_count(QML_LIST_PROPERTY< QObject > *prop)
Definition: ArnQmlMQt.cpp:86
QmlMQtObject(QmlMQtObject *parent=arnNullptr)
Definition: ArnQmlMQt.cpp:47
Definition: Arn.cpp:43
static void data_append(QML_LIST_PROPERTY< QObject > *prop, QObject *obj)
Definition: ArnQmlMQt.cpp:77
QML_LIST_PROPERTY< QObject > data()
virtual void classBegin()
Definition: ArnQmlMQt.cpp:113
QmlMQtObject * parentItem() const
Definition: ArnQmlMQt.cpp:58