Move QString <-> NSString conversion to QtCore
Add (private) API to QCFString: static QString toQString(NSString *) static NSString *toNSString(const QString &) Add implementation to qcore_mac_objc.mm. Keep the mac_cpp since it's used for building qmake as well as bootstrapping. Replace usage of NSString conversion functions in the cocoa and corewlan plugin with QCFString. Change-Id: I9f34edd5231255aef9d8d6e9a60306174bb279b3 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
This commit is contained in:
parent
319ba95c76
commit
ae664f7dc7
@ -35,6 +35,7 @@ mac|darwin {
|
||||
contains(QT_CONFIG, coreservices) {
|
||||
LIBS_PRIVATE += -framework ApplicationServices
|
||||
LIBS_PRIVATE += -framework CoreServices
|
||||
LIBS_PRIVATE += -framework Foundation
|
||||
}
|
||||
LIBS_PRIVATE += -framework CoreFoundation
|
||||
}
|
||||
|
@ -90,6 +90,8 @@ mac {
|
||||
mac:!nacl {
|
||||
SOURCES += \
|
||||
kernel/qcore_mac.cpp
|
||||
OBJECTIVE_SOURCES += \
|
||||
kernel/qcore_mac_objc.mm
|
||||
}
|
||||
|
||||
nacl {
|
||||
|
54
src/corelib/kernel/qcore_mac_objc.mm
Normal file
54
src/corelib/kernel/qcore_mac_objc.mm
Normal file
@ -0,0 +1,54 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <private/qcore_mac_p.h>
|
||||
|
||||
NSString *QCFString::toNSString(const QString &string)
|
||||
{
|
||||
// The const cast below is safe: CfStringRef is immutable and so is NSString.
|
||||
return [const_cast<NSString *>(reinterpret_cast<const NSString *>(toCFStringRef(string))) autorelease];
|
||||
}
|
||||
|
||||
QString QCFString::toQString(const NSString *nsstr)
|
||||
{
|
||||
return toQString(reinterpret_cast<CFStringRef>(nsstr));
|
||||
}
|
||||
|
@ -78,6 +78,10 @@
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#endif
|
||||
|
||||
#ifdef __OBJC__
|
||||
#include <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#undef DEBUG
|
||||
#ifdef OLD_DEBUG
|
||||
# define DEBUG OLD_DEBUG
|
||||
@ -144,6 +148,11 @@ public:
|
||||
operator CFStringRef() const;
|
||||
static QString toQString(CFStringRef cfstr);
|
||||
static CFStringRef toCFStringRef(const QString &str);
|
||||
#ifdef __OBJC__
|
||||
static QString toQString(const NSString *nsstr);
|
||||
static NSString *toNSString(const QString &string);
|
||||
#endif
|
||||
|
||||
private:
|
||||
QString string;
|
||||
};
|
||||
|
@ -86,9 +86,6 @@ static const char *languageForWritingSystem[] = {
|
||||
};
|
||||
enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) };
|
||||
|
||||
inline QString qt_mac_NSStringToQString(const NSString *nsstr)
|
||||
{ return QCFString::toQString(reinterpret_cast<const CFStringRef>(nsstr)); }
|
||||
|
||||
int qt_antialiasing_threshold = 0;
|
||||
bool qt_enable_font_smoothing = true;
|
||||
|
||||
@ -141,7 +138,7 @@ QCoreTextFontDatabase::~QCoreTextFontDatabase()
|
||||
static QString familyNameFromPostScriptName(QHash<QString, QString> &psNameToFamily,
|
||||
NSString *psName)
|
||||
{
|
||||
QString name = qt_mac_NSStringToQString(psName);
|
||||
QString name = QCFString::toQString(psName);
|
||||
if (psNameToFamily.contains(name))
|
||||
return psNameToFamily[name];
|
||||
else {
|
||||
@ -240,7 +237,7 @@ void QCoreTextFontDatabase::populateFontDatabase()
|
||||
pixelSize, fixedPitch, writingSystems, (void *) font);
|
||||
CFStringRef psName = (CFStringRef) CTFontDescriptorCopyAttribute(font, kCTFontNameAttribute);
|
||||
// we need PostScript Name to family name mapping for fallback list construction
|
||||
psNameToFamily[qt_mac_NSStringToQString((NSString *) psName)] = familyName;
|
||||
psNameToFamily[QCFString::toQString((NSString *) psName)] = familyName;
|
||||
CFRelease(psName);
|
||||
}
|
||||
|
||||
|
@ -69,13 +69,6 @@
|
||||
#include <net/if.h>
|
||||
#include <ifaddrs.h>
|
||||
|
||||
inline QString qt_NSStringToQString(const NSString *nsstr)
|
||||
{ return QCFString::toQString(reinterpret_cast<const CFStringRef>(nsstr)); }
|
||||
|
||||
inline NSString *qt_QStringToNSString(const QString &qstr)
|
||||
{ return [reinterpret_cast<const NSString *>(QCFString::toCFStringRef(qstr)) autorelease]; }
|
||||
|
||||
|
||||
@interface QT_MANGLE_NAMESPACE(QNSListener) : NSObject
|
||||
{
|
||||
NSNotificationCenter *notificationCenter;
|
||||
@ -170,7 +163,7 @@ void QScanThread::run()
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
QStringList found;
|
||||
mutex.lock();
|
||||
CWInterface *currentInterface = [CWInterface interfaceWithName:qt_QStringToNSString(interfaceName)];
|
||||
CWInterface *currentInterface = [CWInterface interfaceWithName: QCFString::toNSString(interfaceName)];
|
||||
mutex.unlock();
|
||||
|
||||
if([currentInterface power]) {
|
||||
@ -188,14 +181,14 @@ void QScanThread::run()
|
||||
for(uint row=0; row < [apArray count]; row++ ) {
|
||||
apNetwork = [apArray objectAtIndex:row];
|
||||
|
||||
const QString networkSsid = qt_NSStringToQString([apNetwork ssid]);
|
||||
const QString networkSsid = QCFString::toQString([apNetwork ssid]);
|
||||
const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkSsid));
|
||||
found.append(id);
|
||||
|
||||
QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined;
|
||||
bool known = isKnownSsid(networkSsid);
|
||||
if( [currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) {
|
||||
if( networkSsid == qt_NSStringToQString( [currentInterface ssid])) {
|
||||
if( networkSsid == QCFString::toQString( [currentInterface ssid])) {
|
||||
state = QNetworkConfiguration::Active;
|
||||
}
|
||||
}
|
||||
@ -238,7 +231,7 @@ void QScanThread::run()
|
||||
}
|
||||
|
||||
if( [currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) {
|
||||
if( networkSsid == qt_NSStringToQString([currentInterface ssid])) {
|
||||
if( networkSsid == QCFString::toQString([currentInterface ssid])) {
|
||||
state = QNetworkConfiguration::Active;
|
||||
}
|
||||
}
|
||||
@ -317,10 +310,10 @@ void QScanThread::getUserConfigurations()
|
||||
|
||||
NSArray *thisSsidarray = [prefNetDict valueForKey:@"SSID_STR"];
|
||||
for(NSString *ssidkey in thisSsidarray) {
|
||||
QString thisSsid = qt_NSStringToQString(ssidkey);
|
||||
QString thisSsid = QCFString::toQString(ssidkey);
|
||||
if(!userProfiles.contains(thisSsid)) {
|
||||
QMap <QString,QString> map;
|
||||
map.insert(thisSsid, qt_NSStringToQString(nsInterfaceName));
|
||||
map.insert(thisSsid, QCFString::toQString(nsInterfaceName));
|
||||
userProfiles.insert(thisSsid, map);
|
||||
}
|
||||
}
|
||||
@ -329,7 +322,7 @@ void QScanThread::getUserConfigurations()
|
||||
|
||||
// 802.1X user profiles
|
||||
QString userProfilePath = QDir::homePath() + "/Library/Preferences/com.apple.eap.profiles.plist";
|
||||
NSDictionary* eapDict = [[[NSDictionary alloc] initWithContentsOfFile:qt_QStringToNSString(userProfilePath)] autorelease];
|
||||
NSDictionary* eapDict = [[[NSDictionary alloc] initWithContentsOfFile: QCFString::toNSString(userProfilePath)] autorelease];
|
||||
if(eapDict != nil) {
|
||||
NSString *profileStr= @"Profiles";
|
||||
NSString *nameStr = @"UserDefinedName";
|
||||
@ -348,15 +341,15 @@ void QScanThread::getUserConfigurations()
|
||||
QString ssid;
|
||||
for(int i = 0; i < dictSize; i++) {
|
||||
if([nameStr isEqualToString:keys[i]]) {
|
||||
networkName = qt_NSStringToQString(objects[i]);
|
||||
networkName = QCFString::toQString(objects[i]);
|
||||
}
|
||||
if([networkSsidStr isEqualToString:keys[i]]) {
|
||||
ssid = qt_NSStringToQString(objects[i]);
|
||||
ssid = QCFString::toQString(objects[i]);
|
||||
}
|
||||
if(!userProfiles.contains(networkName)
|
||||
&& !ssid.isEmpty()) {
|
||||
QMap<QString,QString> map;
|
||||
map.insert(ssid, qt_NSStringToQString(nsInterfaceName));
|
||||
map.insert(ssid, QCFString::toQString(nsInterfaceName));
|
||||
userProfiles.insert(networkName, map);
|
||||
}
|
||||
}
|
||||
@ -479,7 +472,7 @@ void QCoreWlanEngine::connectToId(const QString &id)
|
||||
QString interfaceString = getInterfaceFromId(id);
|
||||
|
||||
CWInterface *wifiInterface =
|
||||
[CWInterface interfaceWithName: qt_QStringToNSString(interfaceString)];
|
||||
[CWInterface interfaceWithName: QCFString::toNSString(interfaceString)];
|
||||
|
||||
if ([wifiInterface power]) {
|
||||
NSError *err = nil;
|
||||
@ -497,9 +490,9 @@ void QCoreWlanEngine::connectToId(const QString &id)
|
||||
NSArray *array = [CW8021XProfile allUser8021XProfiles];
|
||||
|
||||
for (NSUInteger i = 0; i < [array count]; ++i) {
|
||||
const QString networkNameHashCheck = QString::number(qHash(QLatin1String("corewlan:") + qt_NSStringToQString([[array objectAtIndex:i] userDefinedName])));
|
||||
const QString networkNameHashCheck = QString::number(qHash(QLatin1String("corewlan:") + QCFString::toQString([[array objectAtIndex:i] userDefinedName])));
|
||||
|
||||
const QString ssidHash = QString::number(qHash(QLatin1String("corewlan:") + qt_NSStringToQString([[array objectAtIndex:i] ssid])));
|
||||
const QString ssidHash = QString::number(qHash(QLatin1String("corewlan:") + QCFString::toQString([[array objectAtIndex:i] ssid])));
|
||||
|
||||
if (id == networkNameHashCheck || id == ssidHash) {
|
||||
const QString thisName = scanThread->getSsidFromNetworkName(id);
|
||||
@ -532,7 +525,7 @@ void QCoreWlanEngine::connectToId(const QString &id)
|
||||
[NSNumber numberWithBool:YES], kCWScanKeyMerge,
|
||||
[NSNumber numberWithInt:kCWScanTypeFast], kCWScanKeyScanType,
|
||||
[NSNumber numberWithInteger:100], kCWScanKeyRestTime,
|
||||
qt_QStringToNSString(wantedSsid), kCWScanKeySSID,
|
||||
QCFString::toNSString(wantedSsid), kCWScanKeySSID,
|
||||
nil];
|
||||
|
||||
NSArray *scanArray = [wifiInterface scanForNetworksWithParameters:scanParameters error:&err];
|
||||
@ -541,7 +534,7 @@ void QCoreWlanEngine::connectToId(const QString &id)
|
||||
for(uint row=0; row < [scanArray count]; row++ ) {
|
||||
CWNetwork *apNetwork = [scanArray objectAtIndex:row];
|
||||
|
||||
if(wantedSsid == qt_NSStringToQString([apNetwork ssid])) {
|
||||
if(wantedSsid == QCFString::toQString([apNetwork ssid])) {
|
||||
|
||||
if(!using8021X) {
|
||||
SecKeychainAttribute attributes[3];
|
||||
@ -608,12 +601,12 @@ void QCoreWlanEngine::connectToId(const QString &id)
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
qDebug() <<"associate ERROR"<< qt_NSStringToQString([err localizedDescription ]);
|
||||
qDebug() <<"associate ERROR"<< QCFString::toQString([err localizedDescription ]);
|
||||
}
|
||||
}
|
||||
} //end scan network
|
||||
} else {
|
||||
qDebug() <<"scan ERROR"<< qt_NSStringToQString([err localizedDescription ]);
|
||||
qDebug() <<"scan ERROR"<< QCFString::toQString([err localizedDescription ]);
|
||||
}
|
||||
emit connectionError(id, InterfaceLookupError);
|
||||
}
|
||||
@ -631,7 +624,7 @@ void QCoreWlanEngine::disconnectFromId(const QString &id)
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
CWInterface *wifiInterface =
|
||||
[CWInterface interfaceWithName: qt_QStringToNSString(interfaceString)];
|
||||
[CWInterface interfaceWithName: QCFString::toNSString(interfaceString)];
|
||||
|
||||
[wifiInterface disassociate];
|
||||
if ([[wifiInterface interfaceState]intValue] != kCWInterfaceStateInactive) {
|
||||
@ -656,7 +649,7 @@ void QCoreWlanEngine::doRequestUpdate()
|
||||
|
||||
NSArray *wifiInterfaces = [CWInterface supportedInterfaces];
|
||||
for (uint row = 0; row < [wifiInterfaces count]; ++row) {
|
||||
scanThread->interfaceName = qt_NSStringToQString([wifiInterfaces objectAtIndex:row]);
|
||||
scanThread->interfaceName = QCFString::toQString([wifiInterfaces objectAtIndex:row]);
|
||||
scanThread->start();
|
||||
}
|
||||
locker.unlock();
|
||||
@ -669,7 +662,7 @@ bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName)
|
||||
bool haswifi = false;
|
||||
if(hasWifi) {
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
CWInterface *defaultInterface = [CWInterface interfaceWithName: qt_QStringToNSString(wifiDeviceName)];
|
||||
CWInterface *defaultInterface = [CWInterface interfaceWithName: QCFString::toNSString(wifiDeviceName)];
|
||||
if([defaultInterface power]) {
|
||||
haswifi = true;
|
||||
}
|
||||
@ -898,7 +891,7 @@ quint64 QCoreWlanEngine::startTime(const QString &identifier)
|
||||
bool ok = false;
|
||||
for(int i = 0; i < dictSize; i++) {
|
||||
if([ssidStr isEqualToString:keys[i]]) {
|
||||
const QString ident = QString::number(qHash(QLatin1String("corewlan:") + qt_NSStringToQString(objects[i])));
|
||||
const QString ident = QString::number(qHash(QLatin1String("corewlan:") + QCFString::toQString(objects[i])));
|
||||
if(ident == identifier) {
|
||||
ok = true;
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ static QAccessibleInterface *acast(void *ptr)
|
||||
QSize qtSize = acast(accessibleInterface)->rect().size();
|
||||
return [NSValue valueWithSize: NSMakeSize(qtSize.width(), qtSize.height())];
|
||||
} else if ([attribute isEqualToString:NSAccessibilityDescriptionAttribute]) {
|
||||
return qt_mac_QStringToNSString(acast(accessibleInterface)->text(QAccessible::Name));
|
||||
return QCFString::toNSString(acast(accessibleInterface)->text(QAccessible::Name));
|
||||
}
|
||||
|
||||
return nil;
|
||||
@ -195,7 +195,7 @@ static QAccessibleInterface *acast(void *ptr)
|
||||
// Return a description from the action interface if this action is not known to the OS.
|
||||
if (qtAction.isEmpty()) {
|
||||
QString description = actionInterface->localizedActionDescription(qtAction);
|
||||
return qt_mac_QStringToNSString(description);
|
||||
return QCFString::toNSString(description);
|
||||
}
|
||||
|
||||
return NSAccessibilityActionDescription(action);
|
||||
|
@ -219,7 +219,7 @@ static void cleanupCocoaApplicationDelegate()
|
||||
Q_UNUSED(sender);
|
||||
/*
|
||||
for (NSString *fileName in filenames) {
|
||||
QString qtFileName = qt_mac_NSStringToQString(fileName);
|
||||
QString qtFileName = QCFString::toQString(fileName);
|
||||
if (inLaunch) {
|
||||
// We need to be careful because Cocoa will be nice enough to take
|
||||
// command line arguments and send them to us as events. Given the history
|
||||
@ -336,7 +336,7 @@ static void cleanupCocoaApplicationDelegate()
|
||||
Q_UNUSED(replyEvent);
|
||||
/*
|
||||
NSString *urlString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
|
||||
QUrl url(qt_mac_NSStringToQString(urlString));
|
||||
QUrl url(QCFString::toQString(urlString));
|
||||
QFileOpenEvent qtEvent(url);
|
||||
qt_sendSpontaneousEvent(qAppInstance(), &qtEvent);
|
||||
*/
|
||||
|
@ -151,14 +151,14 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
|
||||
|
||||
QFileInfo sel(selectFile);
|
||||
if (sel.isDir()){
|
||||
mCurrentDir = [qt_mac_QStringToNSString(sel.absoluteFilePath()) retain];
|
||||
mCurrentDir = [QCFString::toNSString(sel.absoluteFilePath()) retain];
|
||||
mCurrentSelection = new QString;
|
||||
} else {
|
||||
mCurrentDir = [qt_mac_QStringToNSString(sel.absolutePath()) retain];
|
||||
mCurrentDir = [QCFString::toNSString(sel.absolutePath()) retain];
|
||||
mCurrentSelection = new QString(sel.absoluteFilePath());
|
||||
}
|
||||
|
||||
[mSavePanel setTitle:qt_mac_QStringToNSString(options->windowTitle())];
|
||||
[mSavePanel setTitle:QCFString::toNSString(options->windowTitle())];
|
||||
[self createPopUpButton:selectedVisualNameFilter hideDetails:options->testOption(QFileDialogOptions::HideNameFilterDetails)];
|
||||
[self createTextField];
|
||||
[self createAccessory];
|
||||
@ -197,12 +197,12 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
|
||||
- (NSString *)strip:(const QString &)label
|
||||
{
|
||||
QAction a(label, 0);
|
||||
return qt_mac_QStringToNSString(a.iconText());
|
||||
return QCFString::toNSString(a.iconText());
|
||||
}
|
||||
|
||||
- (void)closePanel
|
||||
{
|
||||
*mCurrentSelection = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)([mSavePanel filename]);
|
||||
*mCurrentSelection = QT_PREPEND_NAMESPACE(QCFString::toQString)([mSavePanel filename]);
|
||||
[mSavePanel close];
|
||||
}
|
||||
|
||||
@ -210,8 +210,8 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
|
||||
{
|
||||
if (mOpenPanel){
|
||||
QFileInfo info(*mCurrentSelection);
|
||||
NSString *filename = QT_PREPEND_NAMESPACE(qt_mac_QStringToNSString)(info.fileName());
|
||||
NSString *filepath = QT_PREPEND_NAMESPACE(qt_mac_QStringToNSString)(info.filePath());
|
||||
NSString *filename = QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.fileName());
|
||||
NSString *filepath = QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath());
|
||||
bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave)
|
||||
|| [self panel:nil shouldShowFilename:filepath];
|
||||
[mOpenPanel
|
||||
@ -227,8 +227,8 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
|
||||
- (BOOL)runApplicationModalPanel
|
||||
{
|
||||
QFileInfo info(*mCurrentSelection);
|
||||
NSString *filename = QT_PREPEND_NAMESPACE(qt_mac_QStringToNSString)(info.fileName());
|
||||
NSString *filepath = QT_PREPEND_NAMESPACE(qt_mac_QStringToNSString)(info.filePath());
|
||||
NSString *filename = QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.fileName());
|
||||
NSString *filepath = QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath());
|
||||
bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave)
|
||||
|| [self panel:nil shouldShowFilename:filepath];
|
||||
mReturnCode = [mSavePanel
|
||||
@ -248,8 +248,8 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
|
||||
{
|
||||
Q_UNUSED(docWidget);
|
||||
QFileInfo info(*mCurrentSelection);
|
||||
NSString *filename = QT_PREPEND_NAMESPACE(qt_mac_QStringToNSString)(info.fileName());
|
||||
NSString *filepath = QT_PREPEND_NAMESPACE(qt_mac_QStringToNSString)(info.filePath());
|
||||
NSString *filename = QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.fileName());
|
||||
NSString *filepath = QT_PREPEND_NAMESPACE(QCFString::toNSString)(info.filePath());
|
||||
bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave)
|
||||
|| [self panel:nil shouldShowFilename:filepath];
|
||||
[mSavePanel
|
||||
@ -277,7 +277,7 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
|
||||
}
|
||||
}
|
||||
|
||||
QString qtFileName = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)(filename);
|
||||
QString qtFileName = QT_PREPEND_NAMESPACE(QCFString::toQString)(filename);
|
||||
QFileInfo info(qtFileName.normalized(QT_PREPEND_NAMESPACE(QString::NormalizationForm_C)));
|
||||
QString path = info.absolutePath();
|
||||
if (path != *mLastFilterCheckPath){
|
||||
@ -319,7 +319,7 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
|
||||
if (filters.size() > 0){
|
||||
for (int i=0; i<filters.size(); ++i) {
|
||||
QString filter = hideDetails ? [self removeExtensions:filters.at(i)] : filters.at(i);
|
||||
[mPopUpButton addItemWithTitle:QT_PREPEND_NAMESPACE(qt_mac_QStringToNSString)(filter)];
|
||||
[mPopUpButton addItemWithTitle:QT_PREPEND_NAMESPACE(QCFString::toNSString)(filter)];
|
||||
}
|
||||
[mPopUpButton selectItemAtIndex:0];
|
||||
[mSavePanel setAccessoryView:mAccessoryView];
|
||||
@ -352,7 +352,7 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
|
||||
return QT_PREPEND_NAMESPACE(qt_mac_NSArrayToQStringList)([mOpenPanel filenames]);
|
||||
else{
|
||||
QStringList result;
|
||||
QString filename = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)([mSavePanel filename]);
|
||||
QString filename = QT_PREPEND_NAMESPACE(QCFString::toQString)([mSavePanel filename]);
|
||||
result << filename.remove(QLatin1String("___qt_very_unlikely_prefix_"));
|
||||
return result;
|
||||
}
|
||||
@ -390,7 +390,7 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
|
||||
{
|
||||
Q_UNUSED(sender);
|
||||
if (mHelper) {
|
||||
QString selection = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString([mSavePanel filename]));
|
||||
QString selection = QT_PREPEND_NAMESPACE(QCFString::toQString([mSavePanel filename]));
|
||||
if (selection != mCurrentSelection) {
|
||||
*mCurrentSelection = selection;
|
||||
mHelper->QNSOpenSavePanelDelegate_selectionChanged(selection);
|
||||
@ -417,7 +417,7 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
|
||||
|
||||
[mCurrentDir release];
|
||||
mCurrentDir = [path retain];
|
||||
mHelper->QNSOpenSavePanelDelegate_directoryEntered(QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString(mCurrentDir)));
|
||||
mHelper->QNSOpenSavePanelDelegate_directoryEntered(QT_PREPEND_NAMESPACE(QCFString::toQString(mCurrentDir)));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -476,7 +476,7 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
|
||||
if (filters->size() > 0){
|
||||
for (int i=0; i<mNameFilterDropDownList->size(); ++i) {
|
||||
QString filter = hideDetails ? [self removeExtensions:filters->at(i)] : filters->at(i);
|
||||
[mPopUpButton addItemWithTitle:QT_PREPEND_NAMESPACE(qt_mac_QStringToNSString)(filter)];
|
||||
[mPopUpButton addItemWithTitle:QT_PREPEND_NAMESPACE(QCFString::toNSString)(filter)];
|
||||
if (filters->at(i).startsWith(selectedFilter))
|
||||
[mPopUpButton selectItemAtIndex:i];
|
||||
}
|
||||
@ -557,13 +557,13 @@ extern void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding
|
||||
void QCocoaFileDialogHelper::setDirectory_sys(const QString &directory)
|
||||
{
|
||||
QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
|
||||
[delegate->mSavePanel setDirectory:qt_mac_QStringToNSString(directory)];
|
||||
[delegate->mSavePanel setDirectory:QCFString::toNSString(directory)];
|
||||
}
|
||||
|
||||
QString QCocoaFileDialogHelper::directory_sys() const
|
||||
{
|
||||
QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
|
||||
return qt_mac_NSStringToQString([delegate->mSavePanel directory]);
|
||||
return QCFString::toQString([delegate->mSavePanel directory]);
|
||||
}
|
||||
|
||||
void QCocoaFileDialogHelper::selectFile_sys(const QString &filename)
|
||||
@ -587,7 +587,7 @@ void QCocoaFileDialogHelper::setFilter_sys()
|
||||
{
|
||||
QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *>(mDelegate);
|
||||
const SharedPointerFileDialogOptions &opts = options();
|
||||
[delegate->mSavePanel setTitle:qt_mac_QStringToNSString(opts->windowTitle())];
|
||||
[delegate->mSavePanel setTitle:QCFString::toNSString(opts->windowTitle())];
|
||||
if (opts->isLabelExplicitlySet(QFileDialogOptions::Accept))
|
||||
[delegate->mSavePanel setPrompt:[delegate strip:opts->labelText(QFileDialogOptions::Accept)]];
|
||||
if (opts->isLabelExplicitlySet(QFileDialogOptions::FileName))
|
||||
|
@ -68,12 +68,6 @@ void *qt_mac_QStringListToNSMutableArrayVoid(const QStringList &list);
|
||||
inline NSMutableArray *qt_mac_QStringListToNSMutableArray(const QStringList &qstrlist)
|
||||
{ return reinterpret_cast<NSMutableArray *>(qt_mac_QStringListToNSMutableArrayVoid(qstrlist)); }
|
||||
|
||||
inline QString qt_mac_NSStringToQString(const NSString *nsstr)
|
||||
{ return QCFString::toQString(reinterpret_cast<const CFStringRef>(nsstr)); }
|
||||
|
||||
inline NSString *qt_mac_QStringToNSString(const QString &qstr)
|
||||
{ return [const_cast<NSString *>(reinterpret_cast<const NSString *>(QCFString::toCFStringRef(qstr))) autorelease]; }
|
||||
|
||||
CGImageRef qt_mac_image_to_cgimage(const QImage &image);
|
||||
NSImage *qt_mac_cgimage_to_nsimage(CGImageRef iamge);
|
||||
NSImage *qt_mac_create_nsimage(const QPixmap &pm);
|
||||
|
@ -58,7 +58,7 @@ QStringList qt_mac_NSArrayToQStringList(void *nsarray)
|
||||
QStringList result;
|
||||
NSArray *array = static_cast<NSArray *>(nsarray);
|
||||
for (NSUInteger i=0; i<[array count]; ++i)
|
||||
result << qt_mac_NSStringToQString([array objectAtIndex:i]);
|
||||
result << QCFString::toQString([array objectAtIndex:i]);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ void qt_mac_loadMenuNib(QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader)
|
||||
}
|
||||
|
||||
// Load and instantiate nib file from temp
|
||||
NSURL *nibUrl = [NSURL fileURLWithPath : const_cast<NSString *>(reinterpret_cast<const NSString *>(QCFString::toCFStringRef(nibDir)))];
|
||||
NSURL *nibUrl = [NSURL fileURLWithPath : QCFString::toNSString(nibDir)];
|
||||
[nibUrl autorelease];
|
||||
NSNib *nib = [[NSNib alloc] initWithContentsOfURL : nibUrl];
|
||||
[nib autorelease];
|
||||
@ -282,13 +282,13 @@ void qt_mac_loadMenuNib(QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader)
|
||||
qDebug() << "qtTranslateApplicationMenu";
|
||||
|
||||
#ifndef QT_NO_TRANSLATION
|
||||
[servicesItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(0))];
|
||||
[hideItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(1).arg(qt_mac_applicationName()))];
|
||||
[hideAllOthersItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(2))];
|
||||
[showAllItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(3))];
|
||||
[preferencesItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(4))];
|
||||
[quitItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(5).arg(qt_mac_applicationName()))];
|
||||
[aboutItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(6).arg(qt_mac_applicationName()))];
|
||||
[servicesItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(0))];
|
||||
[hideItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(1).arg(qt_mac_applicationName()))];
|
||||
[hideAllOthersItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(2))];
|
||||
[showAllItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(3))];
|
||||
[preferencesItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(4))];
|
||||
[quitItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(5).arg(qt_mac_applicationName()))];
|
||||
[aboutItem setTitle: QCFString::toNSString(qt_mac_applicationmenu_string(6).arg(qt_mac_applicationName()))];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ static inline QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *getMenuLoader()
|
||||
static NSMenuItem *createNSMenuItem(const QString &title)
|
||||
{
|
||||
NSMenuItem *item = [[NSMenuItem alloc]
|
||||
initWithTitle:qt_mac_QStringToNSString(title)
|
||||
initWithTitle:QCFString::toNSString(title)
|
||||
action:@selector(qtDispatcherToQAction:) keyEquivalent:@""];
|
||||
[item setTarget:nil];
|
||||
return item;
|
||||
@ -636,22 +636,22 @@ void QCocoaMenu::syncAction(QCocoaMenuAction *action)
|
||||
// Cocoa Font and title
|
||||
if (action->action->font().resolve()) {
|
||||
const QFont &actionFont = action->action->font();
|
||||
NSFont *customMenuFont = [NSFont fontWithName:qt_mac_QStringToNSString(actionFont.family())
|
||||
NSFont *customMenuFont = [NSFont fontWithName:QCFString::toNSString(actionFont.family())
|
||||
size:actionFont.pointSize()];
|
||||
NSArray *keys = [NSArray arrayWithObjects:NSFontAttributeName, nil];
|
||||
NSArray *objects = [NSArray arrayWithObjects:customMenuFont, nil];
|
||||
NSDictionary *attributes = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
|
||||
NSAttributedString *str = [[[NSAttributedString alloc] initWithString:qt_mac_QStringToNSString(finalString)
|
||||
NSAttributedString *str = [[[NSAttributedString alloc] initWithString:QCFString::toNSString(finalString)
|
||||
attributes:attributes] autorelease];
|
||||
[item setAttributedTitle: str];
|
||||
} else {
|
||||
[item setTitle: qt_mac_QStringToNSString(finalString)];
|
||||
[item setTitle: QCFString::toNSString(finalString)];
|
||||
}
|
||||
|
||||
if (action->action->menuRole() == QAction::AboutRole || action->action->menuRole() == QAction::QuitRole)
|
||||
[item setTitle:qt_mac_QStringToNSString(text)];
|
||||
[item setTitle:QCFString::toNSString(text)];
|
||||
else
|
||||
[item setTitle:qt_mac_QStringToNSString(qt_mac_removeMnemonics(text))];
|
||||
[item setTitle:QCFString::toNSString(qt_mac_removeMnemonics(text))];
|
||||
|
||||
// Cocoa Enabled
|
||||
[item setEnabled: action->action->isEnabled()];
|
||||
@ -873,7 +873,7 @@ void QCocoaMenuBar::syncAction(QCocoaMenuAction *action)
|
||||
if (submenu) {
|
||||
bool visible = actualMenuItemVisibility(this, action);
|
||||
[item setSubmenu: submenu];
|
||||
[submenu setTitle:qt_mac_QStringToNSString(qt_mac_removeMnemonics(action->action->text()))];
|
||||
[submenu setTitle:QCFString::toNSString(qt_mac_removeMnemonics(action->action->text()))];
|
||||
syncNSMenuItemVisiblity(item, visible);
|
||||
if (release_submenu) { //no pointers to it
|
||||
[submenu release];
|
||||
@ -978,7 +978,7 @@ OSMenuRef QCocoaMenuBar::macMenu()
|
||||
if (GetCurrentProcess(&mine) == noErr && GetFrontProcess(&front) == noErr) {
|
||||
if (!qt_mac_no_menubar_merge && !apple_menu) {
|
||||
apple_menu = qt_mac_create_menu(qtMenuBar);
|
||||
[apple_menu setTitle:qt_mac_QStringToNSString(QString(QChar(0x14)))];
|
||||
[apple_menu setTitle:QCFString::toNSString(QString(QChar(0x14)))];
|
||||
NSMenuItem *apple_menuItem = [[NSMenuItem alloc] init];
|
||||
[apple_menuItem setSubmenu:menu];
|
||||
[apple_menu addItem:apple_menuItem];
|
||||
|
Loading…
Reference in New Issue
Block a user