Qt 4.8
Public Functions | Public Variables | Properties | List of all members
QUnixPrintWidgetPrivate Class Reference

Public Functions

void _q_btnBrowseClicked ()
 
void _q_btnPropertiesClicked ()
 
void _q_printerChanged (int index)
 
void applyPrinterProperties (QPrinter *p)
 copy printer properties to the widget More...
 
bool checkFields ()
 
 QUnixPrintWidgetPrivate (QUnixPrintWidget *q)
 
void setCupsProperties ()
 
void setOptionsPane (QPrintDialogPrivate *pane)
 
void setupPrinter ()
 
void updateWidget ()
 
 ~QUnixPrintWidgetPrivate ()
 

Public Variables

QList< QPrinterDescriptionlprPrinters
 
QUnixPrintWidget *const parent
 
QPrinterprinter
 
QPrintPropertiesDialogpropertiesDialog
 
QAbstractPrintDialogq
 
Ui::QPrintWidget widget
 

Properties

QCUPSSupportcups
 
const ppd_file_t * cupsPPD
 
int cupsPrinterCount
 
const cups_dest_t * cupsPrinters
 
bool filePrintersAdded
 
QPrintDialogPrivateoptionsPane
 

Detailed Description

Definition at line 144 of file qprintdialog_unix.cpp.

Constructors and Destructors

◆ QUnixPrintWidgetPrivate()

QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate ( QUnixPrintWidget *  p)
Warning
This function is not part of the public interface.

Definition at line 660 of file qprintdialog_unix.cpp.

Referenced by setupPrinter().

662 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
663  , cups(0), cupsPrinterCount(0), cupsPrinters(0), cupsPPD(0)
664 #endif
665 {
666  q = 0;
667  if (parent)
668  q = qobject_cast<QAbstractPrintDialog*> (parent->parent());
669 
670  widget.setupUi(parent);
671 
672  int currentPrinterIndex = 0;
673 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
674  cups = new QCUPSSupport;
676  cupsPPD = cups->currentPPD();
679 
680  for (int i = 0; i < cupsPrinterCount; ++i) {
682  if (cupsPrinters[i].instance)
683  printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance);
684 
685  widget.printers->addItem(printerName);
686  if (cupsPrinters[i].is_default)
687  widget.printers->setCurrentIndex(i);
688  }
689  // the model depends on valid ppd. so before enabling the
690  // properties button we make sure the ppd is in fact valid.
691  if (cupsPrinterCount && cups->currentPPD()) {
692  widget.properties->setEnabled(true);
693  }
694  currentPrinterIndex = cups->currentPrinterIndex();
695  } else {
696 #endif
697  currentPrinterIndex = qt_getLprPrinters(lprPrinters);
698  // populating printer combo
700  for(; i != lprPrinters.constEnd(); ++i)
701  widget.printers->addItem((*i).name);
702 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
703  }
704 #endif
705 
706 #if !defined(QT_NO_FILESYSTEMMODEL) && !defined(QT_NO_COMPLETER)
707  QFileSystemModel *fsm = new QFileSystemModel(widget.filename);
708  fsm->setRootPath(QDir::homePath());
709  widget.filename->setCompleter(new QCompleter(fsm, widget.filename));
710 #endif
711  _q_printerChanged(currentPrinterIndex);
712 
713  QObject::connect(widget.printers, SIGNAL(currentIndexChanged(int)),
714  parent, SLOT(_q_printerChanged(int)));
715  QObject::connect(widget.fileBrowser, SIGNAL(clicked()), parent, SLOT(_q_btnBrowseClicked()));
716  QObject::connect(widget.properties, SIGNAL(clicked()), parent, SLOT(_q_btnPropertiesClicked()));
717 
718  // disable features that QPrinter does not yet support.
719  widget.preview->setVisible(false);
720 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
const ppd_file_t * currentPPD() const
Definition: qcups.cpp:173
The QFileSystemModel class provides a data model for the local filesystem.
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
int availablePrintersCount() const
Definition: qcups.cpp:163
#define SLOT(a)
Definition: qobjectdefs.h:226
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QCompleter class provides completions based on an item model.
Definition: qcompleter.h:64
const ppd_file_t * cupsPPD
QUnixPrintWidget *const parent
The QString class provides a Unicode character string.
Definition: qstring.h:83
const cups_dest_t * availablePrinters() const
Definition: qcups.cpp:168
static bool isAvailable()
Definition: qcups.cpp:216
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void _q_printerChanged(int index)
QPrintPropertiesDialog * propertiesDialog
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
int qt_getLprPrinters(QList< QPrinterDescription > &printers)
const char * name
QModelIndex setRootPath(const QString &path)
Sets the directory that is being watched by the model to newPath by installing a file system watcher ...
int currentPrinterIndex() const
Definition: qcups.cpp:211
The QAbstractPrintDialog class provides a base implementation for print dialogs used to configure pri...
QList< QPrinterDescription > lprPrinters
QAbstractPrintDialog * q
QPrintDialogPrivate * optionsPane
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
const cups_dest_t * cupsPrinters
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272
static QString homePath()
Returns the absolute path of the user&#39;s home directory.
Definition: qdir.cpp:1942

◆ ~QUnixPrintWidgetPrivate()

QUnixPrintWidgetPrivate::~QUnixPrintWidgetPrivate ( )

Definition at line 757 of file qprintdialog_unix.cpp.

758 {
759 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
760  delete cups;
761 #endif
762 }

Functions

◆ _q_btnBrowseClicked()

void QUnixPrintWidgetPrivate::_q_btnBrowseClicked ( )

Definition at line 844 of file qprintdialog_unix.cpp.

Referenced by QUnixPrintWidgetPrivate().

845 {
846  QString filename = widget.filename->text();
847 #ifndef QT_NO_FILEDIALOG
848  filename = QFileDialog::getSaveFileName(parent, QPrintDialog::tr("Print To File ..."), filename,
850 #else
851  filename.clear();
852 #endif
853  if (!filename.isEmpty()) {
854  widget.filename->setText(filename);
855  if (filename.endsWith(QString::fromLatin1(".ps"), Qt::CaseInsensitive))
856  widget.printers->setCurrentIndex(widget.printers->count() - 1); // the postscript one
857  else if (filename.endsWith(QString::fromLatin1(".pdf"), Qt::CaseInsensitive))
858  widget.printers->setCurrentIndex(widget.printers->count() - 2); // the pdf one
859  else if (widget.printers->currentIndex() != widget.printers->count() - 1) // if ps is not selected, pdf is default
860  widget.printers->setCurrentIndex(widget.printers->count() - 2); // the pdf one
861  }
862 }
static QString getSaveFileName(QWidget *parent=0, const QString &caption=QString(), const QString &dir=QString(), const QString &filter=QString(), QString *selectedFilter=0, Options options=0)
This is a convenience static function that will return a file name selected by the user...
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QUnixPrintWidget *const parent
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void clear()
Clears the contents of the string and makes it empty.
Definition: qstring.h:723
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796

◆ _q_btnPropertiesClicked()

void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked ( )

Definition at line 951 of file qprintdialog_unix.cpp.

Referenced by QUnixPrintWidgetPrivate().

952 {
953  if (!propertiesDialog) {
956  }
957 
959 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
961 #endif
963 
965  && (widget.printers->currentIndex() > widget.printers->count() - 3)) // PDF or postscript
967  else
969  }
971 }
bool isOptionEnabled(PrintDialogOption option) const
Use QPrintDialog::testOption(option) instead.
int exec()
Shows the dialog as a modal dialog, blocking until the user closes it.
Definition: qdialog.cpp:524
QPrinter * printer() const
Returns the printer that this printer dialog operates on.
QPrintPropertiesDialog * propertiesDialog
void setCups(QCUPSSupport *cups)
void setResult(int r)
Sets the modal dialog&#39;s result code to i.
Definition: qdialog.cpp:475
void selectPdfPsPrinter(const QPrinter *p)
int result() const
In general returns the modal dialog&#39;s result code, Accepted or Rejected.
Definition: qdialog.cpp:458
void applyPrinterProperties(QPrinter *p)
copy printer properties to the widget
QAbstractPrintDialog * q

◆ _q_printerChanged()

void QUnixPrintWidgetPrivate::_q_printerChanged ( int  index)

Definition at line 764 of file qprintdialog_unix.cpp.

Referenced by QUnixPrintWidgetPrivate(), and setOptionsPane().

765 {
766  if (index < 0)
767  return;
768  const int printerCount = widget.printers->count();
769  widget.filename->setEnabled(false);
770  widget.lOutput->setEnabled(false);
771 
772  if (filePrintersAdded) {
773  Q_ASSERT(index != printerCount - 3); // separator
774  if (index > printerCount - 3) { // PDF or postscript
775  bool pdfPrinter = (index == printerCount - 2);
776  widget.location->setText(QPrintDialog::tr("Local file"));
777  widget.type->setText(QPrintDialog::tr("Write %1 file").arg(pdfPrinter ? QString::fromLatin1("PDF")
778  : QString::fromLatin1("PostScript")));
779  widget.properties->setEnabled(true);
780  widget.filename->setEnabled(true);
781  QString filename = widget.filename->text();
782  QString suffix = QFileInfo(filename).suffix();
783  if (pdfPrinter && suffix == QLatin1String("ps"))
784  filename = filename.replace(QLatin1String(".ps"), QLatin1String(".pdf"));
785  if (!pdfPrinter && suffix == QLatin1String("pdf"))
786  filename = filename.replace(QLatin1String(".pdf"), QLatin1String(".ps"));
787  widget.filename->setText(filename);
788  widget.lOutput->setEnabled(true);
789  if (propertiesDialog)
791 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
792  if (optionsPane)
794 #endif
795  return;
796  }
797  }
798 
799  widget.location->setText(QString());
800 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
803 
804  const cups_option_t *opt = cups->printerOption(QString::fromLatin1("printer-location"));
806  if (opt)
807  location = QString::fromLocal8Bit(opt->value);
808  widget.location->setText(location);
809 
810  cupsPPD = cups->currentPPD();
811  // set printer type line
812  QString type;
813  if (cupsPPD)
814  type = QString::fromLocal8Bit(cupsPPD->manufacturer) + QLatin1String(" - ") + QString::fromLocal8Bit(cupsPPD->modelname);
815  widget.type->setText(type);
816  if (propertiesDialog)
818  if (optionsPane)
820  } else {
821  if (optionsPane)
823 #endif
824  if (lprPrinters.count() > 0) {
827  type += QLatin1String(", ") + lprPrinters.at(index).comment;
828  widget.type->setText(type);
829  if (propertiesDialog)
831  }
832 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
833  }
834 #endif
835 }
const ppd_file_t * currentPPD() const
Definition: qcups.cpp:173
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
int type
Definition: qmetatype.cpp:239
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
const ppd_file_t * cupsPPD
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static bool isAvailable()
Definition: qcups.cpp:216
QPrintPropertiesDialog * propertiesDialog
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void selectPrinter(QCUPSSupport *cups)
const cups_option_t * printerOption(const QString &key) const
Definition: qcups.cpp:250
QList< QPrinterDescription > lprPrinters
const ppd_file_t * setCurrentPrinter(int index)
Definition: qcups.cpp:178
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
QString suffix() const
Returns the suffix of the file.
Definition: qfileinfo.cpp:834
void selectPdfPsPrinter(const QPrinter *p)
static QTestResult::TestLocation location
Definition: qtestresult.cpp:63
QByteArray suffix
quint16 index
QPrintDialogPrivate * optionsPane
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ applyPrinterProperties()

void QUnixPrintWidgetPrivate::applyPrinterProperties ( QPrinter p)

copy printer properties to the widget

Definition at line 864 of file qprintdialog_unix.cpp.

865 {
866  if (p == 0)
867  return;
868  printer = p;
869  if (p->outputFileName().isEmpty()) {
870  QString home = QString::fromLocal8Bit(qgetenv("HOME").constData());
871  QString cur = QDir::currentPath();
872  if (home.at(home.length()-1) != QLatin1Char('/'))
873  home += QLatin1Char('/');
874  if (cur.at(cur.length()-1) != QLatin1Char('/'))
875  cur += QLatin1Char('/');
876  if (cur.left(home.length()) != home)
877  cur = home;
878 #ifdef Q_WS_X11
879  if (p->docName().isEmpty()) {
881  cur += QLatin1String("print.ps");
882  else
883  cur += QLatin1String("print.pdf");
884  } else {
885  QRegExp re(QString::fromLatin1("(.*)\\.\\S+"));
886  if (re.exactMatch(p->docName()))
887  cur += re.cap(1);
888  else
889  cur += p->docName();
891  cur += QLatin1String(".ps");
892  else
893  cur += QLatin1String(".pdf");
894  }
895 #endif
896  widget.filename->setText(cur);
897  }
898  else
899  widget.filename->setText( p->outputFileName() );
900  QString printer = p->printerName();
901  if (!printer.isEmpty()) {
902  for (int i = 0; i < widget.printers->count(); ++i) {
903  if (widget.printers->itemText(i) == printer) {
904  widget.printers->setCurrentIndex(i);
905  break;
906  }
907  }
908  }
909  // PDF and PS printers are not added to the dialog yet, we'll handle those cases in QUnixPrintWidgetPrivate::updateWidget
910 
911  if (propertiesDialog)
913 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
QString docName() const
Returns the document name.
Definition: qprinter.cpp:1035
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString currentPath()
Returns the absolute path of the application&#39;s current directory.
Definition: qdir.cpp:1875
QString outputFileName() const
Returns the name of the output file.
Definition: qprinter.cpp:950
OutputFormat outputFormat() const
Returns the output format for this printer.
Definition: qprinter.cpp:813
QPrintPropertiesDialog * propertiesDialog
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
void applyPrinterProperties(QPrinter *p)
copy printer properties to the widget
QString printerName() const
Returns the printer name.
Definition: qprinter.cpp:834
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ checkFields()

bool QUnixPrintWidgetPrivate::checkFields ( )

Definition at line 916 of file qprintdialog_unix.cpp.

917 {
918  if (widget.filename->isEnabled()) {
919  QString file = widget.filename->text();
920  QFile f(file);
921  QFileInfo fi(f);
922  bool exists = fi.exists();
923  bool opened = false;
924  if (exists && fi.isDir()) {
926  QPrintDialog::tr("%1 is a directory.\nPlease choose a different file name.").arg(file));
927  return false;
928  } else if ((exists && !fi.isWritable()) || !(opened = f.open(QFile::Append))) {
930  QPrintDialog::tr("File %1 is not writable.\nPlease choose a different file name.").arg(file));
931  return false;
932  } else if (exists) {
933  int ret = QMessageBox::question(q, q->windowTitle(),
934  QPrintDialog::tr("%1 already exists.\nDo you want to overwrite it?").arg(file),
936  if (ret == QMessageBox::No)
937  return false;
938  }
939  if (opened) {
940  f.close();
941  if (!exists)
942  f.remove();
943  }
944  }
945 
946  // Every test passed. Accept the dialog.
947  return true;
948 }
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
The QString class provides a Unicode character string.
Definition: qstring.h:83
static StandardButton warning(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
Opens a warning message box with the given title and text in front of the specified parent widget...
QString windowTitle() const
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
static StandardButton question(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
Opens a question message box with the given title and text in front of the specified parent widget...
QAbstractPrintDialog * q
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ setCupsProperties()

void QUnixPrintWidgetPrivate::setCupsProperties ( )

Definition at line 974 of file qprintdialog_unix.cpp.

Referenced by setupPrinter().

975 {
976  if (cups && QCUPSSupport::isAvailable() && cups->pageSizes()) {
977  QPrintEngine *engine = printer->printEngine();
978  const ppd_option_t* pageSizes = cups->pageSizes();
979  QByteArray cupsPageSize;
980  for (int i = 0; i < pageSizes->num_choices; ++i) {
981  if (static_cast<int>(pageSizes->choices[i].marked) == 1)
982  cupsPageSize = pageSizes->choices[i].choice;
983  }
986 
987  QRect pageRect = cups->pageRect(cupsPageSize);
988  engine->setProperty(PPK_CupsPageRect, pageRect);
989 
990  QRect paperRect = cups->paperRect(cupsPageSize);
991  engine->setProperty(PPK_CupsPaperRect, paperRect);
992 
993  for (int ps = 0; ps < QPrinter::NPaperSize; ++ps) {
995  if (size.width == paperRect.width() && size.height == paperRect.height())
996  printer->setPaperSize(static_cast<QPrinter::PaperSize>(ps));
997  }
998  }
999 }
PaperSize paperSize(QPrinter::PaperSize paperSize)
Definition: qpdf.cpp:905
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
void setPaperSize(PaperSize)
Sets the printer paper size to newPaperSize if that size is supported.
Definition: qprinter.cpp:1163
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
QRect pageRect(const char *choice) const
Definition: qcups.cpp:321
static bool isAvailable()
Definition: qcups.cpp:216
QPrintEngine * printEngine() const
Returns the print engine used by the printer.
Definition: qprinter.cpp:1896
const ppd_option_t * pageSizes() const
Definition: qcups.cpp:259
The QPrintEngine class defines an interface for how QPrinter interacts with a given printing subsyste...
Definition: qprintengine.h:56
QRect paperRect(const char *choice) const
Definition: qcups.cpp:310
QStringList options() const
Definition: qcups.cpp:335
virtual void setProperty(PrintEnginePropertyKey key, const QVariant &value)=0
Sets the print engine&#39;s property specified by key to the given value.
#define PPK_CupsStringPageSize
Definition: qpdf_p.h:73
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
PaperSize
This enum type specifies what paper size QPrinter should use.
Definition: qprinter.h:91
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
#define PPK_CupsPaperRect
Definition: qpdf_p.h:72
#define PPK_CupsPageRect
Definition: qpdf_p.h:71
#define PPK_CupsOptions
Definition: qpdf_p.h:70

◆ setOptionsPane()

void QUnixPrintWidgetPrivate::setOptionsPane ( QPrintDialogPrivate pane)

Definition at line 837 of file qprintdialog_unix.cpp.

838 {
839  optionsPane = pane;
840  if (optionsPane)
841  _q_printerChanged(widget.printers->currentIndex());
842 }
void _q_printerChanged(int index)
QPrintDialogPrivate * optionsPane

◆ setupPrinter()

void QUnixPrintWidgetPrivate::setupPrinter ( )

Definition at line 1002 of file qprintdialog_unix.cpp.

1003 {
1004  const int printerCount = widget.printers->count();
1005  const int index = widget.printers->currentIndex();
1006 
1007  if (filePrintersAdded && index > printerCount - 3) { // PDF or postscript
1009  Q_ASSERT(index != printerCount - 3); // separator
1010  if (index == printerCount - 2)
1012  else
1014  QString path = widget.filename->text();
1015  if (QDir::isRelativePath(path))
1016  path = QDir::homePath() + QDir::separator() + path;
1017  printer->setOutputFileName(path);
1018  }
1019  else {
1020  printer->setPrinterName(widget.printers->currentText());
1022  }
1023 
1026 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
1027  if (!propertiesDialog)
1029 #endif
1030 }
static bool isRelativePath(const QString &path)
Returns true if path is relative; returns false if it is absolute.
Definition: qdir.cpp:2210
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static QChar separator()
Returns the native directory separator: "/" under Unix (including Mac OS X) and "\\" under Windows...
Definition: qdir.cpp:1831
QPrintPropertiesDialog * propertiesDialog
int result() const
In general returns the modal dialog&#39;s result code, Accepted or Rejected.
Definition: qdialog.cpp:458
quint16 index
void setOutputFormat(OutputFormat format)
Sets the output format for this printer to format.
Definition: qprinter.cpp:765
void setPrinterName(const QString &)
Sets the printer name to name.
Definition: qprinter.cpp:845
void setOutputFileName(const QString &)
Sets the name of the output file to fileName.
Definition: qprinter.cpp:976
static QString homePath()
Returns the absolute path of the user&#39;s home directory.
Definition: qdir.cpp:1942

◆ updateWidget()

void QUnixPrintWidgetPrivate::updateWidget ( )

Definition at line 722 of file qprintdialog_unix.cpp.

723 {
724  const bool printToFile = q == 0 || q->isOptionEnabled(QPrintDialog::PrintToFile);
725  if (printToFile && !filePrintersAdded) {
726  if (widget.printers->count())
727  widget.printers->insertSeparator(widget.printers->count());
728  widget.printers->addItem(QPrintDialog::tr("Print to File (PDF)"));
729  widget.printers->addItem(QPrintDialog::tr("Print to File (Postscript)"));
730  filePrintersAdded = true;
731  }
732  if (!printToFile && filePrintersAdded) {
733  widget.printers->removeItem(widget.printers->count()-1);
734  widget.printers->removeItem(widget.printers->count()-1);
735  if (widget.printers->count())
736  widget.printers->removeItem(widget.printers->count()-1); // remove separator
737  filePrintersAdded = false;
738  }
740  || printer->printerName().isEmpty()))
741  {
743  widget.printers->setCurrentIndex(widget.printers->count() - 2);
745  widget.printers->setCurrentIndex(widget.printers->count() - 1);
746  widget.filename->setEnabled(true);
747  widget.lOutput->setEnabled(true);
748  }
749 
750  widget.filename->setVisible(printToFile);
751  widget.lOutput->setVisible(printToFile);
752  widget.fileBrowser->setVisible(printToFile);
753 
755 }
bool isOptionEnabled(PrintDialogOption option) const
Use QPrintDialog::testOption(option) instead.
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
OutputFormat outputFormat() const
Returns the output format for this printer.
Definition: qprinter.cpp:813
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QAbstractPrintDialog * q
QString printerName() const
Returns the printer name.
Definition: qprinter.cpp:834

Properties

◆ cups

QCUPSSupport* QUnixPrintWidgetPrivate::cups
private

◆ cupsPPD

const ppd_file_t* QUnixPrintWidgetPrivate::cupsPPD
private

Definition at line 179 of file qprintdialog_unix.cpp.

Referenced by _q_printerChanged(), and QUnixPrintWidgetPrivate().

◆ cupsPrinterCount

int QUnixPrintWidgetPrivate::cupsPrinterCount
private

Definition at line 177 of file qprintdialog_unix.cpp.

Referenced by QUnixPrintWidgetPrivate().

◆ cupsPrinters

const cups_dest_t* QUnixPrintWidgetPrivate::cupsPrinters
private

Definition at line 178 of file qprintdialog_unix.cpp.

Referenced by QUnixPrintWidgetPrivate().

◆ filePrintersAdded

bool QUnixPrintWidgetPrivate::filePrintersAdded
private

Definition at line 174 of file qprintdialog_unix.cpp.

Referenced by _q_printerChanged(), setupPrinter(), and updateWidget().

◆ lprPrinters

QList<QPrinterDescription> QUnixPrintWidgetPrivate::lprPrinters

Definition at line 169 of file qprintdialog_unix.cpp.

Referenced by _q_printerChanged(), and QUnixPrintWidgetPrivate().

◆ optionsPane

QPrintDialogPrivate* QUnixPrintWidgetPrivate::optionsPane
private

Definition at line 173 of file qprintdialog_unix.cpp.

Referenced by _q_printerChanged(), and setOptionsPane().

◆ parent

QUnixPrintWidget* const QUnixPrintWidgetPrivate::parent

Definition at line 164 of file qprintdialog_unix.cpp.

◆ printer

QPrinter* QUnixPrintWidgetPrivate::printer

Definition at line 168 of file qprintdialog_unix.cpp.

Referenced by applyPrinterProperties().

◆ propertiesDialog

QPrintPropertiesDialog* QUnixPrintWidgetPrivate::propertiesDialog

◆ q

QAbstractPrintDialog* QUnixPrintWidgetPrivate::q

◆ widget

Ui::QPrintWidget QUnixPrintWidgetPrivate::widget

The documentation for this class was generated from the following file: