summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2010-12-01 12:31:19 +0300
committeraxis <qt-info@nokia.com>2010-12-20 16:14:15 +0100
commit2cf77579cf41594e036beeacf3dc3b6aa9f05cfa (patch)
tree9bc096c8ee45e139fd912e9f6af5ae7880b884a7 /src
parentf725c90032b83df62432018af362830e899e71c1 (diff)
refactoring of QPrinterInfo
move QPrinterInfoPrivate to it's own header file; rename qprinterinfo.qdoc to qprinterinfo.cpp to make it consistent with others; squash the duplicated code into qprinterinfo.cpp; avoid extra d_ptr assignments in the QPrinterInfo copying c-tor; simplify the QPrinterInfo from QPrinter c-tor code; fix styling and few method param names; remove the `m_` prefix of QPrinterInfoPrivate's members (as they are members of a private class anyway ;P) remove the boilerplates Merge-request: 2516 Signed-off-by: axis
Diffstat (limited to 'src')
-rw-r--r--src/gui/painting/painting.pri2
-rw-r--r--src/gui/painting/qprinterinfo.cpp (renamed from src/gui/painting/qprinterinfo.qdoc)82
-rw-r--r--src/gui/painting/qprinterinfo.h15
-rw-r--r--src/gui/painting/qprinterinfo_mac.cpp100
-rw-r--r--src/gui/painting/qprinterinfo_p.h108
-rw-r--r--src/gui/painting/qprinterinfo_unix.cpp159
-rw-r--r--src/gui/painting/qprinterinfo_win.cpp106
7 files changed, 209 insertions, 363 deletions
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index 099619c353..51f2538a83 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -34,6 +34,7 @@ HEADERS += \
painting/qprinter.h \
painting/qprinter_p.h \
painting/qprinterinfo.h \
+ painting/qprinterinfo_p.h \
painting/qrasterizer_p.h \
painting/qregion.h \
painting/qstroker_p.h \
@@ -73,6 +74,7 @@ SOURCES += \
painting/qprintengine_pdf.cpp \
painting/qprintengine_ps.cpp \
painting/qprinter.cpp \
+ painting/qprinterinfo.cpp \
painting/qrasterizer.cpp \
painting/qregion.cpp \
painting/qstroker.cpp \
diff --git a/src/gui/painting/qprinterinfo.qdoc b/src/gui/painting/qprinterinfo.cpp
index 9193213bb9..21d56f3746 100644
--- a/src/gui/painting/qprinterinfo.qdoc
+++ b/src/gui/painting/qprinterinfo.cpp
@@ -25,6 +25,16 @@
**
****************************************************************************/
+#include "qprinterinfo.h"
+#include "qprinterinfo_p.h"
+
+#ifndef QT_NO_PRINTER
+
+QT_BEGIN_NAMESPACE
+
+QPrinterInfoPrivate QPrinterInfoPrivate::shared_null;
+
+
/*!
\class QPrinterInfo
@@ -59,60 +69,94 @@
*/
/*!
- \fn QPrinterInfo::QPrinterInfo()
-
Constructs an empty QPrinterInfo object.
\sa isNull()
*/
+QPrinterInfo::QPrinterInfo()
+ : d_ptr(&QPrinterInfoPrivate::shared_null)
+{
+}
/*!
- \fn QPrinterInfo::QPrinterInfo(const QPrinterInfo& src)
-
- Constructs a copy of \a src.
+ Constructs a copy of \a other.
*/
+QPrinterInfo::QPrinterInfo(const QPrinterInfo &other)
+ : d_ptr(new QPrinterInfoPrivate(*other.d_ptr))
+{
+}
/*!
- \fn QPrinterInfo::QPrinterInfo(const QPrinter& printer)
-
Constructs a QPrinterInfo object from \a printer.
*/
+QPrinterInfo::QPrinterInfo(const QPrinter &printer)
+ : d_ptr(&QPrinterInfoPrivate::shared_null)
+{
+ foreach (const QPrinterInfo &printerInfo, availablePrinters()) {
+ if (printerInfo.printerName() == printer.printerName()) {
+ d_ptr.reset(new QPrinterInfoPrivate(*printerInfo.d_ptr));
+ break;
+ }
+ }
+}
/*!
- \fn QPrinterInfo::~QPrinterInfo()
+ \internal
+*/
+QPrinterInfo::QPrinterInfo(const QString &name)
+ : d_ptr(new QPrinterInfoPrivate(name))
+{
+}
+/*!
Destroys the QPrinterInfo object. References to the values in the
object become invalid.
*/
+QPrinterInfo::~QPrinterInfo()
+{
+}
/*!
- \fn QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
-
- Sets the QPrinterInfo object to be equal to \a src.
+ Sets the QPrinterInfo object to be equal to \a other.
*/
+QPrinterInfo &QPrinterInfo::operator=(const QPrinterInfo &other)
+{
+ Q_ASSERT(d_ptr);
+ d_ptr.reset(new QPrinterInfoPrivate(*other.d_ptr));
+ return *this;
+}
/*!
- \fn QString QPrinterInfo::printerName() const
-
Returns the name of the printer.
\sa QPrinter::setPrinterName()
*/
+QString QPrinterInfo::printerName() const
+{
+ const Q_D(QPrinterInfo);
+ return d->name;
+}
/*!
- \fn bool QPrinterInfo::isNull() const
-
Returns whether this QPrinterInfo object holds a printer definition.
An empty QPrinterInfo object could result for example from calling
defaultPrinter() when there are no printers on the system.
*/
+bool QPrinterInfo::isNull() const
+{
+ const Q_D(QPrinterInfo);
+ return d->isNull;
+}
/*!
- \fn bool QPrinterInfo::isDefault() const
-
Returns whether this printer is the default printer.
*/
+bool QPrinterInfo::isDefault() const
+{
+ const Q_D(QPrinterInfo);
+ return d->isDefault;
+}
/*!
\fn QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
@@ -123,3 +167,7 @@
Not all printer drivers support this query, so the list may be empty.
On Mac OS X 10.3, this function always returns an empty list.
*/
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_PRINTER
diff --git a/src/gui/painting/qprinterinfo.h b/src/gui/painting/qprinterinfo.h
index 063c6b90e9..c8c9534502 100644
--- a/src/gui/painting/qprinterinfo.h
+++ b/src/gui/painting/qprinterinfo.h
@@ -42,9 +42,10 @@
#ifndef QPRINTERINFO_H
#define QPRINTERINFO_H
-#include <QtGui/QPrinter>
#include <QtCore/QList>
+#include <QtGui/QPrinter>
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -56,15 +57,13 @@ class QPrinterInfoPrivate;
class QPrinterInfoPrivateDeleter;
class Q_GUI_EXPORT QPrinterInfo
{
-Q_DECLARE_PRIVATE(QPrinterInfo)
-
public:
QPrinterInfo();
- QPrinterInfo(const QPrinterInfo& src);
- QPrinterInfo(const QPrinter& printer);
+ QPrinterInfo(const QPrinterInfo &other);
+ QPrinterInfo(const QPrinter &printer);
~QPrinterInfo();
- QPrinterInfo& operator=(const QPrinterInfo& src);
+ QPrinterInfo &operator=(const QPrinterInfo &other);
QString printerName() const;
bool isNull() const;
@@ -75,8 +74,10 @@ public:
static QPrinterInfo defaultPrinter();
private:
- QPrinterInfo(const QString& name);
+ QPrinterInfo(const QString &name);
+private:
+ Q_DECLARE_PRIVATE(QPrinterInfo)
QScopedPointer<QPrinterInfoPrivate, QPrinterInfoPrivateDeleter> d_ptr;
};
diff --git a/src/gui/painting/qprinterinfo_mac.cpp b/src/gui/painting/qprinterinfo_mac.cpp
index 6a48c91d9e..9d0e88623a 100644
--- a/src/gui/painting/qprinterinfo_mac.cpp
+++ b/src/gui/painting/qprinterinfo_mac.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qprinterinfo.h"
+#include "qprinterinfo_p.h"
#include "private/qt_mac_p.h"
@@ -47,40 +48,7 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_PRINTER
-class QPrinterInfoPrivate
-{
-public:
- QPrinterInfoPrivate() :
- m_isNull(true), m_default(false)
- {}
- QPrinterInfoPrivate(const QString& name) :
- m_name(name),
- m_isNull(false), m_default(false)
- {}
- ~QPrinterInfoPrivate()
- {}
-
- QString m_name;
- bool m_isNull;
- bool m_default;
-};
-
-static QPrinterInfoPrivate nullQPrinterInfoPrivate;
-
-class QPrinterInfoPrivateDeleter
-{
-public:
- static inline void cleanup(QPrinterInfoPrivate *d)
- {
- if (d != &nullQPrinterInfoPrivate)
- delete d;
- }
-};
-
-extern QPrinter::PaperSize qSizeFTopaperSize(const QSizeF& size);
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
+extern QPrinter::PaperSize qSizeFTopaperSize(const QSizeF &size);
QList<QPrinterInfo> QPrinterInfo::availablePrinters()
{
@@ -96,7 +64,7 @@ QList<QPrinterInfo> QPrinterInfo::availablePrinters()
QString name = QCFString::toQString(PMPrinterGetName(printer));
printers.append(QPrinterInfo(name));
if (PMPrinterIsDefault(printer)) {
- printers[i].d_ptr->m_default = true;
+ printers[i].d_ptr->isDefault = true;
}
}
}
@@ -114,71 +82,11 @@ QPrinterInfo QPrinterInfo::defaultPrinter(){
return QPrinterInfo();
}
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-QPrinterInfo::QPrinterInfo(const QPrinter& prn)
- : d_ptr(&nullQPrinterInfoPrivate)
-{
- QList<QPrinterInfo> list = availablePrinters();
- for (int c = 0; c < list.size(); ++c) {
- if (prn.printerName() == list[c].printerName()) {
- *this = list[c];
- return;
- }
- }
-}
-
-QPrinterInfo::~QPrinterInfo()
-{
-}
-
-QPrinterInfo::QPrinterInfo()
- : d_ptr(&nullQPrinterInfoPrivate)
-{
-}
-
-QPrinterInfo::QPrinterInfo(const QString& name)
- : d_ptr(new QPrinterInfoPrivate(name))
-{
-}
-
-QPrinterInfo::QPrinterInfo(const QPrinterInfo& src)
- : d_ptr(&nullQPrinterInfoPrivate)
-{
- *this = src;
-}
-
-QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
-{
- Q_ASSERT(d_ptr);
- d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr));
- return *this;
-}
-
-QString QPrinterInfo::printerName() const
-{
- const Q_D(QPrinterInfo);
- return d->m_name;
-}
-
-bool QPrinterInfo::isNull() const
-{
- const Q_D(QPrinterInfo);
- return d->m_isNull;
-}
-
-bool QPrinterInfo::isDefault() const
-{
- const Q_D(QPrinterInfo);
- return d->m_default;
-}
-
QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
{
const Q_D(QPrinterInfo);
- PMPrinter cfPrn = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(d->m_name));
+ PMPrinter cfPrn = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(d->name));
if (!cfPrn) return QList<QPrinter::PaperSize>();
diff --git a/src/gui/painting/qprinterinfo_p.h b/src/gui/painting/qprinterinfo_p.h
new file mode 100644
index 0000000000..f5981d423d
--- /dev/null
+++ b/src/gui/painting/qprinterinfo_p.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPRINTERINFO_P_H
+#define QPRINTERINFO_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtCore/qglobal.h"
+
+#ifndef QT_NO_PRINTER
+
+#include "QtCore/qlist.h"
+
+QT_BEGIN_NAMESPACE
+
+class QPrinterInfoPrivate
+{
+public:
+ QPrinterInfoPrivate(const QString& name = QString()) :
+ name(name), isNull(false), isDefault(false)
+#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN)) || defined(Q_WS_QPA)
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ , cupsPrinterIndex(0), hasPaperSizes(false)
+#endif
+#endif
+ {}
+ ~QPrinterInfoPrivate()
+ {}
+
+ static QPrinterInfoPrivate shared_null;
+
+ QString name;
+ bool isNull;
+ bool isDefault;
+
+#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN)) || defined(Q_WS_QPA)
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ int cupsPrinterIndex;
+ mutable bool hasPaperSizes;
+ mutable QList<QPrinter::PaperSize> paperSizes;
+#endif
+#endif
+};
+
+
+class QPrinterInfoPrivateDeleter
+{
+public:
+ static inline void cleanup(QPrinterInfoPrivate *d)
+ {
+ if (d != &QPrinterInfoPrivate::shared_null)
+ delete d;
+ }
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_PRINTER
+
+#endif // QPRINTERINFO_P_H
diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp
index eb16a1bb5f..c30fcb492f 100644
--- a/src/gui/painting/qprinterinfo_unix.cpp
+++ b/src/gui/painting/qprinterinfo_unix.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qprinterinfo.h"
+#include "qprinterinfo_p.h"
#include <qfile.h>
#include <qfileinfo.h>
@@ -121,46 +122,6 @@ static inline const char *paperSize2String(QPrinter::PaperSize size)
}
#endif
-
-class QPrinterInfoPrivate
-{
-public:
- QPrinterInfoPrivate() :
- m_isNull(true), m_default(false),
- m_mustGetPaperSizes(true), m_cupsPrinterIndex(0)
- {}
- QPrinterInfoPrivate(const QString& name) :
- m_name(name),
- m_isNull(false), m_default(false),
- m_mustGetPaperSizes(true), m_cupsPrinterIndex(0)
- {}
- ~QPrinterInfoPrivate()
- {}
-
- QString m_name;
- bool m_isNull;
- bool m_default;
-
- mutable bool m_mustGetPaperSizes;
- mutable QList<QPrinter::PaperSize> m_paperSizes;
- int m_cupsPrinterIndex;
-};
-
-static QPrinterInfoPrivate nullQPrinterInfoPrivate;
-
-class QPrinterInfoPrivateDeleter
-{
-public:
- static inline void cleanup(QPrinterInfoPrivate *d)
- {
- if (d != &nullQPrinterInfoPrivate)
- delete d;
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
void qt_perhapsAddPrinter(QList<QPrinterDescription> *printers, const QString &name,
QString host, QString comment,
QStringList aliases)
@@ -891,9 +852,8 @@ QList<QPrinterInfo> QPrinterInfo::availablePrinters()
QList<QPrinterInfo> list;
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- QCUPSSupport cups;
if (QCUPSSupport::isAvailable()) {
- //const ppd_file_t* cupsPPD = cups.currentPPD();
+ QCUPSSupport cups;
int cupsPrinterCount = cups.availablePrintersCount();
const cups_dest_t* cupsPrinters = cups.availablePrinters();
@@ -903,8 +863,8 @@ QList<QPrinterInfo> QPrinterInfo::availablePrinters()
printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance);
list.append(QPrinterInfo(printerName));
if (cupsPrinters[i].is_default)
- list[i].d_ptr->m_default = true;
- list[i].d_ptr->m_cupsPrinterIndex = i;
+ list[i].d_ptr->isDefault = true;
+ list[i].d_ptr->cupsPrinterIndex = i;
}
} else {
#endif
@@ -916,7 +876,7 @@ QList<QPrinterInfo> QPrinterInfo::availablePrinters()
list.append(QPrinterInfo((*i).name));
}
if (defprn >= 0 && defprn < lprPrinters.size()) {
- list[defprn].d_ptr->m_default = true;
+ list[defprn].d_ptr->isDefault = true;
}
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
}
@@ -935,117 +895,30 @@ QPrinterInfo QPrinterInfo::defaultPrinter()
return (prnList.size() > 0) ? prnList[0] : QPrinterInfo();
}
-QPrinterInfo::QPrinterInfo()
- : d_ptr(&nullQPrinterInfoPrivate)
+QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
{
-}
-
-QPrinterInfo::QPrinterInfo(const QPrinterInfo& src)
- : d_ptr(&nullQPrinterInfoPrivate)
-{
- *this = src;
-}
-
-QPrinterInfo::QPrinterInfo(const QPrinter& printer)
- : d_ptr(new QPrinterInfoPrivate(printer.printerName()))
-{
-
- Q_D(QPrinterInfo);
-
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- QCUPSSupport cups;
- if (QCUPSSupport::isAvailable()) {
- int cupsPrinterCount = cups.availablePrintersCount();
- const cups_dest_t* cupsPrinters = cups.availablePrinters();
-
- for (int i = 0; i < cupsPrinterCount; ++i) {
- QString printerName(QString::fromLocal8Bit(cupsPrinters[i].name));
- if (cupsPrinters[i].instance)
- printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance);
- if (printerName == printer.printerName()) {
- if (cupsPrinters[i].is_default)
- d->m_default = true;
- d->m_cupsPrinterIndex = i;
- return;
- }
- }
- } else {
-#endif
- QList<QPrinterDescription> lprPrinters;
- int defprn = qt_getLprPrinters(lprPrinters);
- // populating printer combo
- QList<QPrinterDescription>::const_iterator i = lprPrinters.constBegin();
- int c;
- for(c = 0; i != lprPrinters.constEnd(); ++i, ++c) {
- if (i->name == printer.printerName()) {
- if (defprn == c)
- d->m_default = true;
- return;
- }
- }
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- }
-#endif
-
- // Printer not found.
- d_ptr.reset(&nullQPrinterInfoPrivate);
-}
-
-QPrinterInfo::QPrinterInfo(const QString& name)
- : d_ptr(new QPrinterInfoPrivate(name))
-{
-}
-
-QPrinterInfo::~QPrinterInfo()
-{
-}
-
-QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
-{
- Q_ASSERT(d_ptr);
- d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr));
- return *this;
-}
-
-QString QPrinterInfo::printerName() const
-{
const Q_D(QPrinterInfo);
- return d->m_name;
-}
-
-bool QPrinterInfo::isNull() const
-{
- const Q_D(QPrinterInfo);
- return d->m_isNull;
-}
-
-bool QPrinterInfo::isDefault() const
-{
- const Q_D(QPrinterInfo);
- return d->m_default;
-}
-QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
-{
- const Q_D(QPrinterInfo);
- if (d->m_mustGetPaperSizes) {
- d->m_mustGetPaperSizes = false;
+ if (!d->hasPaperSizes) {
+ d->hasPaperSizes = true;
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- QCUPSSupport cups;
if (QCUPSSupport::isAvailable()) {
// Find paper sizes from CUPS.
- cups.setCurrentPrinter(d->m_cupsPrinterIndex);
+ QCUPSSupport cups;
+ cups.setCurrentPrinter(d->cupsPrinterIndex);
const ppd_option_t* sizes = cups.pageSizes();
if (sizes) {
for (int j = 0; j < sizes->num_choices; ++j)
- d->m_paperSizes.append(string2PaperSize(sizes->choices[j].choice));
+ d->paperSizes.append(string2PaperSize(sizes->choices[j].choice));
}
}
-#endif
-
}
- return d->m_paperSizes;
+
+ return d->paperSizes;
+#else
+ return QList<QPrinter::PaperSize>();
+#endif
}
#endif // QT_NO_PRINTER
diff --git a/src/gui/painting/qprinterinfo_win.cpp b/src/gui/painting/qprinterinfo_win.cpp
index 808de2cb61..962aa2d3e3 100644
--- a/src/gui/painting/qprinterinfo_win.cpp
+++ b/src/gui/painting/qprinterinfo_win.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qprinterinfo.h"
+#include "qprinterinfo_p.h"
#include <qstringlist.h>
@@ -51,39 +52,6 @@ QT_BEGIN_NAMESPACE
extern QPrinter::PaperSize mapDevmodePaperSize(int s);
-class QPrinterInfoPrivate
-{
-public:
- QPrinterInfoPrivate() :
- m_isNull(true), m_default(false)
- {}
- QPrinterInfoPrivate(const QString& name) :
- m_name(name),
- m_isNull(false), m_default(false)
- {}
- ~QPrinterInfoPrivate()
- {}
-
- QString m_name;
- bool m_isNull;
- bool m_default;
-};
-
-static QPrinterInfoPrivate nullQPrinterInfoPrivate;
-
-class QPrinterInfoPrivateDeleter
-{
-public:
- static inline void cleanup(QPrinterInfoPrivate *d)
- {
- if (d != &nullQPrinterInfoPrivate)
- delete d;
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
QList<QPrinterInfo> QPrinterInfo::availablePrinters()
{
QList<QPrinterInfo> printers;
@@ -105,7 +73,7 @@ QList<QPrinterInfo> QPrinterInfo::availablePrinters()
for (uint i = 0; i < returned; ++i) {
printers.append(QPrinterInfo(QString::fromWCharArray(infoList[i].pPrinterName)));
if (printers.at(i).printerName() == defPrn.printerName())
- printers[i].d_ptr->m_default = true;
+ printers[i].d_ptr->isDefault = true;
}
delete [] buffer;
}
@@ -127,86 +95,24 @@ QPrinterInfo QPrinterInfo::defaultPrinter()
QString printerName = noConfiguredPrinters ? QString() : info.at(0);
QPrinterInfo prn(printerName);
- prn.d_ptr->m_default = true;
+ prn.d_ptr->isDefault = true;
if (noConfiguredPrinters)
- prn.d_ptr->m_isNull = true;
+ prn.d_ptr->isNull = true;
return prn;
}
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-QPrinterInfo::QPrinterInfo()
- : d_ptr(&nullQPrinterInfoPrivate)
-{
-}
-
-QPrinterInfo::QPrinterInfo(const QString& name)
- : d_ptr(new QPrinterInfoPrivate(name))
-{
-}
-
-QPrinterInfo::QPrinterInfo(const QPrinterInfo& src)
- : d_ptr(&nullQPrinterInfoPrivate)
-{
- *this = src;
-}
-
-QPrinterInfo::QPrinterInfo(const QPrinter& prn)
- : d_ptr(&nullQPrinterInfoPrivate)
-{
- QList<QPrinterInfo> list = availablePrinters();
- for (int c = 0; c < list.size(); ++c) {
- if (prn.printerName() == list[c].printerName()) {
- *this = list[c];
- return;
- }
- }
-
- *this = QPrinterInfo();
-}
-
-QPrinterInfo::~QPrinterInfo()
-{
-}
-
-QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
-{
- Q_ASSERT(d_ptr);
- d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr));
- return *this;
-}
-
-QString QPrinterInfo::printerName() const
-{
- const Q_D(QPrinterInfo);
- return d->m_name;
-}
-
-bool QPrinterInfo::isNull() const
-{
- const Q_D(QPrinterInfo);
- return d->m_isNull;
-}
-
-bool QPrinterInfo::isDefault() const
-{
- const Q_D(QPrinterInfo);
- return d->m_default;
-}
-
QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
{
const Q_D(QPrinterInfo);
QList<QPrinter::PaperSize> paperList;
- DWORD size = DeviceCapabilities(reinterpret_cast<const wchar_t*>(d->m_name.utf16()),
+ DWORD size = DeviceCapabilities(reinterpret_cast<const wchar_t*>(d->name.utf16()),
NULL, DC_PAPERS, NULL, NULL);
if ((int)size == -1)
return paperList;
wchar_t *papers = new wchar_t[size];
- size = DeviceCapabilities(reinterpret_cast<const wchar_t*>(d->m_name.utf16()),
+ size = DeviceCapabilities(reinterpret_cast<const wchar_t*>(d->name.utf16()),
NULL, DC_PAPERS, papers, NULL);
for (int c = 0; c < (int)size; ++c) {