From 6d6c738879bb2ef5b5c1e42908bdd1ed16980f95 Mon Sep 17 00:00:00 2001
From: Konstantin Ritt <ritt.ks@gmail.com>
Date: Wed, 1 Dec 2010 12:13:27 +0300
Subject: use binary search int the string2PaperSize() helper

since it is much much faster

Merge-request: 2516
Signed-off-by: axis
---
 src/gui/painting/qprinterinfo_unix.cpp | 207 ++++++++++-----------------------
 1 file changed, 64 insertions(+), 143 deletions(-)

diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp
index 2129aa5..0d4cc16 100644
--- a/src/gui/painting/qprinterinfo_unix.cpp
+++ b/src/gui/painting/qprinterinfo_unix.cpp
@@ -60,6 +60,68 @@ QT_BEGIN_NAMESPACE
 
 #ifndef QT_NO_PRINTER
 
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+// preserver names in ascending order for the binary search
+static const struct NamedPaperSize {
+    const char *const name;
+    QPrinter::PaperSize size;
+} named_sizes_map[QPrinter::NPageSize] = {
+    { "A0", QPrinter::A0 },
+    { "A1", QPrinter::A1 },
+    { "A2", QPrinter::A2 },
+    { "A3", QPrinter::A3 },
+    { "A4", QPrinter::A4 },
+    { "A5", QPrinter::A5 },
+    { "A6", QPrinter::A6 },
+    { "A7", QPrinter::A7 },
+    { "A8", QPrinter::A8 },
+    { "A9", QPrinter::A9 },
+    { "B0", QPrinter::B0 },
+    { "B1", QPrinter::B1 },
+    { "B10", QPrinter::B10 },
+    { "B2", QPrinter::B2 },
+    { "B4", QPrinter::B4 },
+    { "B5", QPrinter::B5 },
+    { "B6", QPrinter::B6 },
+    { "B7", QPrinter::B7 },
+    { "B8", QPrinter::B8 },
+    { "B9", QPrinter::B9 },
+    { "C5E", QPrinter::C5E },
+    { "Comm10E", QPrinter::Comm10E },
+    { "Custom", QPrinter::Custom },
+    { "DLE", QPrinter::DLE },
+    { "Executive", QPrinter::Executive },
+    { "Folio", QPrinter::Folio },
+    { "Ledger", QPrinter::Ledger },
+    { "Legal", QPrinter::Legal },
+    { "Letter", QPrinter::Letter },
+    { "Tabloid", QPrinter::Tabloid }
+};
+
+inline bool operator<(const char *name, const NamedPaperSize &data)
+{ return qstrcmp(name, data.name) < 0; }
+inline bool operator<(const NamedPaperSize &data, const char *name)
+{ return qstrcmp(data.name, name) < 0; }
+
+static inline QPrinter::PaperSize string2PaperSize(const char *name)
+{
+    const NamedPaperSize *r = qBinaryFind(named_sizes_map, named_sizes_map + QPrinter::NPageSize, name);
+    if (r - named_sizes_map != QPrinter::NPageSize)
+        return r->size;
+    return QPrinter::Custom;
+}
+
+static inline const char *paperSize2String(QPrinter::PaperSize size)
+{
+    for (int i = 0; i < QPrinter::NPageSize; ++i) {
+        if (size == named_sizes_map[i].size)
+            return named_sizes_map[i].name;
+    }
+    return 0;
+}
+#endif
+
+
 class QPrinterInfoPrivate
 {
 Q_DECLARE_PUBLIC(QPrinterInfo)
@@ -68,9 +130,6 @@ public:
     QPrinterInfoPrivate(const QString& name);
     ~QPrinterInfoPrivate();
 
-    static QPrinter::PaperSize string2PaperSize(const QString& str);
-    static QString pageSize2String(QPrinter::PaperSize size);
-
 private:
     QString                     m_name;
     bool                        m_isNull;
@@ -977,11 +1036,8 @@ QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
             cups.setCurrentPrinter(d->m_cupsPrinterIndex);
             const ppd_option_t* sizes = cups.pageSizes();
             if (sizes) {
-                for (int j = 0; j < sizes->num_choices; ++j) {
-                    d->m_paperSizes.append(
-                        QPrinterInfoPrivate::string2PaperSize(
-                            QLatin1String(sizes->choices[j].choice)));
-                }
+                for (int j = 0; j < sizes->num_choices; ++j)
+                    d->m_paperSizes.append(string2PaperSize(sizes->choices[j].choice));
             }
         }
 #endif
@@ -1016,141 +1072,6 @@ QPrinterInfoPrivate::~QPrinterInfoPrivate()
 {
 }
 
-QPrinter::PaperSize QPrinterInfoPrivate::string2PaperSize(const QString& str)
-{
-    if (str == QLatin1String("A4")) {
-        return QPrinter::A4;
-    } else if (str == QLatin1String("B5")) {
-        return QPrinter::B5;
-    } else if (str == QLatin1String("Letter")) {
-        return QPrinter::Letter;
-    } else if (str == QLatin1String("Legal")) {
-        return QPrinter::Legal;
-    } else if (str == QLatin1String("Executive")) {
-        return QPrinter::Executive;
-    } else if (str == QLatin1String("A0")) {
-        return QPrinter::A0;
-    } else if (str == QLatin1String("A1")) {
-        return QPrinter::A1;
-    } else if (str == QLatin1String("A2")) {
-        return QPrinter::A2;
-    } else if (str == QLatin1String("A3")) {
-        return QPrinter::A3;
-    } else if (str == QLatin1String("A5")) {
-        return QPrinter::A5;
-    } else if (str == QLatin1String("A6")) {
-        return QPrinter::A6;
-    } else if (str == QLatin1String("A7")) {
-        return QPrinter::A7;
-    } else if (str == QLatin1String("A8")) {
-        return QPrinter::A8;
-    } else if (str == QLatin1String("A9")) {
-        return QPrinter::A9;
-    } else if (str == QLatin1String("B0")) {
-        return QPrinter::B0;
-    } else if (str == QLatin1String("B1")) {
-        return QPrinter::B1;
-    } else if (str == QLatin1String("B10")) {
-        return QPrinter::B10;
-    } else if (str == QLatin1String("B2")) {
-        return QPrinter::B2;
-    } else if (str == QLatin1String("B3")) {
-        return QPrinter::B3;
-    } else if (str == QLatin1String("B4")) {
-        return QPrinter::B4;
-    } else if (str == QLatin1String("B6")) {
-        return QPrinter::B6;
-    } else if (str == QLatin1String("B7")) {
-        return QPrinter::B7;
-    } else if (str == QLatin1String("B8")) {
-        return QPrinter::B8;
-    } else if (str == QLatin1String("B9")) {
-        return QPrinter::B9;
-    } else if (str == QLatin1String("C5E")) {
-        return QPrinter::C5E;
-    } else if (str == QLatin1String("Comm10E")) {
-        return QPrinter::Comm10E;
-    } else if (str == QLatin1String("DLE")) {
-        return QPrinter::DLE;
-    } else if (str == QLatin1String("Folio")) {
-        return QPrinter::Folio;
-    } else if (str == QLatin1String("Ledger")) {
-        return QPrinter::Ledger;
-    } else if (str == QLatin1String("Tabloid")) {
-        return QPrinter::Tabloid;
-    } else {
-        return QPrinter::Custom;
-    }
-}
-
-QString QPrinterInfoPrivate::pageSize2String(QPrinter::PaperSize size)
-{
-    switch (size) {
-    case QPrinter::A4:
-        return QLatin1String("A4");
-    case QPrinter::B5:
-        return QLatin1String("B5");
-    case QPrinter::Letter:
-        return QLatin1String("Letter");
-    case QPrinter::Legal:
-        return QLatin1String("Legal");
-    case QPrinter::Executive:
-        return QLatin1String("Executive");
-    case QPrinter::A0:
-        return QLatin1String("A0");
-    case QPrinter::A1:
-        return QLatin1String("A1");
-    case QPrinter::A2:
-        return QLatin1String("A2");
-    case QPrinter::A3:
-        return QLatin1String("A3");
-    case QPrinter::A5:
-        return QLatin1String("A5");
-    case QPrinter::A6:
-        return QLatin1String("A6");
-    case QPrinter::A7:
-        return QLatin1String("A7");
-    case QPrinter::A8:
-        return QLatin1String("A8");
-    case QPrinter::A9:
-        return QLatin1String("A9");
-    case QPrinter::B0:
-        return QLatin1String("B0");
-    case QPrinter::B1:
-        return QLatin1String("B1");
-    case QPrinter::B10:
-        return QLatin1String("B10");
-    case QPrinter::B2:
-        return QLatin1String("B2");
-    case QPrinter::B3:
-        return QLatin1String("B3");
-    case QPrinter::B4:
-        return QLatin1String("B4");
-    case QPrinter::B6:
-        return QLatin1String("B6");
-    case QPrinter::B7:
-        return QLatin1String("B7");
-    case QPrinter::B8:
-        return QLatin1String("B8");
-    case QPrinter::B9:
-        return QLatin1String("B9");
-    case QPrinter::C5E:
-        return QLatin1String("C5E");
-    case QPrinter::Comm10E:
-        return QLatin1String("Comm10E");
-    case QPrinter::DLE:
-        return QLatin1String("DLE");
-    case QPrinter::Folio:
-        return QLatin1String("Folio");
-    case QPrinter::Ledger:
-        return QLatin1String("Ledger");
-    case QPrinter::Tabloid:
-        return QLatin1String("Tabloid");
-    default:
-        return QLatin1String("Custom");
-    }
-}
-
 #endif // QT_NO_PRINTER
 
 QT_END_NAMESPACE
-- 
cgit v0.12


From f725c90032b83df62432018af362830e899e71c1 Mon Sep 17 00:00:00 2001
From: Konstantin Ritt <ritt.ks@gmail.com>
Date: Wed, 1 Dec 2010 07:48:55 +0300
Subject: minor refactoring of QPrinterInfoPrivate

use member initialization lists;
remove unused Q_DECLARE_PUBLIC stuff and q_ptr member; make members public instead

Merge-request: 2516
Signed-off-by: axis
---
 src/gui/painting/qprinterinfo_mac.cpp  | 42 +++++++----------------------
 src/gui/painting/qprinterinfo_unix.cpp | 48 +++++++++-------------------------
 src/gui/painting/qprinterinfo_win.cpp  | 42 +++++++----------------------
 3 files changed, 32 insertions(+), 100 deletions(-)

diff --git a/src/gui/painting/qprinterinfo_mac.cpp b/src/gui/painting/qprinterinfo_mac.cpp
index 9b199f4..6a48c91 100644
--- a/src/gui/painting/qprinterinfo_mac.cpp
+++ b/src/gui/painting/qprinterinfo_mac.cpp
@@ -49,18 +49,20 @@ QT_BEGIN_NAMESPACE
 
 class QPrinterInfoPrivate
 {
-Q_DECLARE_PUBLIC(QPrinterInfo)
 public:
-    ~QPrinterInfoPrivate();
-    QPrinterInfoPrivate();
-    QPrinterInfoPrivate(const QString& name);
-
-private:
-    QPrinterInfo*                 q_ptr;
+    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_default;
     bool                        m_isNull;
+    bool                        m_default;
 };
 
 static QPrinterInfoPrivate nullQPrinterInfoPrivate;
@@ -139,7 +141,6 @@ QPrinterInfo::QPrinterInfo()
 QPrinterInfo::QPrinterInfo(const QString& name)
     : d_ptr(new QPrinterInfoPrivate(name))
 {
-    d_ptr->q_ptr = this;
 }
 
 QPrinterInfo::QPrinterInfo(const QPrinterInfo& src)
@@ -152,7 +153,6 @@ QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
 {
     Q_ASSERT(d_ptr);
     d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr));
-    d_ptr->q_ptr = this;
     return *this;
 }
 
@@ -210,28 +210,6 @@ QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
     return paperList;
 }
 
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-QPrinterInfoPrivate::QPrinterInfoPrivate() :
-    q_ptr(NULL),
-    m_default(false),
-    m_isNull(true)
-{
-}
-
-QPrinterInfoPrivate::QPrinterInfoPrivate(const QString& name) :
-    q_ptr(NULL),
-    m_name(name),
-    m_default(false),
-    m_isNull(false)
-{
-}
-
-QPrinterInfoPrivate::~QPrinterInfoPrivate()
-{
-}
-
 #endif // QT_NO_PRINTER
 
 QT_END_NAMESPACE
diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp
index 0d4cc16..eb16a1b 100644
--- a/src/gui/painting/qprinterinfo_unix.cpp
+++ b/src/gui/painting/qprinterinfo_unix.cpp
@@ -124,21 +124,26 @@ static inline const char *paperSize2String(QPrinter::PaperSize size)
 
 class QPrinterInfoPrivate
 {
-Q_DECLARE_PUBLIC(QPrinterInfo)
 public:
-    QPrinterInfoPrivate();
-    QPrinterInfoPrivate(const QString& name);
-    ~QPrinterInfoPrivate();
+    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()
+    {}
 
-private:
     QString                     m_name;
     bool                        m_isNull;
     bool                        m_default;
+
     mutable bool                m_mustGetPaperSizes;
     mutable QList<QPrinter::PaperSize> m_paperSizes;
     int                         m_cupsPrinterIndex;
-
-    QPrinterInfo*               q_ptr;
 };
 
 static QPrinterInfoPrivate nullQPrinterInfoPrivate;
@@ -946,7 +951,6 @@ QPrinterInfo::QPrinterInfo(const QPrinter& printer)
 {
 
     Q_D(QPrinterInfo);
-    d->q_ptr = this;
 
 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
     QCUPSSupport cups;
@@ -990,7 +994,6 @@ QPrinterInfo::QPrinterInfo(const QPrinter& printer)
 QPrinterInfo::QPrinterInfo(const QString& name)
     : d_ptr(new QPrinterInfoPrivate(name))
 {
-    d_ptr->q_ptr = this;
 }
 
 QPrinterInfo::~QPrinterInfo()
@@ -1001,7 +1004,6 @@ QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
 {
     Q_ASSERT(d_ptr);
     d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr));
-    d_ptr->q_ptr = this;
     return *this;
 }
 
@@ -1046,32 +1048,6 @@ QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
     return d->m_paperSizes;
 }
 
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-QPrinterInfoPrivate::QPrinterInfoPrivate()
-{
-    m_isNull = true;
-    m_default = false;
-    m_mustGetPaperSizes = true;
-    m_cupsPrinterIndex = 0;
-    q_ptr = 0;
-}
-
-QPrinterInfoPrivate::QPrinterInfoPrivate(const QString& name)
-{
-    m_name = name;
-    m_isNull = false;
-    m_default = false;
-    m_mustGetPaperSizes = true;
-    m_cupsPrinterIndex = 0;
-    q_ptr = 0;
-}
-
-QPrinterInfoPrivate::~QPrinterInfoPrivate()
-{
-}
-
 #endif // QT_NO_PRINTER
 
 QT_END_NAMESPACE
diff --git a/src/gui/painting/qprinterinfo_win.cpp b/src/gui/painting/qprinterinfo_win.cpp
index caada1f..808de2c 100644
--- a/src/gui/painting/qprinterinfo_win.cpp
+++ b/src/gui/painting/qprinterinfo_win.cpp
@@ -53,18 +53,20 @@ extern QPrinter::PaperSize mapDevmodePaperSize(int s);
 
 class QPrinterInfoPrivate
 {
-Q_DECLARE_PUBLIC(QPrinterInfo)
 public:
-    ~QPrinterInfoPrivate();
-    QPrinterInfoPrivate();
-    QPrinterInfoPrivate(const QString& name);
+    QPrinterInfoPrivate() :
+        m_isNull(true), m_default(false)
+    {}
+    QPrinterInfoPrivate(const QString& name) :
+        m_name(name),
+        m_isNull(false), m_default(false)
+    {}
+    ~QPrinterInfoPrivate()
+    {}
 
-private:
     QString                     m_name;
-    bool                        m_default;
     bool                        m_isNull;
-
-    QPrinterInfo*               q_ptr;
+    bool                        m_default;
 };
 
 static QPrinterInfoPrivate nullQPrinterInfoPrivate;
@@ -142,7 +144,6 @@ QPrinterInfo::QPrinterInfo()
 QPrinterInfo::QPrinterInfo(const QString& name)
     : d_ptr(new QPrinterInfoPrivate(name))
 {
-    d_ptr->q_ptr = this;
 }
 
 QPrinterInfo::QPrinterInfo(const QPrinterInfo& src)
@@ -173,7 +174,6 @@ QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
 {
     Q_ASSERT(d_ptr);
     d_ptr.reset(new QPrinterInfoPrivate(*src.d_ptr));
-    d_ptr->q_ptr = this;
     return *this;
 }
 
@@ -218,28 +218,6 @@ QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
     return paperList;
 }
 
-/////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-QPrinterInfoPrivate::QPrinterInfoPrivate() :
-    m_default(false),
-    m_isNull(true),
-    q_ptr(NULL)
-{
-}
-
-QPrinterInfoPrivate::QPrinterInfoPrivate(const QString& name) :
-    m_name(name),
-    m_default(false),
-    m_isNull(false),
-    q_ptr(NULL)
-{
-}
-
-QPrinterInfoPrivate::~QPrinterInfoPrivate()
-{
-}
-
 #endif // QT_NO_PRINTER
 
 QT_END_NAMESPACE
-- 
cgit v0.12


From 2cf77579cf41594e036beeacf3dc3b6aa9f05cfa Mon Sep 17 00:00:00 2001
From: Konstantin Ritt <ritt.ks@gmail.com>
Date: Wed, 1 Dec 2010 12:31:19 +0300
Subject: 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
---
 src/gui/painting/painting.pri          |   2 +
 src/gui/painting/qprinterinfo.cpp      | 173 +++++++++++++++++++++++++++++++++
 src/gui/painting/qprinterinfo.h        |  15 +--
 src/gui/painting/qprinterinfo.qdoc     | 125 ------------------------
 src/gui/painting/qprinterinfo_mac.cpp  | 100 +------------------
 src/gui/painting/qprinterinfo_p.h      | 108 ++++++++++++++++++++
 src/gui/painting/qprinterinfo_unix.cpp | 159 +++---------------------------
 src/gui/painting/qprinterinfo_win.cpp  | 106 ++------------------
 8 files changed, 317 insertions(+), 471 deletions(-)
 create mode 100644 src/gui/painting/qprinterinfo.cpp
 delete mode 100644 src/gui/painting/qprinterinfo.qdoc
 create mode 100644 src/gui/painting/qprinterinfo_p.h

diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index 099619c..51f2538 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.cpp b/src/gui/painting/qprinterinfo.cpp
new file mode 100644
index 0000000..21d56f3
--- /dev/null
+++ b/src/gui/painting/qprinterinfo.cpp
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** 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 documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of this
+** file.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qprinterinfo.h"
+#include "qprinterinfo_p.h"
+
+#ifndef QT_NO_PRINTER
+
+QT_BEGIN_NAMESPACE
+
+QPrinterInfoPrivate QPrinterInfoPrivate::shared_null;
+
+
+/*!
+    \class QPrinterInfo
+
+    \brief The QPrinterInfo class gives access to information about
+    existing printers.
+    
+    \ingroup printing
+
+    Use the static functions to generate a list of QPrinterInfo
+    objects. Each QPrinterInfo object in the list represents a single
+    printer and can be queried for name, supported paper sizes, and
+    whether or not it is the default printer.
+
+    \since 4.4
+*/
+
+/*!
+    \fn QList<QPrinterInfo> QPrinterInfo::availablePrinters()
+
+    Returns a list of available printers on the system.
+*/
+
+/*!
+    \fn QPrinterInfo QPrinterInfo::defaultPrinter()
+
+    Returns the default printer on the system.
+
+    The return value should be checked using isNull() before being
+    used, in case there is no default printer.
+
+    \sa isNull()
+*/
+
+/*!
+    Constructs an empty QPrinterInfo object.
+
+    \sa isNull()
+*/
+QPrinterInfo::QPrinterInfo()
+    : d_ptr(&QPrinterInfoPrivate::shared_null)
+{
+}
+
+/*!
+    Constructs a copy of \a other.
+*/
+QPrinterInfo::QPrinterInfo(const QPrinterInfo &other)
+    : d_ptr(new QPrinterInfoPrivate(*other.d_ptr))
+{
+}
+
+/*!
+    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;
+        }
+    }
+}
+
+/*!
+    \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()
+{
+}
+
+/*!
+    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;
+}
+
+/*!
+    Returns the name of the printer.
+
+    \sa QPrinter::setPrinterName()
+*/
+QString QPrinterInfo::printerName() const
+{
+    const Q_D(QPrinterInfo);
+    return d->name;
+}
+
+/*!
+    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;
+}
+
+/*!
+    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
+    \since 4.4
+
+    Returns a list of supported paper sizes by the printer.
+
+    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 063c6b9..c8c9534 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.qdoc b/src/gui/painting/qprinterinfo.qdoc
deleted file mode 100644
index 9193213..0000000
--- a/src/gui/painting/qprinterinfo.qdoc
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************************
-**
-** 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 documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of this
-** file.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-    \class QPrinterInfo
-
-    \brief The QPrinterInfo class gives access to information about
-    existing printers.
-    
-    \ingroup printing
-
-    Use the static functions to generate a list of QPrinterInfo
-    objects. Each QPrinterInfo object in the list represents a single
-    printer and can be queried for name, supported paper sizes, and
-    whether or not it is the default printer.
-
-    \since 4.4
-*/
-
-/*!
-    \fn QList<QPrinterInfo> QPrinterInfo::availablePrinters()
-
-    Returns a list of available printers on the system.
-*/
-
-/*!
-    \fn QPrinterInfo QPrinterInfo::defaultPrinter()
-
-    Returns the default printer on the system.
-
-    The return value should be checked using isNull() before being
-    used, in case there is no default printer.
-
-    \sa isNull()
-*/
-
-/*!
-    \fn QPrinterInfo::QPrinterInfo()
-
-    Constructs an empty QPrinterInfo object.
-
-    \sa isNull()
-*/
-
-/*!
-    \fn QPrinterInfo::QPrinterInfo(const QPrinterInfo& src)
-
-    Constructs a copy of \a src.
-*/
-
-/*!
-    \fn QPrinterInfo::QPrinterInfo(const QPrinter& printer)
-
-    Constructs a QPrinterInfo object from \a printer.
-*/
-
-/*!
-    \fn QPrinterInfo::~QPrinterInfo()
-
-    Destroys the QPrinterInfo object. References to the values in the
-    object become invalid.
-*/
-
-/*!
-    \fn QPrinterInfo& QPrinterInfo::operator=(const QPrinterInfo& src)
-
-    Sets the QPrinterInfo object to be equal to \a src.
-*/
-
-/*!
-    \fn QString QPrinterInfo::printerName() const
-
-    Returns the name of the printer.
-
-    \sa QPrinter::setPrinterName()
-*/
-
-/*!
-    \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.
-*/
-
-/*!
-    \fn bool QPrinterInfo::isDefault() const
-
-    Returns whether this printer is the default printer.
-*/
-
-/*!
-    \fn QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
-    \since 4.4
-
-    Returns a list of supported paper sizes by the printer.
-
-    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.
-*/
diff --git a/src/gui/painting/qprinterinfo_mac.cpp b/src/gui/painting/qprinterinfo_mac.cpp
index 6a48c91..9d0e886 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 0000000..f5981d4
--- /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 eb16a1b..c30fcb4 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 808de2c..962aa2d 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) {
-- 
cgit v0.12


From 70fd5a220d966279eb66df08ad69539bb26d59cd Mon Sep 17 00:00:00 2001
From: Konstantin Ritt <ritt.ks@gmail.com>
Date: Wed, 1 Dec 2010 12:54:52 +0300
Subject: micro-optimizations, clean-ups and styling fixes

Merge-request: 2516
Signed-off-by: axis
---
 src/gui/painting/qprinterinfo_mac.cpp  | 67 ++++++++++++++++-----------------
 src/gui/painting/qprinterinfo_unix.cpp | 46 +++++++++++------------
 src/gui/painting/qprinterinfo_win.cpp  | 68 +++++++++++++++-------------------
 3 files changed, 83 insertions(+), 98 deletions(-)

diff --git a/src/gui/painting/qprinterinfo_mac.cpp b/src/gui/painting/qprinterinfo_mac.cpp
index 9d0e886..8d41217 100644
--- a/src/gui/painting/qprinterinfo_mac.cpp
+++ b/src/gui/painting/qprinterinfo_mac.cpp
@@ -54,68 +54,63 @@ QList<QPrinterInfo> QPrinterInfo::availablePrinters()
 {
     QList<QPrinterInfo> printers;
 
-    OSStatus status = noErr;
-    QCFType<CFArrayRef> printerList;
-    status = PMServerCreatePrinterList(kPMServerLocal, &printerList);
-    if (status == noErr) {
-        CFIndex count = CFArrayGetCount(printerList);
-        for (CFIndex i=0; i<count; ++i) {
-            PMPrinter printer = static_cast<PMPrinter>(const_cast<void *>(CFArrayGetValueAtIndex(printerList, i)));
-            QString name = QCFString::toQString(PMPrinterGetName(printer));
-            printers.append(QPrinterInfo(name));
-            if (PMPrinterIsDefault(printer)) {
-                printers[i].d_ptr->isDefault = true;
-            }
+    QCFType<CFArrayRef> array;
+    if (PMServerCreatePrinterList(kPMServerLocal, &array) == noErr) {
+        CFIndex count = CFArrayGetCount(array);
+        for (int i = 0; i < count; ++i) {
+            PMPrinter printer = static_cast<PMPrinter>(const_cast<void *>(CFArrayGetValueAtIndex(array, i)));
+            QString printerName = QCFString::toQString(PMPrinterGetName(printer));
+
+            QPrinterInfo printerInfo(printerName);
+            if (PMPrinterIsDefault(printer))
+                printerInfo.d_ptr->isDefault = true;
+            printers.append(printerInfo);
         }
     }
 
     return printers;
 }
 
-QPrinterInfo QPrinterInfo::defaultPrinter(){
+QPrinterInfo QPrinterInfo::defaultPrinter()
+{
     QList<QPrinterInfo> printers = availablePrinters();
-    for (int c = 0; c < printers.size(); ++c) {
-        if (printers[c].isDefault()) {
-            return printers[c];
-        }
+    foreach (const QPrinterInfo &printerInfo, printers) {
+        if (printerInfo.isDefault())
+            return printerInfo;
     }
-    return QPrinterInfo();
+
+    return printers.value(0);
 }
 
 QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
 {
     const Q_D(QPrinterInfo);
 
-    PMPrinter cfPrn = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(d->name));
+    QList<QPrinter::PaperSize> paperSizes;
 
-    if (!cfPrn) return QList<QPrinter::PaperSize>();
+    PMPrinter cfPrn = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(d->name));
+    if (!cfPrn)
+        return paperSizes;
 
     CFArrayRef array;
-    OSStatus status = PMPrinterGetPaperList(cfPrn, &array);
-
-    if (status != 0) {
+    if (PMPrinterGetPaperList(cfPrn, &array) != noErr) {
         PMRelease(cfPrn);
-        return QList<QPrinter::PaperSize>();
+        return paperSizes;
     }
 
-    QList<QPrinter::PaperSize> paperList;
     int count = CFArrayGetCount(array);
-    for (int c = 0; c < count; c++) {
-        PMPaper paper = static_cast<PMPaper>(
-                const_cast<void*>(
-                CFArrayGetValueAtIndex(array, c)));
+    for (int i = 0; i < count; ++i) {
+        PMPaper paper = static_cast<PMPaper>(const_cast<void *>(CFArrayGetValueAtIndex(array, i)));
         double width, height;
-        status = PMPaperGetWidth(paper, &width);
-        status |= PMPaperGetHeight(paper, &height);
-        if (status != 0) continue;
-
-        QSizeF size(width * 0.3527, height * 0.3527);
-        paperList.append(qSizeFTopaperSize(size));
+        if (PMPaperGetWidth(paper, &width) == noErr && PMPaperGetHeight(paper, &height) == noErr) {
+            QSizeF size(width * 0.3527, height * 0.3527);
+            paperSizes.append(qSizeFTopaperSize(size));
+        }
     }
 
     PMRelease(cfPrn);
 
-    return paperList;
+    return paperSizes;
 }
 
 #endif // QT_NO_PRINTER
diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp
index c30fcb4..be24bd7 100644
--- a/src/gui/painting/qprinterinfo_unix.cpp
+++ b/src/gui/painting/qprinterinfo_unix.cpp
@@ -809,12 +809,12 @@ int qt_getLprPrinters(QList<QPrinterDescription>& printers)
 #endif
     }
 
+    QRegExp ps(QLatin1String("[^a-z]ps(?:[^a-z]|$)"));
+    QRegExp lp(QLatin1String("[^a-z]lp(?:[^a-z]|$)"));
+
     int quality = 0;
     int best = 0;
     for (int i = 0; i < printers.size(); ++i) {
-        QRegExp ps(QLatin1String("[^a-z]ps(?:[^a-z]|$)"));
-        QRegExp lp(QLatin1String("[^a-z]lp(?:[^a-z]|$)"));
-
         QString name = printers.at(i).name;
         QString comment = printers.at(i).comment;
         if (quality < 5 && name == dollarPrinter) {
@@ -849,50 +849,48 @@ int qt_getLprPrinters(QList<QPrinterDescription>& printers)
 
 QList<QPrinterInfo> QPrinterInfo::availablePrinters()
 {
-    QList<QPrinterInfo> list;
+    QList<QPrinterInfo> printers;
 
 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
     if (QCUPSSupport::isAvailable()) {
         QCUPSSupport cups;
         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);
-            list.append(QPrinterInfo(printerName));
+
+            QPrinterInfo printerInfo(printerName);
             if (cupsPrinters[i].is_default)
-                list[i].d_ptr->isDefault = true;
-            list[i].d_ptr->cupsPrinterIndex = i;
+                printerInfo.d_ptr->isDefault = true;
+            printerInfo.d_ptr->cupsPrinterIndex = i;
+            printers.append(printerInfo);
         }
-    } else {
+    } else
 #endif
+           {
         QList<QPrinterDescription> lprPrinters;
         int defprn = qt_getLprPrinters(lprPrinters);
         // populating printer combo
-        QList<QPrinterDescription>::const_iterator i = lprPrinters.constBegin();
-        for(; i != lprPrinters.constEnd(); ++i) {
-            list.append(QPrinterInfo((*i).name));
-        }
-        if (defprn >= 0 && defprn < lprPrinters.size()) {
-            list[defprn].d_ptr->isDefault = true;
-        }
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+        foreach (const QPrinterDescription &description, lprPrinters)
+            printers.append(QPrinterInfo(description.name));
+        if (defprn >= 0 && defprn < printers.size())
+            printers[defprn].d_ptr->isDefault = true;
     }
-#endif
 
-    return list;
+    return printers;
 }
 
 QPrinterInfo QPrinterInfo::defaultPrinter()
 {
-    QList<QPrinterInfo> prnList = availablePrinters();
-    for (int i = 0; i < prnList.size(); ++i) {
-        if (prnList[i].isDefault())
-            return prnList[i];
+    QList<QPrinterInfo> printers = availablePrinters();
+    foreach (const QPrinterInfo &printerInfo, printers) {
+        if (printerInfo.isDefault())
+            return printerInfo;
     }
-    return (prnList.size() > 0) ? prnList[0] : QPrinterInfo();
+
+    return printers.value(0);
 }
 
 QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
diff --git a/src/gui/painting/qprinterinfo_win.cpp b/src/gui/painting/qprinterinfo_win.cpp
index 962aa2d..6adf5a4 100644
--- a/src/gui/painting/qprinterinfo_win.cpp
+++ b/src/gui/painting/qprinterinfo_win.cpp
@@ -55,25 +55,22 @@ extern QPrinter::PaperSize mapDevmodePaperSize(int s);
 QList<QPrinterInfo> QPrinterInfo::availablePrinters()
 {
     QList<QPrinterInfo> printers;
-    LPBYTE buffer;
+
     DWORD needed = 0;
     DWORD returned = 0;
-
-    if ( !EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, 0, 0, &needed, &returned))
-    {
-        buffer = new BYTE[needed];
-        if (!EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS , NULL,
-                           4, buffer, needed, &needed, &returned))
-        {
-            delete [] buffer;
-            return printers;
-        }
-        PPRINTER_INFO_4 infoList = reinterpret_cast<PPRINTER_INFO_4>(buffer);
-        QPrinterInfo defPrn = defaultPrinter();
-        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->isDefault = true;
+    if (!EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, 0, 0, &needed, &returned)) {
+        LPBYTE buffer = new BYTE[needed];
+        if (EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 4, buffer, needed, &needed, &returned)) {
+            PPRINTER_INFO_4 infoList = reinterpret_cast<PPRINTER_INFO_4>(buffer);
+            QPrinterInfo defPrn = defaultPrinter();
+            for (uint i = 0; i < returned; ++i) {
+                QString printerName(QString::fromWCharArray(infoList[i].pPrinterName));
+
+                QPrinterInfo printerInfo(printerName);
+                if (printerInfo.printerName() == defPrn.printerName())
+                    printerInfo.d_ptr->isDefault = true;
+                printers.append(printerInfo);
+            }
         }
         delete [] buffer;
     }
@@ -88,40 +85,35 @@ QPrinterInfo QPrinterInfo::defaultPrinter()
     GetProfileString(L"windows", L"device", (wchar_t*)noPrinters.utf16(), buffer, 256);
     QString output = QString::fromWCharArray(buffer);
 
-    // Filter out the name of the printer, which should be everything
-    // before a comma.
+    // Filter out the name of the printer, which should be everything before a comma.
     bool noConfiguredPrinters = (output == noPrinters);
-    QStringList info = output.split(QLatin1Char(','));
-    QString printerName = noConfiguredPrinters ? QString() : info.at(0);
+    QString printerName = output.split(QLatin1Char(',')).value(0);
 
-    QPrinterInfo prn(printerName);
-    prn.d_ptr->isDefault = true;
+    QPrinterInfo printerInfo(printerName);
+    printerInfo.d_ptr->isDefault = true;
     if (noConfiguredPrinters)
-        prn.d_ptr->isNull = true;
-    return prn;
+        printerInfo.d_ptr->isNull = true;
+    return printerInfo;
 }
 
 QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
 {
     const Q_D(QPrinterInfo);
-    QList<QPrinter::PaperSize> paperList;
+
+    QList<QPrinter::PaperSize> paperSizes;
 
     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->name.utf16()),
-                              NULL, DC_PAPERS, papers, NULL);
-
-    for (int c = 0; c < (int)size; ++c) {
-        paperList.append(mapDevmodePaperSize(papers[c]));
+    if ((int)size != -1) {
+        wchar_t *papers = new wchar_t[size];
+        size = DeviceCapabilities(reinterpret_cast<const wchar_t*>(d->name.utf16()),
+                                  NULL, DC_PAPERS, papers, NULL);
+        for (int c = 0; c < (int)size; ++c)
+            paperSizes.append(mapDevmodePaperSize(papers[c]));
+        delete [] papers;
     }
 
-    delete [] papers;
-
-    return paperList;
+    return paperSizes;
 }
 
 #endif // QT_NO_PRINTER
-- 
cgit v0.12


From ed2abc6f5d8b2fe9e819d473768767c11f9c83ba Mon Sep 17 00:00:00 2001
From: Konstantin Ritt <ritt.ks@gmail.com>
Date: Wed, 1 Dec 2010 13:24:44 +0300
Subject: fix QPrinterInfo::defaultPrinter() on win

to not return a partially filled invalid printer info.
is the default printer couldn't be retrieved, return an invalid QPrinterInfo()
rather than a semi-invalid info
which has isDefault() == true and printerName() == "qt_no_printers"

Merge-request: 2516
Signed-off-by: axis
---
 src/gui/painting/qprinterinfo_win.cpp | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/gui/painting/qprinterinfo_win.cpp b/src/gui/painting/qprinterinfo_win.cpp
index 6adf5a4..f7b6874 100644
--- a/src/gui/painting/qprinterinfo_win.cpp
+++ b/src/gui/painting/qprinterinfo_win.cpp
@@ -84,16 +84,15 @@ QPrinterInfo QPrinterInfo::defaultPrinter()
     wchar_t buffer[256];
     GetProfileString(L"windows", L"device", (wchar_t*)noPrinters.utf16(), buffer, 256);
     QString output = QString::fromWCharArray(buffer);
+    if (output != noPrinters) {
+        // Filter out the name of the printer, which should be everything before a comma.
+        QString printerName = output.split(QLatin1Char(',')).value(0);
+        QPrinterInfo printerInfo(printerName);
+        printerInfo.d_ptr->isDefault = true;
+        return printerInfo;
+    }
 
-    // Filter out the name of the printer, which should be everything before a comma.
-    bool noConfiguredPrinters = (output == noPrinters);
-    QString printerName = output.split(QLatin1Char(',')).value(0);
-
-    QPrinterInfo printerInfo(printerName);
-    printerInfo.d_ptr->isDefault = true;
-    if (noConfiguredPrinters)
-        printerInfo.d_ptr->isNull = true;
-    return printerInfo;
+    return QPrinterInfo();
 }
 
 QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
-- 
cgit v0.12


From 50af3716c956be0f50fdd896925da7af91d5da2c Mon Sep 17 00:00:00 2001
From: Konstantin Ritt <ritt.ks@gmail.com>
Date: Wed, 1 Dec 2010 13:46:24 +0300
Subject: QPrinterInfo::supportedPaperSizes(): return early if the info is
 invalid

e.g. don't report supported paper sized in any case

Merge-request: 2516
Signed-off-by: axis
---
 src/gui/painting/qprinterinfo_mac.cpp  | 2 ++
 src/gui/painting/qprinterinfo_unix.cpp | 3 +++
 src/gui/painting/qprinterinfo_win.cpp  | 2 ++
 3 files changed, 7 insertions(+)

diff --git a/src/gui/painting/qprinterinfo_mac.cpp b/src/gui/painting/qprinterinfo_mac.cpp
index 8d41217..033682a 100644
--- a/src/gui/painting/qprinterinfo_mac.cpp
+++ b/src/gui/painting/qprinterinfo_mac.cpp
@@ -87,6 +87,8 @@ QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
     const Q_D(QPrinterInfo);
 
     QList<QPrinter::PaperSize> paperSizes;
+    if (isNull())
+        return paperSizes;
 
     PMPrinter cfPrn = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(d->name));
     if (!cfPrn)
diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp
index be24bd7..af2e52a 100644
--- a/src/gui/painting/qprinterinfo_unix.cpp
+++ b/src/gui/painting/qprinterinfo_unix.cpp
@@ -898,6 +898,9 @@ QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
     const Q_D(QPrinterInfo);
 
+    if (isNull())
+        return d->paperSizes;
+
     if (!d->hasPaperSizes) {
         d->hasPaperSizes = true;
 
diff --git a/src/gui/painting/qprinterinfo_win.cpp b/src/gui/painting/qprinterinfo_win.cpp
index f7b6874..2d25063 100644
--- a/src/gui/painting/qprinterinfo_win.cpp
+++ b/src/gui/painting/qprinterinfo_win.cpp
@@ -100,6 +100,8 @@ QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
     const Q_D(QPrinterInfo);
 
     QList<QPrinter::PaperSize> paperSizes;
+    if (isNull())
+        return paperSizes;
 
     DWORD size = DeviceCapabilities(reinterpret_cast<const wchar_t*>(d->name.utf16()),
                                     NULL, DC_PAPERS, NULL, NULL);
-- 
cgit v0.12


From 1d6266e751d6b23a15f56bc21c503fe1a71da975 Mon Sep 17 00:00:00 2001
From: Konstantin Ritt <ritt.ks@gmail.com>
Date: Wed, 1 Dec 2010 14:28:32 +0300
Subject: get rid of QPrinterInfoPrivate::isNull member

invalid QPrinterInfo always have d_ptr == &QPrinterInfoPrivate::shared_null;
no need in separate flag for that

Merge-request: 2516
Signed-off-by: axis
---
 src/gui/painting/qprinterinfo.cpp | 2 +-
 src/gui/painting/qprinterinfo_p.h | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/gui/painting/qprinterinfo.cpp b/src/gui/painting/qprinterinfo.cpp
index 21d56f3..72f8be3 100644
--- a/src/gui/painting/qprinterinfo.cpp
+++ b/src/gui/painting/qprinterinfo.cpp
@@ -146,7 +146,7 @@ QString QPrinterInfo::printerName() const
 bool QPrinterInfo::isNull() const
 {
     const Q_D(QPrinterInfo);
-    return d->isNull;
+    return d == &QPrinterInfoPrivate::shared_null;
 }
 
 /*!
diff --git a/src/gui/painting/qprinterinfo_p.h b/src/gui/painting/qprinterinfo_p.h
index f5981d4..7781d59 100644
--- a/src/gui/painting/qprinterinfo_p.h
+++ b/src/gui/painting/qprinterinfo_p.h
@@ -65,7 +65,7 @@ class QPrinterInfoPrivate
 {
 public:
     QPrinterInfoPrivate(const QString& name = QString()) :
-        name(name), isNull(false), isDefault(false)
+        name(name), 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)
@@ -78,7 +78,6 @@ public:
     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)
-- 
cgit v0.12


From b24447e0f20db4a40df724476c6542ea44590935 Mon Sep 17 00:00:00 2001
From: axis <qt-info@nokia.com>
Date: Mon, 20 Dec 2010 16:09:50 +0100
Subject: Fixed autotest.

---
 tests/auto/qprinterinfo/tst_qprinterinfo.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/auto/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/qprinterinfo/tst_qprinterinfo.cpp
index c3fad6c..4f767a5 100644
--- a/tests/auto/qprinterinfo/tst_qprinterinfo.cpp
+++ b/tests/auto/qprinterinfo/tst_qprinterinfo.cpp
@@ -134,7 +134,7 @@ QStringList tst_QPrinterInfo::getPrintersFromSystem()
     QString output = getOutputFromCommand(command);
     QStringList list = output.split(QChar::fromLatin1('\n'));
 
-    QRegExp reg("^[Pp]rinter ([.a-zA-Z0-9_-]+)");
+    QRegExp reg("^[Pp]rinter ([.a-zA-Z0-9-_@]+)");
     for (int c = 0; c < list.size(); ++c) {
         if (reg.indexIn(list[c]) >= 0) {
             QString printer = reg.cap(1);
-- 
cgit v0.12


From d9c00320a1e1f6aa7d0083b3415704e20e216a1f Mon Sep 17 00:00:00 2001
From: axis <qt-info@nokia.com>
Date: Mon, 6 Dec 2010 13:41:51 +0100
Subject: Moved the default dependency targets to default_post.prf.

The file that they were in would not be parsed if CONFIG -= qt, but
it always needs to be parsed, otherwise apps that don't use Qt will
fail the sis file creation.

RevBy:    Miikka Heikkinen
---
 mkspecs/features/symbian/default_post.prf | 47 +++++++++++++++++++++++++++++++
 mkspecs/features/symbian/qt.prf           | 47 -------------------------------
 2 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/mkspecs/features/symbian/default_post.prf b/mkspecs/features/symbian/default_post.prf
index a2ac377..89f655d 100644
--- a/mkspecs/features/symbian/default_post.prf
+++ b/mkspecs/features/symbian/default_post.prf
@@ -53,6 +53,53 @@ isEmpty(TARGET.UID2) {
     }
 }
 
+# Allow .pro files to specify include path(s) to be prepended to the list.
+#
+# This allows the project to override the default ordering, whereby paths
+# relative to $$QMAKE_INCDIR_QT always come first.  This ordering can cause
+# problems when both the epoc32/include tree and a Qt include directory
+# contain a header of the same name - in this case, the Qt header is always
+# included by virtue of its path appearing first in the SYSTEMINCLUDE
+# directives in the generated MMP file.
+#
+# To work around this situation, the following line can be added to the .pro
+# file:
+#	PREPEND_INCLUDEPATH = /epoc32/include
+#
+INCLUDEPATH = $$PREPEND_INCLUDEPATH $$INCLUDEPATH
+
+# Add dependency to Qt package to all other projects besides Qt libs.
+# Note: Qt libs package with full capabilities has UID3 of 0x2001E61C,
+#       while self-signed version typically has temporary UID3 of 0xE001E61C.
+contains(CONFIG, qt):!contains(TARGET.UID3, 0x2001E61C):!contains(TARGET.UID3, 0xE001E61C):isEmpty(QT_LIBINFIX) {
+    qt_pkg_name = Qt
+    pkg_depends_qt += \
+        "; Default dependency to Qt libraries" \
+        "(0x2001E61C), $${QT_MAJOR_VERSION}, $${QT_MINOR_VERSION}, $${QT_PATCH_VERSION}, {$$addLanguageDependentPkgItem(qt_pkg_name)}"
+
+    # Projects linking to webkit need dependency to webkit
+    contains(QT, webkit): {
+        # these can be overridden by mkspecs/modules/qt_webkit.pri
+        isEmpty(QT_WEBKIT_MAJOR_VERSION) {
+            QT_WEBKIT_MAJOR_VERSION = $${QT_MAJOR_VERSION}
+            QT_WEBKIT_MINOR_VERSION = $${QT_MINOR_VERSION}
+            QT_WEBKIT_PATCH_VERSION = $${QT_PATCH_VERSION}
+        }
+
+        webkit_pkg_name = QtWebKit
+        pkg_depends_webkit += \
+            "; Dependency to Qt Webkit" \
+            "(0x200267C2), $${QT_WEBKIT_MAJOR_VERSION}, $${QT_WEBKIT_MINOR_VERSION}, $${QT_WEBKIT_PATCH_VERSION}, {$$addLanguageDependentPkgItem(webkit_pkg_name)}"
+    } else {
+        default_deployment.pkg_prerules -= pkg_depends_webkit
+    }
+} else {
+    default_deployment.pkg_prerules -= pkg_depends_webkit pkg_depends_qt
+}
+
+isEmpty(TARGET.EPOCSTACKSIZE):TARGET.EPOCSTACKSIZE = 0x14000
+isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x020000 0x800000
+
 # Supports S60 3.1, 3.2, 5.0, Symbian^3, and Symbian^4 by default
 platform_product_id = S60ProductID
 platform_product_id = $$addLanguageDependentPkgItem(platform_product_id)
diff --git a/mkspecs/features/symbian/qt.prf b/mkspecs/features/symbian/qt.prf
index c8f97aa..c376b64 100644
--- a/mkspecs/features/symbian/qt.prf
+++ b/mkspecs/features/symbian/qt.prf
@@ -6,53 +6,6 @@ CONFIG += qtmain
 
 load(qt)
 
-# Allow .pro files to specify include path(s) to be prepended to the list.
-#
-# This allows the project to override the default ordering, whereby paths
-# relative to $$QMAKE_INCDIR_QT always come first.  This ordering can cause
-# problems when both the epoc32/include tree and a Qt include directory
-# contain a header of the same name - in this case, the Qt header is always
-# included by virtue of its path appearing first in the SYSTEMINCLUDE
-# directives in the generated MMP file.
-#
-# To work around this situation, the following line can be added to the .pro
-# file:
-#	PREPEND_INCLUDEPATH = /epoc32/include
-#
-INCLUDEPATH = $$PREPEND_INCLUDEPATH $$INCLUDEPATH
-
-# Add dependency to Qt package to all other projects besides Qt libs.
-# Note: Qt libs package with full capabilities has UID3 of 0x2001E61C,
-#       while self-signed version typically has temporary UID3 of 0xE001E61C.
-contains(CONFIG, qt):!contains(TARGET.UID3, 0x2001E61C):!contains(TARGET.UID3, 0xE001E61C):isEmpty(QT_LIBINFIX) {
-    qt_pkg_name = Qt
-    pkg_depends_qt += \
-        "; Default dependency to Qt libraries" \
-        "(0x2001E61C), $${QT_MAJOR_VERSION}, $${QT_MINOR_VERSION}, $${QT_PATCH_VERSION}, {$$addLanguageDependentPkgItem(qt_pkg_name)}"
-
-    # Projects linking to webkit need dependency to webkit
-    contains(QT, webkit): {
-        # these can be overridden by mkspecs/modules/qt_webkit.pri
-        isEmpty(QT_WEBKIT_MAJOR_VERSION) {
-            QT_WEBKIT_MAJOR_VERSION = $${QT_MAJOR_VERSION}
-            QT_WEBKIT_MINOR_VERSION = $${QT_MINOR_VERSION}
-            QT_WEBKIT_PATCH_VERSION = $${QT_PATCH_VERSION}
-        }
-
-        webkit_pkg_name = QtWebKit
-        pkg_depends_webkit += \
-            "; Dependency to Qt Webkit" \
-            "(0x200267C2), $${QT_WEBKIT_MAJOR_VERSION}, $${QT_WEBKIT_MINOR_VERSION}, $${QT_WEBKIT_PATCH_VERSION}, {$$addLanguageDependentPkgItem(webkit_pkg_name)}"
-    } else {
-        default_deployment.pkg_prerules -= pkg_depends_webkit
-    }
-} else {
-    default_deployment.pkg_prerules -= pkg_depends_webkit pkg_depends_qt
-}
-
-isEmpty(TARGET.EPOCSTACKSIZE):TARGET.EPOCSTACKSIZE = 0x14000
-isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x020000 0x800000
-
 # Workaround for the fact that Gnupoc and Symbian chose different approaches to
 # the letter casing of headers.
 contains(CONFIG, is_using_gnupoc) {
-- 
cgit v0.12


From 2a340b56c9935ee25bbd0b750d1239cb14051b27 Mon Sep 17 00:00:00 2001
From: axis <qt-info@nokia.com>
Date: Tue, 21 Dec 2010 10:46:26 +0100
Subject: Fixed PREPEND_INCLUDEPATH being executed too early.

It used to be carried out inside qt.prf, but was moved to
default_post.prf. However, since qt.prf is executed after
default_post.prf, it would still prepend its own include paths at the
very front, which is wrong.

Fixed by introducing a new feature profile for PREPEND_INCLUDEPATH,
which is run after qt.prf (features in $$CONFIG are executed in
reverse order).

RevBy:    Miikka Heikkinen
---
 mkspecs/common/symbian/symbian.conf              |  2 +-
 mkspecs/features/symbian/default_post.prf        | 15 ---------------
 mkspecs/features/symbian/prepend_includepath.prf | 14 ++++++++++++++
 3 files changed, 15 insertions(+), 16 deletions(-)
 create mode 100644 mkspecs/features/symbian/prepend_includepath.prf

diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf
index b8e1d26..8c79d8b 100644
--- a/mkspecs/common/symbian/symbian.conf
+++ b/mkspecs/common/symbian/symbian.conf
@@ -3,7 +3,7 @@
 #
 
 TEMPLATE		= app
-CONFIG			+= qt warn_on release incremental link_prl sis_targets run_on_phone
+CONFIG			+= prepend_includepath qt warn_on release incremental link_prl sis_targets run_on_phone
 QT			+= core gui
 QMAKE_INCREMENTAL_STYLE = sublib
 
diff --git a/mkspecs/features/symbian/default_post.prf b/mkspecs/features/symbian/default_post.prf
index 89f655d..fffc481 100644
--- a/mkspecs/features/symbian/default_post.prf
+++ b/mkspecs/features/symbian/default_post.prf
@@ -53,21 +53,6 @@ isEmpty(TARGET.UID2) {
     }
 }
 
-# Allow .pro files to specify include path(s) to be prepended to the list.
-#
-# This allows the project to override the default ordering, whereby paths
-# relative to $$QMAKE_INCDIR_QT always come first.  This ordering can cause
-# problems when both the epoc32/include tree and a Qt include directory
-# contain a header of the same name - in this case, the Qt header is always
-# included by virtue of its path appearing first in the SYSTEMINCLUDE
-# directives in the generated MMP file.
-#
-# To work around this situation, the following line can be added to the .pro
-# file:
-#	PREPEND_INCLUDEPATH = /epoc32/include
-#
-INCLUDEPATH = $$PREPEND_INCLUDEPATH $$INCLUDEPATH
-
 # Add dependency to Qt package to all other projects besides Qt libs.
 # Note: Qt libs package with full capabilities has UID3 of 0x2001E61C,
 #       while self-signed version typically has temporary UID3 of 0xE001E61C.
diff --git a/mkspecs/features/symbian/prepend_includepath.prf b/mkspecs/features/symbian/prepend_includepath.prf
new file mode 100644
index 0000000..d9fd4fe
--- /dev/null
+++ b/mkspecs/features/symbian/prepend_includepath.prf
@@ -0,0 +1,14 @@
+# Allow .pro files to specify include path(s) to be prepended to the list.
+#
+# This allows the project to override the default ordering, whereby paths
+# relative to $$QMAKE_INCDIR_QT always come first.  This ordering can cause
+# problems when both the epoc32/include tree and a Qt include directory
+# contain a header of the same name - in this case, the Qt header is always
+# included by virtue of its path appearing first in the SYSTEMINCLUDE
+# directives in the generated MMP file.
+#
+# To work around this situation, the following line can be added to the .pro
+# file:
+#	PREPEND_INCLUDEPATH = /epoc32/include
+#
+INCLUDEPATH = $$PREPEND_INCLUDEPATH $$INCLUDEPATH
-- 
cgit v0.12