PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/qt-everywhere-opensource-src-4.8.2/src/gui/dialogs/qabstractpagesetupdialog.cpp

#
C++ | 139 lines | 58 code | 15 blank | 66 comment | 6 complexity | 9edec33b0b4bb7e88509fd904fc92280 MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0, MPL-2.0-no-copyleft-exception, CC-BY-SA-4.0, LGPL-3.0, GPL-2.0, LGPL-2.0, LGPL-2.1, GPL-3.0
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
  4. ** All rights reserved.
  5. ** Contact: Nokia Corporation (qt-info@nokia.com)
  6. **
  7. ** This file is part of the QtGui module of the Qt Toolkit.
  8. **
  9. ** $QT_BEGIN_LICENSE:LGPL$
  10. ** GNU Lesser General Public License Usage
  11. ** This file may be used under the terms of the GNU Lesser General Public
  12. ** License version 2.1 as published by the Free Software Foundation and
  13. ** appearing in the file LICENSE.LGPL included in the packaging of this
  14. ** file. Please review the following information to ensure the GNU Lesser
  15. ** General Public License version 2.1 requirements will be met:
  16. ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  17. **
  18. ** In addition, as a special exception, Nokia gives you certain additional
  19. ** rights. These rights are described in the Nokia Qt LGPL Exception
  20. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  21. **
  22. ** GNU General Public License Usage
  23. ** Alternatively, this file may be used under the terms of the GNU General
  24. ** Public License version 3.0 as published by the Free Software Foundation
  25. ** and appearing in the file LICENSE.GPL included in the packaging of this
  26. ** file. Please review the following information to ensure the GNU General
  27. ** Public License version 3.0 requirements will be met:
  28. ** http://www.gnu.org/copyleft/gpl.html.
  29. **
  30. ** Other Usage
  31. ** Alternatively, this file may be used in accordance with the terms and
  32. ** conditions contained in a signed written agreement between you and Nokia.
  33. **
  34. **
  35. **
  36. **
  37. **
  38. ** $QT_END_LICENSE$
  39. **
  40. ****************************************************************************/
  41. #include "qabstractpagesetupdialog.h"
  42. #include "qabstractpagesetupdialog_p.h"
  43. #ifndef QT_NO_PRINTDIALOG
  44. #include <QtCore/qcoreapplication.h>
  45. #include <QtGui/qprinter.h>
  46. QT_BEGIN_NAMESPACE
  47. /*!
  48. \internal
  49. \class QAbstractPageSetupDialog
  50. \brief The QAbstractPageSetupDialog class provides a base for
  51. implementations of page setup dialogs.
  52. */
  53. /*!
  54. Constructs the page setup dialog for the printer \a printer with
  55. \a parent as parent widget.
  56. */
  57. QAbstractPageSetupDialog::QAbstractPageSetupDialog(QPrinter *printer, QWidget *parent)
  58. : QDialog(*(new QAbstractPageSetupDialogPrivate), parent)
  59. {
  60. Q_D(QAbstractPageSetupDialog);
  61. setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup"));
  62. d->setPrinter(printer);
  63. }
  64. /*!
  65. \internal
  66. */
  67. QAbstractPageSetupDialog::QAbstractPageSetupDialog(QAbstractPageSetupDialogPrivate &ptr,
  68. QPrinter *printer, QWidget *parent)
  69. : QDialog(ptr, parent)
  70. {
  71. Q_D(QAbstractPageSetupDialog);
  72. setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup"));
  73. d->setPrinter(printer);
  74. }
  75. QAbstractPageSetupDialog::~QAbstractPageSetupDialog()
  76. {
  77. Q_D(QAbstractPageSetupDialog);
  78. if (d->opts & QPageSetupDialog::OwnsPrinter)
  79. delete d->printer;
  80. }
  81. /*!
  82. Returns the printer that this page setup dialog is operating on.
  83. */
  84. QPrinter *QAbstractPageSetupDialog::printer()
  85. {
  86. Q_D(QAbstractPageSetupDialog);
  87. return d->printer;
  88. }
  89. void QAbstractPageSetupDialogPrivate::setPrinter(QPrinter *newPrinter)
  90. {
  91. if (newPrinter) {
  92. printer = newPrinter;
  93. } else {
  94. printer = new QPrinter;
  95. opts |= QPageSetupDialog::OwnsPrinter;
  96. }
  97. #ifndef Q_WS_X11
  98. if (printer->outputFormat() != QPrinter::NativeFormat)
  99. qWarning("QPageSetupDialog: Cannot be used on non-native printers");
  100. #endif
  101. }
  102. /*!
  103. \fn int QAbstractPageSetupDialog::exec()
  104. This virtual function is called to pop up the dialog. It must be
  105. reimplemented in subclasses.
  106. */
  107. /*!
  108. \reimp
  109. */
  110. void QAbstractPageSetupDialog::done(int result)
  111. {
  112. Q_D(QAbstractPageSetupDialog);
  113. QDialog::done(result);
  114. if (d->receiverToDisconnectOnClose) {
  115. disconnect(this, SIGNAL(accepted()),
  116. d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
  117. d->receiverToDisconnectOnClose = 0;
  118. }
  119. d->memberToDisconnectOnClose.clear();
  120. }
  121. QT_END_NAMESPACE
  122. #endif // QT_NO_PRINTDIALOG