Make toOF/toQt more powerful and complete QtWidget
This commit is contained in:
parent
b37c5f6fc5
commit
d8f3aa90ec
24 changed files with 1047 additions and 385 deletions
|
@ -35,3 +35,20 @@
|
|||
- initWithType: (QChildEvent::Type)type
|
||||
child: (QtObject*)child;
|
||||
@end
|
||||
|
||||
namespace ObjQt {
|
||||
|
||||
static OF_INLINE QtChildEvent*
|
||||
toOF(QChildEvent *qChildEvent)
|
||||
{
|
||||
return [[[QtChildEvent alloc]
|
||||
initWithQChildEvent: qChildEvent] autorelease];
|
||||
}
|
||||
|
||||
static OF_INLINE QChildEvent*
|
||||
toQt(QtChildEvent *childEvent)
|
||||
{
|
||||
return [childEvent qChildEvent];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
#import "QtChildEvent.h"
|
||||
#import "QtObject.h"
|
||||
|
||||
using ObjQt::toOF;
|
||||
using ObjQt::toQt;
|
||||
|
||||
@implementation QtChildEvent
|
||||
- initWithQEvent: (QEvent*)event
|
||||
{
|
||||
|
@ -39,7 +42,7 @@
|
|||
{
|
||||
try {
|
||||
self = [self initWithQChildEvent:
|
||||
new QChildEvent(type, [child qObject])];
|
||||
new QChildEvent(type, toQt(child))];
|
||||
|
||||
[self takeOwnership];
|
||||
|
||||
|
@ -58,22 +61,21 @@
|
|||
|
||||
- (bool)isAdded
|
||||
{
|
||||
return [self qChildEvent]->added();
|
||||
return toQt(self)->added();
|
||||
}
|
||||
|
||||
- (QtObject*)child
|
||||
{
|
||||
return [[[QtObject alloc]
|
||||
initWithQObject: [self qChildEvent]->child()] autorelease];
|
||||
return toOF(toQt(self)->child());
|
||||
}
|
||||
|
||||
- (bool)isPolished
|
||||
{
|
||||
return [self qChildEvent]->polished();
|
||||
return toQt(self)->polished();
|
||||
}
|
||||
|
||||
- (bool)isRemoved
|
||||
{
|
||||
return [self qChildEvent]->removed();
|
||||
return toQt(self)->removed();
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -37,3 +37,20 @@
|
|||
- (bool)sendEvent: (QtEvent*)event
|
||||
receiver: (QtObject*)receiver;
|
||||
@end
|
||||
|
||||
namespace ObjQt {
|
||||
|
||||
static OF_INLINE QtCoreApplication*
|
||||
toOF(QCoreApplication *qCoreApplication)
|
||||
{
|
||||
return [[[QtCoreApplication alloc]
|
||||
initWithQCoreApplication: qCoreApplication] autorelease];
|
||||
}
|
||||
|
||||
static OF_INLINE QCoreApplication*
|
||||
toQt(QtCoreApplication *coreApplication)
|
||||
{
|
||||
return [coreApplication qCoreApplication];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,8 +22,10 @@
|
|||
|
||||
#import "QtCoreApplication.h"
|
||||
#import "QtEvent.h"
|
||||
#import "OFString+QString.h"
|
||||
|
||||
#import "helpers.h"
|
||||
using ObjQt::toOF;
|
||||
using ObjQt::toQt;
|
||||
|
||||
@implementation QtCoreApplication
|
||||
- initWithQObject: (QObject*)qObject
|
||||
|
@ -43,75 +45,72 @@
|
|||
|
||||
- (OFString*)applicationName
|
||||
{
|
||||
return toOF([self qCoreApplication]->applicationName());
|
||||
return toOF(toQt(self)->applicationName());
|
||||
}
|
||||
|
||||
- (void)setApplicationName: (OFString*)applicationName
|
||||
{
|
||||
[self qCoreApplication]->setApplicationName(toQt(applicationName));
|
||||
toQt(self)->setApplicationName(toQt(applicationName));
|
||||
}
|
||||
|
||||
- (OFString*)applicationVersion
|
||||
{
|
||||
return toOF([self qCoreApplication]->applicationVersion());
|
||||
return toOF(toQt(self)->applicationVersion());
|
||||
}
|
||||
|
||||
- (void)installNativeEventFilter: (QAbstractNativeEventFilter*)filterObject
|
||||
{
|
||||
[self qCoreApplication]->installNativeEventFilter(filterObject);
|
||||
toQt(self)->installNativeEventFilter(filterObject);
|
||||
}
|
||||
|
||||
- (void)setApplicationVersion: (OFString*)applicationVersion
|
||||
{
|
||||
[self qCoreApplication]->setApplicationVersion(
|
||||
toQt(applicationVersion));
|
||||
toQt(self)->setApplicationVersion(toQt(applicationVersion));
|
||||
}
|
||||
|
||||
- (OFString*)organizationDomain
|
||||
{
|
||||
return toOF([self qCoreApplication]->organizationDomain());
|
||||
return toOF(toQt(self)->organizationDomain());
|
||||
}
|
||||
|
||||
- (void)setOrganizationDomain: (OFString*)organizationDomain
|
||||
{
|
||||
[self qCoreApplication]->setOrganizationDomain(
|
||||
toQt(organizationDomain));
|
||||
toQt(self)->setOrganizationDomain(toQt(organizationDomain));
|
||||
}
|
||||
|
||||
- (OFString*)organizationName
|
||||
{
|
||||
return toOF([self qCoreApplication]->organizationName());
|
||||
return toOF(toQt(self)->organizationName());
|
||||
}
|
||||
|
||||
- (void)setOrganizationName: (OFString*)organizationName
|
||||
{
|
||||
[self qCoreApplication]->setOrganizationName(toQt(organizationName));
|
||||
toQt(self)->setOrganizationName(toQt(organizationName));
|
||||
}
|
||||
|
||||
- (void)quit
|
||||
{
|
||||
[self qCoreApplication]->quit();
|
||||
toQt(self)->quit();
|
||||
}
|
||||
|
||||
- (bool)isQuitLockEnabled
|
||||
{
|
||||
return [self qCoreApplication]->isQuitLockEnabled();
|
||||
return toQt(self)->isQuitLockEnabled();
|
||||
}
|
||||
|
||||
- (void)setQuitLockEnabled: (bool)quitLockEnabled
|
||||
{
|
||||
[self qCoreApplication]->setQuitLockEnabled(quitLockEnabled);
|
||||
toQt(self)->setQuitLockEnabled(quitLockEnabled);
|
||||
}
|
||||
|
||||
- (void)removeNativeEventFilter: (QAbstractNativeEventFilter*)filterObject
|
||||
{
|
||||
[self qCoreApplication]->removeNativeEventFilter(filterObject);
|
||||
toQt(self)->removeNativeEventFilter(filterObject);
|
||||
}
|
||||
|
||||
- (bool)sendEvent: (QtEvent*)event
|
||||
receiver: (QtObject*)receiver
|
||||
{
|
||||
return [self qCoreApplication]->notify(
|
||||
[receiver qObject], [event qEvent]);
|
||||
return toQt(self)->notify(toQt(receiver), toQt(event));
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -42,3 +42,19 @@
|
|||
- (void)accept;
|
||||
- (void)ignore;
|
||||
@end
|
||||
|
||||
namespace ObjQt {
|
||||
|
||||
static OF_INLINE QtEvent*
|
||||
toOF(QEvent *qEvent)
|
||||
{
|
||||
return [[[QtEvent alloc] initWithQEvent: qEvent] autorelease];
|
||||
}
|
||||
|
||||
static OF_INLINE QEvent*
|
||||
toQt(QtEvent *event)
|
||||
{
|
||||
return [event qEvent];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -80,3 +80,19 @@
|
|||
- (QtThread*)thread;
|
||||
- (void)deleteLater;
|
||||
@end
|
||||
|
||||
namespace ObjQt {
|
||||
|
||||
static OF_INLINE QtObject*
|
||||
toOF(QObject *qObject)
|
||||
{
|
||||
return [[[QtObject alloc] initWithQObject: qObject] autorelease];
|
||||
}
|
||||
|
||||
static OF_INLINE QObject*
|
||||
toQt(QtObject *object)
|
||||
{
|
||||
return [object qObject];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,11 +23,14 @@
|
|||
#import "QtObject.h"
|
||||
#import "QtEvent.h"
|
||||
#import "QtThread.h"
|
||||
|
||||
#import "helpers.h"
|
||||
#import "OFString+QString.h"
|
||||
#import "OFDataArray+QByteArray.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
using ObjQt::toOF;
|
||||
using ObjQt::toQt;
|
||||
|
||||
@implementation QtObject
|
||||
@synthesize qObject = _qObject;
|
||||
|
||||
|
@ -88,8 +91,7 @@
|
|||
void *pool = objc_autoreleasePoolPush();
|
||||
|
||||
for (QObject *qChild: qChildren)
|
||||
[children addObject:
|
||||
[[[QtObject alloc] initWithQObject: qChild] autorelease]];
|
||||
[children addObject: toOF(qChild)];
|
||||
|
||||
[children makeImmutable];
|
||||
|
||||
|
@ -103,7 +105,7 @@
|
|||
method: (OFString*)method
|
||||
type: (Qt::ConnectionType)type
|
||||
{
|
||||
return _qObject->connect([sender qObject],
|
||||
return _qObject->connect(toQt(sender),
|
||||
[signal UTF8String], [method UTF8String], type);
|
||||
}
|
||||
|
||||
|
@ -111,14 +113,14 @@
|
|||
receiver: (QtObject*)receiver
|
||||
method: (OFString*)method
|
||||
{
|
||||
return _qObject->disconnect([signal UTF8String], [receiver qObject],
|
||||
return _qObject->disconnect([signal UTF8String], toQt(receiver),
|
||||
[method UTF8String]);
|
||||
}
|
||||
|
||||
- (bool)disconnectAllSignalsForReceiver: (QtObject*)receiver
|
||||
method: (OFString*)method
|
||||
{
|
||||
return _qObject->disconnect([receiver qObject], [method UTF8String]);
|
||||
return _qObject->disconnect(toQt(receiver), [method UTF8String]);
|
||||
}
|
||||
|
||||
- (void)dumpObjectInfo
|
||||
|
@ -133,35 +135,31 @@
|
|||
|
||||
- (OFArray OF_GENERIC(OFDataArray*)*)dynamicPropertyNames
|
||||
{
|
||||
const QList<QByteArray> &qDynamicPropertyNames =
|
||||
const QList<QByteArray> &dynamicPropertyNames =
|
||||
_qObject->dynamicPropertyNames();
|
||||
OFMutableArray *dynamicPropertyNames =
|
||||
[OFMutableArray arrayWithCapacity: qDynamicPropertyNames.count()];
|
||||
OFMutableArray *ret =
|
||||
[OFMutableArray arrayWithCapacity: dynamicPropertyNames.count()];
|
||||
void *pool = objc_autoreleasePoolPush();
|
||||
|
||||
for (const QByteArray &qDynamicPropertyName: qDynamicPropertyNames) {
|
||||
OFDataArray *dynamicPropertyName = [OFDataArray dataArray];
|
||||
[dynamicPropertyName addItems: qDynamicPropertyName.data()
|
||||
count: qDynamicPropertyName.count()];
|
||||
[dynamicPropertyNames addObject: dynamicPropertyName];
|
||||
}
|
||||
for (const QByteArray &dynamicPropertyName: dynamicPropertyNames)
|
||||
[ret addObject: toOF(dynamicPropertyName)];
|
||||
|
||||
[dynamicPropertyNames makeImmutable];
|
||||
[ret makeImmutable];
|
||||
|
||||
objc_autoreleasePoolPop(pool);
|
||||
|
||||
return dynamicPropertyNames;
|
||||
return ret;
|
||||
}
|
||||
|
||||
- (bool)handleEvent: (QtEvent*)event
|
||||
{
|
||||
return _qObject->event([event qEvent]);
|
||||
return _qObject->event(toQt(event));
|
||||
}
|
||||
|
||||
- (bool)filterEvent: (QtEvent*)event
|
||||
forObject: (QtObject*)watched
|
||||
{
|
||||
return _qObject->eventFilter([watched qObject], [event qEvent]);
|
||||
return _qObject->eventFilter(toQt(watched), toQt(event));
|
||||
}
|
||||
|
||||
- (bool)inheritsClassWithName: (OFString*)className
|
||||
|
@ -171,7 +169,7 @@
|
|||
|
||||
- (void)installEventFilter: (QtObject*)filterObj
|
||||
{
|
||||
_qObject->installEventFilter([filterObj qObject]);
|
||||
_qObject->installEventFilter(toQt(filterObj));
|
||||
}
|
||||
|
||||
- (bool)isWidgetType
|
||||
|
@ -196,18 +194,17 @@
|
|||
|
||||
- (void)moveToThread: (QtThread*)targetThread
|
||||
{
|
||||
_qObject->moveToThread([targetThread qThread]);
|
||||
_qObject->moveToThread(toQt(targetThread));
|
||||
}
|
||||
|
||||
- (QtObject*)parent
|
||||
{
|
||||
return [[[QtObject alloc]
|
||||
initWithQObject: _qObject->parent()] autorelease];
|
||||
return toOF(_qObject->parent());
|
||||
}
|
||||
|
||||
- (void)setParent: (QtObject*)parent
|
||||
{
|
||||
_qObject->setParent([parent qObject]);
|
||||
_qObject->setParent(toQt(parent));
|
||||
}
|
||||
|
||||
- (QVariant)propertyForName: (OFString*)name
|
||||
|
@ -217,7 +214,7 @@
|
|||
|
||||
- (void)removeEventFilter: (QtObject*)obj
|
||||
{
|
||||
_qObject->removeEventFilter([obj qObject]);
|
||||
_qObject->removeEventFilter(toQt(obj));
|
||||
}
|
||||
|
||||
- (bool)setProperty: (QVariant&)value
|
||||
|
@ -239,8 +236,7 @@
|
|||
|
||||
- (QtThread*)thread
|
||||
{
|
||||
return [[[QtThread alloc]
|
||||
initWithQThread: _qObject->thread()] autorelease];
|
||||
return toOF(_qObject->thread());
|
||||
}
|
||||
|
||||
- (void)deleteLater
|
||||
|
|
|
@ -42,3 +42,19 @@
|
|||
- (void)startWithPriority: (QThread::Priority)priority;
|
||||
- (void)terminate;
|
||||
@end
|
||||
|
||||
namespace ObjQt {
|
||||
|
||||
static OF_INLINE QtThread*
|
||||
toOF(QThread *qThread)
|
||||
{
|
||||
return [[[QtThread alloc] initWithQThread: qThread] autorelease];
|
||||
}
|
||||
|
||||
static OF_INLINE QThread*
|
||||
toQt(QtThread *thread)
|
||||
{
|
||||
return [thread qThread];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#import "QtThread.h"
|
||||
|
||||
using ObjQt::toQt;
|
||||
|
||||
@implementation QtThread: QtObject
|
||||
- initWithQObject: (QObject*)qObject
|
||||
{
|
||||
|
@ -40,81 +42,81 @@
|
|||
|
||||
- (QAbstractEventDispatcher*)eventDispatcher
|
||||
{
|
||||
return [self qThread]->eventDispatcher();
|
||||
return toQt(self)->eventDispatcher();
|
||||
}
|
||||
|
||||
- (void)setEventDispatcher: (QAbstractEventDispatcher*)eventDispatcher
|
||||
{
|
||||
[self qThread]->setEventDispatcher(eventDispatcher);
|
||||
toQt(self)->setEventDispatcher(eventDispatcher);
|
||||
}
|
||||
|
||||
- (void)exitWithReturnCode: (int)returnCode
|
||||
{
|
||||
[self qThread]->exit(returnCode);
|
||||
toQt(self)->exit(returnCode);
|
||||
}
|
||||
|
||||
- (bool)isFinished
|
||||
{
|
||||
return [self qThread]->isFinished();
|
||||
return toQt(self)->isFinished();
|
||||
}
|
||||
|
||||
- (bool)isInterruptionRequested
|
||||
{
|
||||
return [self qThread]->isInterruptionRequested();
|
||||
return toQt(self)->isInterruptionRequested();
|
||||
}
|
||||
|
||||
- (bool)isRunning
|
||||
{
|
||||
return [self qThread]->isRunning();
|
||||
return toQt(self)->isRunning();
|
||||
}
|
||||
|
||||
- (int)loopLevel
|
||||
{
|
||||
return [self qThread]->loopLevel();
|
||||
return toQt(self)->loopLevel();
|
||||
}
|
||||
|
||||
- (QThread::Priority)priority
|
||||
{
|
||||
return [self qThread]->priority();
|
||||
return toQt(self)->priority();
|
||||
}
|
||||
|
||||
- (void)setPriority: (QThread::Priority)priority
|
||||
{
|
||||
[self qThread]->setPriority(priority);
|
||||
toQt(self)->setPriority(priority);
|
||||
}
|
||||
|
||||
- (void)requestInterruption
|
||||
{
|
||||
[self qThread]->requestInterruption();
|
||||
toQt(self)->requestInterruption();
|
||||
}
|
||||
|
||||
- (unsigned int)stackSize
|
||||
{
|
||||
return [self qThread]->stackSize();
|
||||
return toQt(self)->stackSize();
|
||||
}
|
||||
|
||||
- (void)setStackSize: (unsigned int)stackSize
|
||||
{
|
||||
[self qThread]->setStackSize(stackSize);
|
||||
toQt(self)->setStackSize(stackSize);
|
||||
}
|
||||
|
||||
- (bool)waitForMilliseconds: (unsigned long)time
|
||||
{
|
||||
return [self qThread]->wait(time);
|
||||
return toQt(self)->wait(time);
|
||||
}
|
||||
|
||||
- (void)quit
|
||||
{
|
||||
[self qThread]->quit();
|
||||
toQt(self)->quit();
|
||||
}
|
||||
|
||||
- (void)startWithPriority: (QThread::Priority)priority
|
||||
{
|
||||
[self qThread]->start(priority);
|
||||
toQt(self)->start(priority);
|
||||
}
|
||||
|
||||
- (void)terminate
|
||||
{
|
||||
[self qThread]->terminate();
|
||||
toQt(self)->terminate();
|
||||
}
|
||||
@end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue