1
|
1 /**
|
|
2 *
|
|
3 * Copyright: Copyright QtD Team, 2008-2009
|
|
4 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>
|
|
5 *
|
|
6 * Copyright QtD Team, 2008-2009
|
|
7 * Distributed under the Boost Software License, Version 1.0.
|
|
8 * (See accompanying file boost-license-1.0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
9 *
|
|
10 */
|
|
11
|
|
12 #include "qtd_core.h"
|
|
13 #include <iostream>
|
253
|
14
|
1
|
15 extern "C" DLL_PUBLIC QModelIndex qtd_to_QModelIndex(QModelIndexAccessor mia)
|
|
16 {
|
|
17 return * (QModelIndex *) (&mia) ;
|
|
18 }
|
|
19
|
|
20 extern "C" DLL_PUBLIC QModelIndexAccessor qtd_from_QModelIndex(const QModelIndex &index)
|
|
21 {
|
|
22 QModelIndexAccessor mia = {
|
|
23 index.row(),
|
|
24 index.column(),
|
|
25 index.internalPointer(),
|
|
26 (QAbstractItemModel *) index.model()
|
|
27 };
|
|
28
|
|
29 return mia;
|
|
30 }
|
|
31
|
247
|
32 extern "C" DLL_PUBLIC const char* qtd_qVersion()
|
|
33 {
|
|
34 return qVersion();
|
|
35 }
|
|
36
|
|
37 extern "C" DLL_PUBLIC bool qtd_qSharedBuild()
|
|
38 {
|
|
39 return qSharedBuild();
|
|
40 }
|
|
41
|
1
|
42 #ifdef CPP_SHARED
|
253
|
43 QTD_EXPORT_VAR(qtd_toUtf8);
|
|
44 QTD_EXPORT_VAR(qtd_dummy);
|
257
|
45 QTD_EXPORT_VAR(qtd_delete_d_object);
|
1
|
46
|
257
|
47 extern "C" DLL_PUBLIC void qtd_core_initCallBacks(pfunc_abstr d_func, pfunc_abstr dummy
|
|
48 , pfunc_abstr del_d_obj) {
|
253
|
49 QTD_EXPORT_VAR_SET(qtd_toUtf8, d_func);
|
|
50 QTD_EXPORT_VAR_SET(qtd_dummy, dummy);
|
257
|
51 QTD_EXPORT_VAR_SET(qtd_delete_d_object, del_d_obj);
|
253
|
52 //std::cout << "qtd_core initialized" << std::endl;
|
1
|
53 }
|
|
54 #endif
|
57
|
55
|
|
56 extern bool qRegisterResourceData
|
|
57 (int, const unsigned char *, const unsigned char *, const unsigned char *);
|
|
58
|
|
59 extern bool qUnregisterResourceData
|
|
60 (int, const unsigned char *, const unsigned char *, const unsigned char *);
|
|
61
|
|
62 extern "C" DLL_PUBLIC bool qtd_register_resource_data(int version, const unsigned char *tree,
|
|
63 const unsigned char *name, const unsigned char *data)
|
|
64 {
|
|
65 return qRegisterResourceData(version, tree, name, data);
|
|
66 }
|
|
67
|
|
68 extern "C" DLL_PUBLIC bool qtd_unregister_resource_data(int version, const unsigned char *tree,
|
|
69 const unsigned char *name, const unsigned char *data)
|
|
70 {
|
|
71 return qUnregisterResourceData(version, tree, name, data);
|
|
72 }
|
257
|
73
|
|
74
|
|
75 QtD_QObjectEntity::QtD_QObjectEntity(QObject *qObject, void *dId) : QtD_Entity(dId)
|
|
76 {
|
|
77 qObject->setUserData(userDataId, this);
|
|
78 }
|
|
79
|
|
80 QtD_QObjectEntity::~QtD_QObjectEntity()
|
|
81 {
|
|
82 if (dId)
|
|
83 destroyEntity();
|
|
84 }
|
|
85
|
|
86 void QtD_QObjectEntity::destroyEntity(QObject *qObject)
|
|
87 {
|
|
88 Q_ASSERT(dId);
|
|
89 qtd_delete_d_object(dId);
|
|
90 if (qObject)
|
|
91 {
|
|
92 qObject->setUserData(userDataId, NULL);
|
|
93 dId = NULL;
|
|
94 }
|
|
95 }
|
|
96
|
|
97 QtD_QObjectEntity* QtD_QObjectEntity::getQObjectEntity(const QObject *qObject)
|
|
98 {
|
|
99 return static_cast<QtD_QObjectEntity*>(qObject->userData(userDataId));
|
|
100 }
|