separate QPrinter and QPrintDialog
Removed all dependencies QPrinter had on QPrintDialog.
This commit is contained in:
parent
7196329d32
commit
b22f3a086e
@ -149,8 +149,8 @@ QAbstractPrintDialog::~QAbstractPrintDialog()
|
||||
void QPrintDialog::setOption(PrintDialogOption option, bool on)
|
||||
{
|
||||
Q_D(QPrintDialog);
|
||||
if (!(d->pd->options & option) != !on)
|
||||
setOptions(d->pd->options ^ option);
|
||||
if (!(d->options & option) != !on)
|
||||
setOptions(d->options ^ option);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -162,7 +162,7 @@ void QPrintDialog::setOption(PrintDialogOption option, bool on)
|
||||
bool QPrintDialog::testOption(PrintDialogOption option) const
|
||||
{
|
||||
Q_D(const QPrintDialog);
|
||||
return (d->pd->options & option) != 0;
|
||||
return (d->options & option) != 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -182,17 +182,17 @@ void QPrintDialog::setOptions(PrintDialogOptions options)
|
||||
{
|
||||
Q_D(QPrintDialog);
|
||||
|
||||
PrintDialogOptions changed = (options ^ d->pd->options);
|
||||
PrintDialogOptions changed = (options ^ d->options);
|
||||
if (!changed)
|
||||
return;
|
||||
|
||||
d->pd->options = options;
|
||||
d->options = options;
|
||||
}
|
||||
|
||||
QPrintDialog::PrintDialogOptions QPrintDialog::options() const
|
||||
{
|
||||
Q_D(const QPrintDialog);
|
||||
return d->pd->options;
|
||||
return d->options;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -203,7 +203,7 @@ QPrintDialog::PrintDialogOptions QPrintDialog::options() const
|
||||
void QAbstractPrintDialog::setEnabledOptions(PrintDialogOptions options)
|
||||
{
|
||||
Q_D(QAbstractPrintDialog);
|
||||
d->pd->options = options;
|
||||
d->options = options;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -214,7 +214,7 @@ void QAbstractPrintDialog::setEnabledOptions(PrintDialogOptions options)
|
||||
void QAbstractPrintDialog::addEnabledOption(PrintDialogOption option)
|
||||
{
|
||||
Q_D(QAbstractPrintDialog);
|
||||
d->pd->options |= option;
|
||||
d->options |= option;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -225,7 +225,7 @@ void QAbstractPrintDialog::addEnabledOption(PrintDialogOption option)
|
||||
QAbstractPrintDialog::PrintDialogOptions QAbstractPrintDialog::enabledOptions() const
|
||||
{
|
||||
Q_D(const QAbstractPrintDialog);
|
||||
return d->pd->options;
|
||||
return d->options;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -236,7 +236,7 @@ QAbstractPrintDialog::PrintDialogOptions QAbstractPrintDialog::enabledOptions()
|
||||
bool QAbstractPrintDialog::isOptionEnabled(PrintDialogOption option) const
|
||||
{
|
||||
Q_D(const QAbstractPrintDialog);
|
||||
return d->pd->options & option;
|
||||
return d->options & option;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -245,7 +245,7 @@ bool QAbstractPrintDialog::isOptionEnabled(PrintDialogOption option) const
|
||||
void QAbstractPrintDialog::setPrintRange(PrintRange range)
|
||||
{
|
||||
Q_D(QAbstractPrintDialog);
|
||||
d->pd->printRange = range;
|
||||
d->pd->printRange = QPrinter::PrintRange(range);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -254,7 +254,7 @@ void QAbstractPrintDialog::setPrintRange(PrintRange range)
|
||||
QAbstractPrintDialog::PrintRange QAbstractPrintDialog::printRange() const
|
||||
{
|
||||
Q_D(const QAbstractPrintDialog);
|
||||
return d->pd->printRange;
|
||||
return QAbstractPrintDialog::PrintRange(d->pd->printRange);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -268,7 +268,7 @@ void QAbstractPrintDialog::setMinMax(int min, int max)
|
||||
"'min' must be less than or equal to 'max'");
|
||||
d->pd->minPage = min;
|
||||
d->pd->maxPage = max;
|
||||
d->pd->options |= PrintPageRange;
|
||||
d->options |= PrintPageRange;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -343,6 +343,8 @@ void QAbstractPrintDialogPrivate::setPrinter(QPrinter *newPrinter)
|
||||
if (newPrinter) {
|
||||
printer = newPrinter;
|
||||
ownsPrinter = false;
|
||||
if (printer->fromPage() || printer->toPage())
|
||||
options |= QAbstractPrintDialog::PrintPageRange;
|
||||
} else {
|
||||
printer = new QPrinter;
|
||||
ownsPrinter = true;
|
||||
|
@ -62,6 +62,7 @@ class Q_GUI_EXPORT QAbstractPrintDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Keep in sync with QPrinter::PrintRange
|
||||
enum PrintRange {
|
||||
AllPages,
|
||||
Selection,
|
||||
|
@ -73,6 +73,8 @@ class QAbstractPrintDialogPrivate : public QDialogPrivate
|
||||
public:
|
||||
QAbstractPrintDialogPrivate()
|
||||
: printer(0), pd(0), ownsPrinter(false)
|
||||
, options(QAbstractPrintDialog::PrintToFile | QAbstractPrintDialog::PrintPageRange |
|
||||
QAbstractPrintDialog::PrintCollateCopies | QAbstractPrintDialog::PrintShowPageSize)
|
||||
{
|
||||
}
|
||||
|
||||
@ -82,6 +84,8 @@ public:
|
||||
QPointer<QObject> receiverToDisconnectOnClose;
|
||||
QByteArray memberToDisconnectOnClose;
|
||||
|
||||
QAbstractPrintDialog::PrintDialogOptions options;
|
||||
|
||||
virtual void setTabs(const QList<QWidget *> &) {}
|
||||
void setPrinter(QPrinter *newPrinter);
|
||||
};
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "qprintpreviewwidget.h"
|
||||
#include <private/qprinter_p.h>
|
||||
#include "private/qdialog_p.h"
|
||||
#include "qprintdialog.h"
|
||||
|
||||
#include <QtGui/qaction.h>
|
||||
#include <QtGui/qboxlayout.h>
|
||||
|
@ -44,7 +44,6 @@
|
||||
#include "qprintengine.h"
|
||||
#include "qprinterinfo.h"
|
||||
#include "qlist.h"
|
||||
#include <qpagesetupdialog.h>
|
||||
#include <qcoreapplication.h>
|
||||
#include <qfileinfo.h>
|
||||
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
|
||||
@ -2051,7 +2050,6 @@ void QPrinter::setFromTo(int from, int to)
|
||||
if (d->minPage == 0 && d->maxPage == 0) {
|
||||
d->minPage = 1;
|
||||
d->maxPage = to;
|
||||
d->options |= QAbstractPrintDialog::PrintPageRange;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2063,7 +2061,7 @@ void QPrinter::setFromTo(int from, int to)
|
||||
void QPrinter::setPrintRange( PrintRange range )
|
||||
{
|
||||
Q_D(QPrinter);
|
||||
d->printRange = QAbstractPrintDialog::PrintRange(range);
|
||||
d->printRange = range;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2078,7 +2076,7 @@ void QPrinter::setPrintRange( PrintRange range )
|
||||
QPrinter::PrintRange QPrinter::printRange() const
|
||||
{
|
||||
Q_D(const QPrinter);
|
||||
return PrintRange(d->printRange);
|
||||
return d->printRange;
|
||||
}
|
||||
|
||||
|
||||
|
@ -123,7 +123,7 @@ public:
|
||||
|
||||
enum OutputFormat { NativeFormat, PdfFormat };
|
||||
|
||||
// ### Qt 5: Merge with QAbstractPrintDialog::PrintRange
|
||||
// Keep in sync with QAbstractPrintDialog::PrintRange
|
||||
enum PrintRange { AllPages, Selection, PageRange, CurrentPage };
|
||||
|
||||
enum Unit {
|
||||
|
@ -60,7 +60,6 @@
|
||||
|
||||
#include "QtGui/qprinter.h"
|
||||
#include "QtGui/qprintengine.h"
|
||||
#include "QtGui/qprintdialog.h"
|
||||
#include "QtCore/qpointer.h"
|
||||
|
||||
#include <limits.h>
|
||||
@ -79,9 +78,7 @@ public:
|
||||
: printEngine(0)
|
||||
, paintEngine(0)
|
||||
, q_ptr(printer)
|
||||
, options(QAbstractPrintDialog::PrintToFile | QAbstractPrintDialog::PrintPageRange |
|
||||
QAbstractPrintDialog::PrintCollateCopies | QAbstractPrintDialog::PrintShowPageSize)
|
||||
, printRange(QAbstractPrintDialog::AllPages)
|
||||
, printRange(QPrinter::AllPages)
|
||||
, minPage(1)
|
||||
, maxPage(INT_MAX)
|
||||
, fromPage(0)
|
||||
@ -118,8 +115,7 @@ public:
|
||||
|
||||
QPrinter *q_ptr;
|
||||
|
||||
QAbstractPrintDialog::PrintDialogOptions options;
|
||||
QAbstractPrintDialog::PrintRange printRange;
|
||||
QPrinter::PrintRange printRange;
|
||||
int minPage, maxPage, fromPage, toPage;
|
||||
|
||||
uint use_default_engine : 1;
|
||||
|
@ -45,9 +45,9 @@
|
||||
#include <qfile.h>
|
||||
#include <qfileinfo.h>
|
||||
#include <qdir.h>
|
||||
#include <qprintdialog.h>
|
||||
#include <qlibrary.h>
|
||||
#include <qtextstream.h>
|
||||
#include <qcoreapplication.h>
|
||||
|
||||
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
|
||||
# include <private/qcups_p.h>
|
||||
@ -130,10 +130,8 @@ void qt_perhapsAddPrinter(QList<QPrinterDescription> *printers, const QString &n
|
||||
if (printers->at(i).samePrinter(name))
|
||||
return;
|
||||
|
||||
#ifndef QT_NO_PRINTDIALOG
|
||||
if (host.isEmpty())
|
||||
host = QPrintDialog::tr("locally connected");
|
||||
#endif
|
||||
host = QCoreApplication::translate("QPrinter", "locally connected");
|
||||
printers->append(QPrinterDescription(name.simplified(), host.simplified(), comment.simplified(), aliases));
|
||||
}
|
||||
|
||||
@ -153,11 +151,9 @@ void qt_parsePrinterDesc(QString printerDesc, QList<QPrinterDescription> *printe
|
||||
if (j > 0 && j < i) {
|
||||
printerName = printerDesc.left(j);
|
||||
aliases = printerDesc.mid(j + 1, i - j - 1).split(QLatin1Char('|'));
|
||||
#ifndef QT_NO_PRINTDIALOG
|
||||
// try extracting a comment from the aliases
|
||||
printerComment = QPrintDialog::tr("Aliases: %1")
|
||||
printerComment = QCoreApplication::translate("QPrinter", "Aliases: %1")
|
||||
.arg(aliases.join(QLatin1String(", ")));
|
||||
#endif
|
||||
} else {
|
||||
printerName = printerDesc.left(i);
|
||||
}
|
||||
@ -379,10 +375,8 @@ char *qt_parsePrintersConf(QList<QPrinterDescription> *printers, bool *found)
|
||||
if (j > 0) {
|
||||
// try extracting a comment from the aliases
|
||||
aliases = printerDesc.mid(j + 1, i - j - 1).split(QLatin1Char('|'));
|
||||
#ifndef QT_NO_PRINTDIALOG
|
||||
printerComment = QPrintDialog::tr("Aliases: %1")
|
||||
printerComment = QCoreApplication::translate("QPrinter", "Aliases: %1")
|
||||
.arg(aliases.join(QLatin1String(", ")));
|
||||
#endif
|
||||
}
|
||||
// look for signs of this being a remote printer
|
||||
i = printerDesc.indexOf(
|
||||
@ -593,9 +587,6 @@ void qt_parseEtcLpMember(QList<QPrinterDescription> *printers)
|
||||
if (dirs.isEmpty())
|
||||
return;
|
||||
|
||||
#ifdef QT_NO_PRINTDIALOG
|
||||
Q_UNUSED(printers);
|
||||
#else
|
||||
QString tmp;
|
||||
for (int i = 0; i < dirs.size(); ++i) {
|
||||
QFileInfo printer = dirs.at(i);
|
||||
@ -605,10 +596,9 @@ void qt_parseEtcLpMember(QList<QPrinterDescription> *printers)
|
||||
// decent way to locate aliases and remote printers.
|
||||
if (printer.isFile())
|
||||
qt_perhapsAddPrinter(printers, printer.fileName(),
|
||||
QPrintDialog::tr("unknown"),
|
||||
QCoreApplication::translate("QPrinter", "unknown"),
|
||||
QLatin1String(""));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// IRIX 6.x
|
||||
@ -801,12 +791,10 @@ int qt_getLprPrinters(QList<QPrinterDescription>& printers)
|
||||
dollarPrinter = QString::fromLocal8Bit(qgetenv("NPRINTER"));
|
||||
if (dollarPrinter.isEmpty())
|
||||
dollarPrinter = QString::fromLocal8Bit(qgetenv("NGPRINTER"));
|
||||
#ifndef QT_NO_PRINTDIALOG
|
||||
if (!dollarPrinter.isEmpty())
|
||||
qt_perhapsAddPrinter(&printers, dollarPrinter,
|
||||
QPrintDialog::tr("unknown"),
|
||||
QCoreApplication::translate("QPrinter", "unknown"),
|
||||
QLatin1String(""));
|
||||
#endif
|
||||
}
|
||||
|
||||
QRegExp ps(QLatin1String("[^a-z]ps(?:[^a-z]|$)"));
|
||||
|
Loading…
Reference in New Issue
Block a user