From 2cb398e1d901e62384bb2b388761cfd18fc8804a Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 9 Jun 2011 17:34:17 +0200 Subject: move some internal helper functions from qglobal.cpp to qcore_mac* namely: void qt_mac_to_pascal_string(const QString &s, Str255 str, TextEncoding encoding = 0, int len = -1); QString qt_mac_from_pascal_string(const Str255 pstr); OSErr qt_mac_create_fsref(const QString &file, FSRef *fsref); OSErr qt_mac_create_fsspec(const QString &file, FSSpec *spec); remove relevant "extern" declarations all over the Qt sources Merge-request: 2615 Reviewed-by: Denis Dzyubenko --- src/corelib/global/qglobal.cpp | 55 ++--------------------------- src/corelib/kernel/qcore_mac.cpp | 50 ++++++++++++++++++++++++++ src/corelib/kernel/qcore_mac_p.h | 7 ++++ src/gui/dialogs/qfiledialog_mac.mm | 3 -- src/gui/kernel/qapplication_mac.mm | 1 - src/gui/kernel/qmime_mac.cpp | 4 --- src/gui/kernel/qt_mac.cpp | 1 - src/gui/text/qfontdatabase_mac.cpp | 2 -- src/opengl/qgl_mac.mm | 1 - src/qt3support/dialogs/q3filedialog_mac.cpp | 2 -- 10 files changed, 59 insertions(+), 67 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index c144871594..f6eaedc346 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1648,64 +1648,13 @@ static const unsigned int qt_one = 1; const int QSysInfo::ByteOrder = ((*((unsigned char *) &qt_one) == 0) ? BigEndian : LittleEndian); #endif -#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) +#if !defined(QWS) && defined(Q_OS_MAC) QT_BEGIN_INCLUDE_NAMESPACE #include "private/qcore_mac_p.h" #include "qnamespace.h" QT_END_INCLUDE_NAMESPACE -Q_CORE_EXPORT OSErr qt_mac_create_fsref(const QString &file, FSRef *fsref) -{ - return FSPathMakeRef(reinterpret_cast(file.toUtf8().constData()), fsref, 0); -} - -// Don't use this function, it won't work in 10.5 (Leopard) and up -Q_CORE_EXPORT OSErr qt_mac_create_fsspec(const QString &file, FSSpec *spec) -{ - FSRef fsref; - OSErr ret = qt_mac_create_fsref(file, &fsref); - if (ret == noErr) - ret = FSGetCatalogInfo(&fsref, kFSCatInfoNone, 0, 0, spec, 0); - return ret; -} - -Q_CORE_EXPORT void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding=0, int len=-1) -{ - if(len == -1) - len = s.length(); -#if 0 - UnicodeMapping mapping; - mapping.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeDefault, - kTextEncodingDefaultVariant, - kUnicode16BitFormat); - mapping.otherEncoding = (encoding ? encoding : ); - mapping.mappingVersion = kUnicodeUseLatestMapping; - - UnicodeToTextInfo info; - OSStatus err = CreateUnicodeToTextInfo(&mapping, &info); - if(err != noErr) { - qDebug("Qt: internal: Unable to create pascal string '%s'::%d [%ld]", - s.left(len).latin1(), (int)encoding, err); - return; - } - const int unilen = len * 2; - const UniChar *unibuf = (UniChar *)s.unicode(); - ConvertFromUnicodeToPString(info, unilen, unibuf, str); - DisposeUnicodeToTextInfo(&info); -#else - Q_UNUSED(encoding); - CFStringGetPascalString(QCFString(s), str, 256, CFStringGetSystemEncoding()); -#endif -} - -Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr) { - return QCFString(CFStringCreateWithPascalString(0, pstr, CFStringGetSystemEncoding())); -} -#endif //!defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) - -#if !defined(QWS) && defined(Q_OS_MAC) - static QSysInfo::MacVersion macVersion() { #ifndef QT_NO_CORESERVICES @@ -2105,7 +2054,7 @@ static void mac_default_handler(const char *msg) { if (qt_is_gui_used) { Str255 pmsg; - qt_mac_to_pascal_string(msg, pmsg); + qt_mac_to_pascal_string(QString::fromAscii(msg), pmsg); DebugStr(pmsg); } else { fprintf(stderr, msg); diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp index e45ef50c24..e705c314c5 100644 --- a/src/corelib/kernel/qcore_mac.cpp +++ b/src/corelib/kernel/qcore_mac.cpp @@ -86,4 +86,54 @@ QCFString::operator CFStringRef() const return type; } + +void qt_mac_to_pascal_string(const QString &s, Str255 str, TextEncoding encoding, int len) +{ + if(len == -1) + len = s.length(); +#if 0 + UnicodeMapping mapping; + mapping.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeDefault, + kTextEncodingDefaultVariant, + kUnicode16BitFormat); + mapping.otherEncoding = (encoding ? encoding : ); + mapping.mappingVersion = kUnicodeUseLatestMapping; + + UnicodeToTextInfo info; + OSStatus err = CreateUnicodeToTextInfo(&mapping, &info); + if(err != noErr) { + qDebug("Qt: internal: Unable to create pascal string '%s'::%d [%ld]", + s.left(len).latin1(), (int)encoding, err); + return; + } + const int unilen = len * 2; + const UniChar *unibuf = (UniChar *)s.unicode(); + ConvertFromUnicodeToPString(info, unilen, unibuf, str); + DisposeUnicodeToTextInfo(&info); +#else + Q_UNUSED(encoding); + CFStringGetPascalString(QCFString(s), str, 256, CFStringGetSystemEncoding()); +#endif +} + +QString qt_mac_from_pascal_string(const Str255 pstr) +{ + return QCFString(CFStringCreateWithPascalString(0, pstr, CFStringGetSystemEncoding())); +} + +OSErr qt_mac_create_fsref(const QString &file, FSRef *fsref) +{ + return FSPathMakeRef(reinterpret_cast(file.toUtf8().constData()), fsref, 0); +} + +// Don't use this function, it won't work in 10.5 (Leopard) and up +OSErr qt_mac_create_fsspec(const QString &file, FSSpec *spec) +{ + FSRef fsref; + OSErr ret = qt_mac_create_fsref(file, &fsref); + if (ret == noErr) + ret = FSGetCatalogInfo(&fsref, kFSCatInfoNone, 0, 0, spec, 0); + return ret; +} + QT_END_NAMESPACE diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index adbad83cad..4b8c16f1e6 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -148,6 +148,13 @@ private: QString string; }; +Q_CORE_EXPORT void qt_mac_to_pascal_string(const QString &s, Str255 str, TextEncoding encoding = 0, int len = -1); +Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr); + +Q_CORE_EXPORT OSErr qt_mac_create_fsref(const QString &file, FSRef *fsref); +// Don't use this function, it won't work in 10.5 (Leopard) and up +Q_CORE_EXPORT OSErr qt_mac_create_fsspec(const QString &file, FSSpec *spec); + QT_END_NAMESPACE #if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5) diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm index 885ce77c52..fb52274798 100644 --- a/src/gui/dialogs/qfiledialog_mac.mm +++ b/src/gui/dialogs/qfiledialog_mac.mm @@ -553,9 +553,6 @@ void QFileDialogPrivate::QNSOpenSavePanelDelegate_filterSelected(int menuIndex) emit q_func()->filterSelected(nameFilters.at(menuIndex)); } -extern OSErr qt_mac_create_fsref(const QString &, FSRef *); // qglobal.cpp -extern void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding=0, int len=-1); // qglobal.cpp - void QFileDialogPrivate::setDirectory_sys(const QString &directory) { #ifndef QT_MAC_USE_COCOA diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index eb0fd8d057..5268698cd2 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -218,7 +218,6 @@ extern OSWindowRef qt_mac_window_for(const QWidget*); //qwidget_mac.cpp extern QWidget *qt_mac_find_window(OSWindowRef); //qwidget_mac.cpp extern void qt_mac_set_cursor(const QCursor *); //qcursor_mac.cpp extern bool qt_mac_is_macsheet(const QWidget *); //qwidget_mac.cpp -extern QString qt_mac_from_pascal_string(const Str255); //qglobal.cpp extern void qt_mac_command_set_enabled(MenuRef, UInt32, bool); //qmenu_mac.cpp extern bool qt_sendSpontaneousEvent(QObject *obj, QEvent *event); // qapplication.cpp extern void qt_mac_update_cursor(); // qcursor_mac.mm diff --git a/src/gui/kernel/qmime_mac.cpp b/src/gui/kernel/qmime_mac.cpp index a1df34eb1f..8b47d8e52a 100644 --- a/src/gui/kernel/qmime_mac.cpp +++ b/src/gui/kernel/qmime_mac.cpp @@ -119,10 +119,6 @@ const QStringList& qEnabledDraggedTypes() *****************************************************************************/ //#define DEBUG_MIME_MAPS -//functions -extern QString qt_mac_from_pascal_string(const Str255); //qglobal.cpp -extern void qt_mac_from_pascal_string(QString, Str255, TextEncoding encoding=0, int len=-1); //qglobal.cpp - ScrapFlavorType qt_mac_mime_type = 'CUTE'; CFStringRef qt_mac_mime_typeUTI = CFSTR("com.pasteboard.trolltech.marker"); diff --git a/src/gui/kernel/qt_mac.cpp b/src/gui/kernel/qt_mac.cpp index 339bc82ff5..69f003403f 100644 --- a/src/gui/kernel/qt_mac.cpp +++ b/src/gui/kernel/qt_mac.cpp @@ -61,7 +61,6 @@ QFont qfontForThemeFont(ThemeFontID themeID) SInt16 f_size; Style f_style; GetThemeFont(themeID, Script, f_name, &f_size, &f_style); - extern QString qt_mac_from_pascal_string(const Str255); //qglobal.cpp return QFont(qt_mac_from_pascal_string(f_name), f_size, (f_style & ::bold) ? QFont::Bold : QFont::Normal, (bool)(f_style & ::italic)); diff --git a/src/gui/text/qfontdatabase_mac.cpp b/src/gui/text/qfontdatabase_mac.cpp index 6fdaf06c8b..954b5c29b3 100644 --- a/src/gui/text/qfontdatabase_mac.cpp +++ b/src/gui/text/qfontdatabase_mac.cpp @@ -362,7 +362,6 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt) if(fnt->data.isEmpty()) { #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { - extern OSErr qt_mac_create_fsref(const QString &, FSRef *); // qglobal.cpp FSRef ref; if(qt_mac_create_fsref(fnt->fileName, &ref) != noErr) return; @@ -372,7 +371,6 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt) #endif { #ifndef Q_WS_MAC64 - extern Q_CORE_EXPORT OSErr qt_mac_create_fsspec(const QString &, FSSpec *); // global.cpp FSSpec spec; if(qt_mac_create_fsspec(fnt->fileName, &spec) != noErr) return; diff --git a/src/opengl/qgl_mac.mm b/src/opengl/qgl_mac.mm index d4b2a40e93..c3dac871eb 100644 --- a/src/opengl/qgl_mac.mm +++ b/src/opengl/qgl_mac.mm @@ -114,7 +114,6 @@ extern int qt_mac_pixmap_get_bytes_per_line(const QPixmap *); extern RgnHandle qt_mac_get_rgn(); //qregion_mac.cpp extern void qt_mac_dispose_rgn(RgnHandle); //qregion_mac.cpp extern QRegion qt_mac_convert_mac_region(RgnHandle); //qregion_mac.cpp -extern void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding=0, int len=-1); //qglobal.cpp /* QGLTemporaryContext implementation diff --git a/src/qt3support/dialogs/q3filedialog_mac.cpp b/src/qt3support/dialogs/q3filedialog_mac.cpp index f82a8ac2b2..c5db9444dc 100644 --- a/src/qt3support/dialogs/q3filedialog_mac.cpp +++ b/src/qt3support/dialogs/q3filedialog_mac.cpp @@ -248,8 +248,6 @@ static const NavEventUPP make_navProcUPP() } -extern OSErr qt_mac_create_fsref(const QString &, FSRef *); //qglobal.cpp - QStringList Q3FileDialog::macGetOpenFileNames(const QString &filter, QString *pwd, QWidget *parent, const char* /*name*/, const QString& caption, QString *selectedFilter, -- cgit v1.2.1