From 9fa6e8f627d0c61fd5a3b993903a362dc04bf707 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Thu, 29 Sep 2011 14:29:05 +0200 Subject: Clean-up a macro for Cocoa MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the usage of Q_MAC_USE_COCOA and Carbon code paths. Change-Id: Ib569ad8c6d9ffe258f454b3c3b06e95294a10112 Reviewed-on: http://codereview.qt-project.org/5100 Reviewed-by: Morten Johan Sørvig Sanity-Review: Morten Johan Sørvig --- src/printsupport/dialogs/qpagesetupdialog_mac.mm | 110 ----------------------- 1 file changed, 110 deletions(-) (limited to 'src/printsupport/dialogs/qpagesetupdialog_mac.mm') diff --git a/src/printsupport/dialogs/qpagesetupdialog_mac.mm b/src/printsupport/dialogs/qpagesetupdialog_mac.mm index 725520116a..0bbdbcc242 100644 --- a/src/printsupport/dialogs/qpagesetupdialog_mac.mm +++ b/src/printsupport/dialogs/qpagesetupdialog_mac.mm @@ -96,110 +96,19 @@ class QPageSetupDialogPrivate : public QAbstractPageSetupDialogPrivate public: QPageSetupDialogPrivate() : ep(0) -#ifndef QT_MAC_USE_COCOA - ,upp(0) -#else ,pageLayout(0) -#endif {} ~QPageSetupDialogPrivate() { -#ifndef QT_MAC_USE_COCOA - if (upp) { - DisposePMSheetDoneUPP(upp); - upp = 0; - } - QHash::iterator it = sheetCallbackMap.begin(); - while (it != sheetCallbackMap.end()) { - if (it.value() == this) { - it = sheetCallbackMap.erase(it); - } else { - ++it; - } - } -#endif } -#ifndef QT_MAC_USE_COCOA - void openCarbonPageLayout(Qt::WindowModality modality); - void closeCarbonPageLayout(); - static void pageSetupDialogSheetDoneCallback(PMPrintSession printSession, WindowRef /*documentWindow*/, Boolean accepted) { - QPageSetupDialogPrivate *priv = sheetCallbackMap.value(printSession); - if (!priv) { - qWarning("%s:%d: QPageSetupDialog::exec: Could not retrieve data structure, " - "you most likely now have an infinite modal loop", __FILE__, __LINE__); - return; - } - priv->q_func()->done(accepted ? QDialog::Accepted : QDialog::Rejected); - } -#else void openCocoaPageLayout(Qt::WindowModality modality); void closeCocoaPageLayout(); -#endif QMacPrintEnginePrivate *ep; -#ifndef QT_MAC_USE_COCOA - PMSheetDoneUPP upp; - static QHash sheetCallbackMap; -#else NSPageLayout *pageLayout; -#endif }; -#ifndef QT_MAC_USE_COCOA -QHash QPageSetupDialogPrivate::sheetCallbackMap; -void QPageSetupDialogPrivate::openCarbonPageLayout(Qt::WindowModality modality) -{ - Q_Q(QPageSetupDialog); - // If someone is reusing a QPrinter object, the end released all our old - // information. In this case, we must reinitialize. - if (ep->session == 0) - ep->initialize(); - - sheetCallbackMap.insert(ep->session, this); - if (modality == Qt::ApplicationModal) { - QWidget modal_widg(0, Qt::Window); - modal_widg.setObjectName(QLatin1String(__FILE__ "__modal_dlg")); - modal_widg.createWinId(); - QApplicationPrivate::enterModal(&modal_widg); - QApplicationPrivate::native_modal_dialog_active = true; - Boolean accepted; - PMSessionPageSetupDialog(ep->session, ep->format, &accepted); - QApplicationPrivate::leaveModal(&modal_widg); - QApplicationPrivate::native_modal_dialog_active = false; - pageSetupDialogSheetDoneCallback(ep->session, 0, accepted); - } else { - // Window Modal means that we use a sheet at the moment, there's no other way to do it correctly. - if (!upp) - upp = NewPMSheetDoneUPP(QPageSetupDialogPrivate::pageSetupDialogSheetDoneCallback); - PMSessionUseSheets(ep->session, qt_mac_window_for(q->parentWidget()), upp); - Boolean unused; - PMSessionPageSetupDialog(ep->session, ep->format, &unused); - } -} - -void QPageSetupDialogPrivate::closeCarbonPageLayout() -{ - // if the margins have changed, we have to use the margins from the new - // PMFormat object - if (q_func()->result() == QDialog::Accepted) { - PMPaper paper; - PMPaperMargins margins; - PMGetPageFormatPaper(ep->format, &paper); - PMPaperGetMargins(paper, &margins); - ep->leftMargin = margins.left; - ep->topMargin = margins.top; - ep->rightMargin = margins.right; - ep->bottomMargin = margins.bottom; - - PMRect paperRect; - PMGetUnadjustedPaperRect(ep->format, &paperRect); - ep->customSize = QSizeF(paperRect.right - paperRect.left, - paperRect.bottom - paperRect.top); - } - sheetCallbackMap.remove(ep->session); -} -#else void QPageSetupDialogPrivate::openCocoaPageLayout(Qt::WindowModality modality) { Q_Q(QPageSetupDialog); @@ -240,7 +149,6 @@ void QPageSetupDialogPrivate::closeCocoaPageLayout() [pageLayout release]; pageLayout = 0; } -#endif QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent) : QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), printer, parent) @@ -263,32 +171,19 @@ void QPageSetupDialog::setVisible(bool visible) if (d->printer->outputFormat() != QPrinter::NativeFormat) return; -#ifndef QT_MAC_USE_COCOA - bool isCurrentlyVisible = d->sheetCallbackMap.contains(d->ep->session); -#else bool isCurrentlyVisible = (d->pageLayout != 0); -#endif if (!visible == !isCurrentlyVisible) return; if (visible) { -#ifndef QT_MAC_USE_COCOA - d->openCarbonPageLayout(parentWidget() ? Qt::WindowModal - : Qt::ApplicationModal); -#else d->openCocoaPageLayout(parentWidget() ? Qt::WindowModal : Qt::ApplicationModal); -#endif return; } else { -#ifndef QT_MAC_USE_COCOA - d->closeCarbonPageLayout(); -#else if (d->pageLayout) { d->closeCocoaPageLayout(); return; } -#endif } } @@ -299,14 +194,9 @@ int QPageSetupDialog::exec() if (d->printer->outputFormat() != QPrinter::NativeFormat) return Rejected; -#ifndef QT_MAC_USE_COCOA - d->openCarbonPageLayout(Qt::ApplicationModal); - d->closeCarbonPageLayout(); -#else QMacCocoaAutoReleasePool pool; d->openCocoaPageLayout(Qt::ApplicationModal); d->closeCocoaPageLayout(); -#endif return result(); } -- cgit v1.2.3