示例#1
0
QString QMacPasteboardMimeQt3Any::flavorFor(const QString &mime)
{
    const int os_flav = registerMimeType(mime);
    QCFType<CFArrayRef> ids = UTTypeCreateAllIdentifiersForTag(0, kUTTagClassOSType,
                                                               QCFString(UTCreateStringForOSType(os_flav)));
    if(ids) {
        const int type_count = CFArrayGetCount(ids);
        if(type_count) {
            if(type_count > 1)
                qDebug("Can't happen!");
            return QCFString::toQString((CFStringRef)CFArrayGetValueAtIndex(ids, 0));
        }
    }
    return QString();
}
示例#2
0
OSStatus DisplayAlert(CFStringRef error, CFStringRef explanation,
		      OSStatus status)
{
    DialogRef dialog;

    if (status == 0)
	CreateStandardAlert(kAlertStopAlert, error, explanation, NULL, &dialog);

    else
    {
	CFStringRef exp;

	if (status > 0)
	{
	    char s[8];

	    CFStringRef stat = UTCreateStringForOSType(status);
	    CFStringGetCString(stat, s, sizeof(s), kCFStringEncodingMacRoman);
	    CFRelease(stat);
    
	    exp =
		CFStringCreateWithFormat(kCFAllocatorDefault, NULL,
					 CFSTR("%s: '%s' (0x%x)"),
					 CFStringGetCStringPtr(explanation,
					     kCFStringEncodingMacRoman),
					 s, status);
	}

	else
	{
	    exp =
		CFStringCreateWithFormat(kCFAllocatorDefault, NULL,
					 CFSTR("%s: %d (0x%x)"),
					 CFStringGetCStringPtr(explanation,
					     kCFStringEncodingMacRoman),
					 status, status);
	}

	CreateStandardAlert(kAlertStopAlert, error, exp, NULL, &dialog);
    }

    SetWindowTitleWithCFString(GetDialogWindow(dialog), CFSTR("Accordion"));
    RunStandardAlert(dialog, NULL, NULL);

    return noErr;
}