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>
|
257
|
14 #include <QCryptographicHash>
|
253
|
15
|
257
|
16 extern "C" DLL_PUBLIC void* qtd_test_Object()
|
253
|
17 {
|
257
|
18 return new QCryptographicHash(QCryptographicHash::Md5);
|
|
19 }
|
|
20
|
|
21 extern "C" DLL_PUBLIC void qtd_test_delete_Object(void* obj)
|
|
22 {
|
|
23 delete (QCryptographicHash*)obj;
|
253
|
24 }
|
|
25
|
1
|
26 extern "C" DLL_PUBLIC QModelIndex qtd_to_QModelIndex(QModelIndexAccessor mia)
|
|
27 {
|
|
28 return * (QModelIndex *) (&mia) ;
|
|
29 }
|
|
30
|
|
31 extern "C" DLL_PUBLIC QModelIndexAccessor qtd_from_QModelIndex(const QModelIndex &index)
|
|
32 {
|
|
33 QModelIndexAccessor mia = {
|
|
34 index.row(),
|
|
35 index.column(),
|
|
36 index.internalPointer(),
|
|
37 (QAbstractItemModel *) index.model()
|
|
38 };
|
|
39
|
|
40 return mia;
|
|
41 }
|
|
42
|
247
|
43 extern "C" DLL_PUBLIC const char* qtd_qVersion()
|
|
44 {
|
|
45 return qVersion();
|
|
46 }
|
|
47
|
|
48 extern "C" DLL_PUBLIC bool qtd_qSharedBuild()
|
|
49 {
|
|
50 return qSharedBuild();
|
|
51 }
|
|
52
|
1
|
53 #ifdef CPP_SHARED
|
253
|
54 QTD_EXPORT_VAR(qtd_toUtf8);
|
|
55 QTD_EXPORT_VAR(qtd_dummy);
|
257
|
56 QTD_EXPORT_VAR(qtd_delete_d_object);
|
1
|
57
|
257
|
58 extern "C" DLL_PUBLIC void qtd_core_initCallBacks(pfunc_abstr d_func, pfunc_abstr dummy
|
|
59 , pfunc_abstr del_d_obj) {
|
253
|
60 QTD_EXPORT_VAR_SET(qtd_toUtf8, d_func);
|
|
61 QTD_EXPORT_VAR_SET(qtd_dummy, dummy);
|
257
|
62 QTD_EXPORT_VAR_SET(qtd_delete_d_object, del_d_obj);
|
253
|
63 //std::cout << "qtd_core initialized" << std::endl;
|
1
|
64 }
|
|
65 #endif
|
57
|
66
|
|
67 extern bool qRegisterResourceData
|
|
68 (int, const unsigned char *, const unsigned char *, const unsigned char *);
|
|
69
|
|
70 extern bool qUnregisterResourceData
|
|
71 (int, const unsigned char *, const unsigned char *, const unsigned char *);
|
|
72
|
|
73 extern "C" DLL_PUBLIC bool qtd_register_resource_data(int version, const unsigned char *tree,
|
|
74 const unsigned char *name, const unsigned char *data)
|
|
75 {
|
|
76 return qRegisterResourceData(version, tree, name, data);
|
|
77 }
|
|
78
|
|
79 extern "C" DLL_PUBLIC bool qtd_unregister_resource_data(int version, const unsigned char *tree,
|
|
80 const unsigned char *name, const unsigned char *data)
|
|
81 {
|
|
82 return qUnregisterResourceData(version, tree, name, data);
|
|
83 }
|
257
|
84
|
|
85
|
|
86 QtD_QObjectEntity::QtD_QObjectEntity(QObject *qObject, void *dId) : QtD_Entity(dId)
|
|
87 {
|
|
88 qObject->setUserData(userDataId, this);
|
|
89 }
|
|
90
|
|
91 QtD_QObjectEntity::~QtD_QObjectEntity()
|
|
92 {
|
|
93 if (dId)
|
|
94 destroyEntity();
|
|
95 }
|
|
96
|
|
97 void QtD_QObjectEntity::destroyEntity(QObject *qObject)
|
|
98 {
|
|
99 Q_ASSERT(dId);
|
|
100 qtd_delete_d_object(dId);
|
|
101 if (qObject)
|
|
102 {
|
|
103 qObject->setUserData(userDataId, NULL);
|
|
104 dId = NULL;
|
|
105 }
|
|
106 }
|
|
107
|
|
108 QtD_QObjectEntity* QtD_QObjectEntity::getQObjectEntity(const QObject *qObject)
|
|
109 {
|
|
110 return static_cast<QtD_QObjectEntity*>(qObject->userData(userDataId));
|
|
111 }
|