-////////////////////////////////////////////////////////////////////////
-// Mac OSX specific stuff goes here...
-
-#ifdef Q_WS_MACX
-namespace{
-
-OSErr checkAppleEventForMissingParams(const AppleEvent& theAppleEvent)
- {
- DescType returnedType;
- Size actualSize;
- OSErr err = AEGetAttributePtr(&theAppleEvent, keyMissedKeywordAttr,
- typeWildCard, &returnedType, nil, 0,
- &actualSize);
- switch (err) {
- case errAEDescNotFound:
- return noErr;
- case noErr:
- return errAEEventNotHandled;
- default:
- return err;
- }
- }
-
-} // namespace
-
-OSErr GuiApplication::handleOpenDocuments(const AppleEvent* inEvent,
- AppleEvent* /*reply*/, long /*refCon*/)
-{
- QString s_arg;
- AEDescList documentList;
- OSErr err = AEGetParamDesc(inEvent, keyDirectObject, typeAEList,
- &documentList);
- if (err != noErr)
- return err;
-
- err = checkAppleEventForMissingParams(*inEvent);
- if (err == noErr) {
- long documentCount;
- err = AECountItems(&documentList, &documentCount);
- for (long documentIndex = 1;
- err == noErr && documentIndex <= documentCount;
- documentIndex++) {
- DescType returnedType;
- Size actualSize;
- AEKeyword keyword;
- FSRef ref;
- char qstr_buf[1024];
- err = AESizeOfNthItem(&documentList, documentIndex,
- &returnedType, &actualSize);
- if (err == noErr) {
- err = AEGetNthPtr(&documentList, documentIndex,
- typeFSRef, &keyword,
- &returnedType, (Ptr)&ref,
- sizeof(FSRef), &actualSize);
- if (err == noErr) {
- FSRefMakePath(&ref, (UInt8*)qstr_buf,
- 1024);
- s_arg=QString::fromUtf8(qstr_buf);
-// bv->workAreaDispatch(
-// FuncRequest(LFUN_FILE_OPEN,
-// fromqstr(s_arg)));
- break;
- }
- }
- } // for ...
- }
- AEDisposeDesc(&documentList);
-
- return err;
-}
-
-bool GuiApplication::macEventFilter(EventRef event)
-{
- if (GetEventClass(event) == kEventClassAppleEvent) {
- EventRecord eventrec;
- ConvertEventRefToEventRecord(event, &eventrec);
- AEProcessAppleEvent(&eventrec);
-
- return false;
- }
- return false;
-}
-
-#endif // Q_WS_MACX
-