summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@petroules.com>2014-09-15 16:24:41 -0400
committerJake Petroules <jake.petroules@petroules.com>2014-10-08 02:29:54 +0200
commit3b1de67fde055747bf26c2a6ca52b946f85cde0b (patch)
tree34c50db36060738534f12b96e8d0265c7e0cac50
parent50430a8392cf4c29a05e6604ec84520856e07577 (diff)
Utilize Q_FORWARD_DECLARE_OBJC_CLASS in QCocoaFileDialogHelper.
Change-Id: I94ae91ac8fb625de4a328c6628ce0ab45919708f Reviewed-by: Jake Petroules <jake.petroules@petroules.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm55
2 files changed, 25 insertions, 34 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h
index 9cbf8fe5f1..97fa56bd01 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h
@@ -37,6 +37,8 @@
#include <QObject>
#include <qpa/qplatformdialoghelper.h>
+Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate));
+
QT_BEGIN_NAMESPACE
class QFileDialog;
@@ -73,7 +75,7 @@ public:
void QNSOpenSavePanelDelegate_filterSelected(int menuIndex);
private:
- void *mDelegate;
+ QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) *mDelegate;
QUrl mDir;
};
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
index 78465b896d..084b53af79 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
@@ -77,8 +77,6 @@ QT_USE_NAMESPACE
typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
-@class QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate);
-
@interface QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate)
: NSObject<NSOpenSavePanelDelegate>
{
@@ -568,7 +566,7 @@ QCocoaFileDialogHelper::~QCocoaFileDialogHelper()
if (!mDelegate)
return;
QCocoaAutoReleasePool pool;
- [reinterpret_cast<QNSOpenSavePanelDelegate *>(mDelegate) release];
+ [mDelegate release];
mDelegate = 0;
}
@@ -604,18 +602,16 @@ extern void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding
void QCocoaFileDialogHelper::setDirectory(const QUrl &directory)
{
- QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
- if (delegate)
- [delegate->mSavePanel setDirectoryURL:[NSURL fileURLWithPath:QCFString::toNSString(directory.toLocalFile())]];
+ if (mDelegate)
+ [mDelegate->mSavePanel setDirectoryURL:[NSURL fileURLWithPath:QCFString::toNSString(directory.toLocalFile())]];
else
mDir = directory;
}
QUrl QCocoaFileDialogHelper::directory() const
{
- QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
- if (delegate) {
- QString path = QCFString::toQString([[delegate->mSavePanel directoryURL] path]).normalized(QString::NormalizationForm_C);
+ if (mDelegate) {
+ QString path = QCFString::toQString([[mDelegate->mSavePanel directoryURL] path]).normalized(QString::NormalizationForm_C);
return QUrl::fromLocalFile(path);
}
return mDir;
@@ -634,25 +630,23 @@ void QCocoaFileDialogHelper::selectFile(const QUrl &filename)
QList<QUrl> QCocoaFileDialogHelper::selectedFiles() const
{
- QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
- if (delegate)
- return [delegate selectedFiles];
+ if (mDelegate)
+ return [mDelegate selectedFiles];
return QList<QUrl>();
}
void QCocoaFileDialogHelper::setFilter()
{
- QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
- if (!delegate)
+ if (!mDelegate)
return;
const SharedPointerFileDialogOptions &opts = options();
- [delegate->mSavePanel setTitle:QCFString::toNSString(opts->windowTitle())];
+ [mDelegate->mSavePanel setTitle:QCFString::toNSString(opts->windowTitle())];
if (opts->isLabelExplicitlySet(QFileDialogOptions::Accept))
- [delegate->mSavePanel setPrompt:[delegate strip:opts->labelText(QFileDialogOptions::Accept)]];
+ [mDelegate->mSavePanel setPrompt:[mDelegate strip:opts->labelText(QFileDialogOptions::Accept)]];
if (opts->isLabelExplicitlySet(QFileDialogOptions::FileName))
- [delegate->mSavePanel setNameFieldLabel:[delegate strip:opts->labelText(QFileDialogOptions::FileName)]];
+ [mDelegate->mSavePanel setNameFieldLabel:[mDelegate strip:opts->labelText(QFileDialogOptions::FileName)]];
- [delegate updateProperties];
+ [mDelegate updateProperties];
}
void QCocoaFileDialogHelper::selectNameFilter(const QString &filter)
@@ -661,22 +655,20 @@ void QCocoaFileDialogHelper::selectNameFilter(const QString &filter)
return;
const int index = options()->nameFilters().indexOf(filter);
if (index != -1) {
- QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
- if (!delegate) {
+ if (!mDelegate) {
options()->setInitiallySelectedNameFilter(filter);
return;
}
- [delegate->mPopUpButton selectItemAtIndex:index];
- [delegate filterChanged:nil];
+ [mDelegate->mPopUpButton selectItemAtIndex:index];
+ [mDelegate filterChanged:nil];
}
}
QString QCocoaFileDialogHelper::selectedNameFilter() const
{
- QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
- if (!delegate)
+ if (!mDelegate)
return options()->initiallySelectedNameFilter();
- int index = [delegate->mPopUpButton indexOfSelectedItem];
+ int index = [mDelegate->mPopUpButton indexOfSelectedItem];
if (index >= options()->nameFilters().count())
return QString();
return index != -1 ? options()->nameFilters().at(index) : QString();
@@ -723,13 +715,12 @@ void QCocoaFileDialogHelper::createNSOpenSavePanelDelegate()
bool QCocoaFileDialogHelper::showCocoaFilePanel(Qt::WindowModality windowModality, QWindow *parent)
{
createNSOpenSavePanelDelegate();
- QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
- if (!delegate)
+ if (!mDelegate)
return false;
if (windowModality == Qt::NonModal)
- [delegate showModelessPanel];
+ [mDelegate showModelessPanel];
else if (windowModality == Qt::WindowModal && parent)
- [delegate showWindowModalSheet:parent];
+ [mDelegate showWindowModalSheet:parent];
// no need to show a Qt::ApplicationModal dialog here, since it will be done in _q_platformRunNativeAppModalPanel()
return true;
}
@@ -741,8 +732,7 @@ bool QCocoaFileDialogHelper::hideCocoaFilePanel()
// open regarding whether or not to go native:
return false;
} else {
- QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
- [delegate closePanel];
+ [mDelegate closePanel];
// Even when we hide it, we are still using a
// native dialog, so return true:
return true;
@@ -756,8 +746,7 @@ void QCocoaFileDialogHelper::exec()
// yet been reactivated (regardless if [NSApp run] is still on the stack)),
// showing a native modal dialog will fail.
QCocoaAutoReleasePool pool;
- QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate);
- if ([delegate runApplicationModalPanel])
+ if ([mDelegate runApplicationModalPanel])
emit accept();
else
emit reject();