419 } |
421 } |
420 #endif |
422 #endif |
421 |
423 |
422 int qt_retrieveNisPrinters(QList<QPrinterDescription> *printers) |
424 int qt_retrieveNisPrinters(QList<QPrinterDescription> *printers) |
423 { |
425 { |
|
426 #ifndef QT_NO_LIBRARY |
424 typedef int (*WildCast)(int, char *, int, char *, int, char *); |
427 typedef int (*WildCast)(int, char *, int, char *, int, char *); |
425 char printersConfByname[] = "printers.conf.byname"; |
428 char printersConfByname[] = "printers.conf.byname"; |
426 char *domain; |
429 char *domain; |
427 int err; |
430 int err; |
428 |
431 |
834 if (cupsPrinters[i].instance) |
838 if (cupsPrinters[i].instance) |
835 printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance); |
839 printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance); |
836 list.append(QPrinterInfo(printerName)); |
840 list.append(QPrinterInfo(printerName)); |
837 if (cupsPrinters[i].is_default) |
841 if (cupsPrinters[i].is_default) |
838 list[i].d_ptr->m_default = true; |
842 list[i].d_ptr->m_default = true; |
839 // Find paper sizes. |
843 list[i].d_ptr->m_cupsPrinterIndex = i; |
840 cups.setCurrentPrinter(i); |
|
841 const ppd_option_t* sizes = cups.pageSizes(); |
|
842 if (sizes) { |
|
843 for (int j = 0; j < sizes->num_choices; ++j) { |
|
844 list[i].d_ptr->m_paperSizes.append( |
|
845 QPrinterInfoPrivate::string2PaperSize( |
|
846 QLatin1String(sizes->choices[j].choice))); |
|
847 } |
|
848 } |
|
849 } |
844 } |
850 } else { |
845 } else { |
851 #endif |
846 #endif |
852 QList<QPrinterDescription> lprPrinters; |
847 QList<QPrinterDescription> lprPrinters; |
853 int defprn = qt_getLprPrinters(lprPrinters); |
848 int defprn = qt_getLprPrinters(lprPrinters); |
905 if (cupsPrinters[i].instance) |
900 if (cupsPrinters[i].instance) |
906 printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance); |
901 printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance); |
907 if (printerName == printer.printerName()) { |
902 if (printerName == printer.printerName()) { |
908 if (cupsPrinters[i].is_default) |
903 if (cupsPrinters[i].is_default) |
909 d->m_default = true; |
904 d->m_default = true; |
910 // Find paper sizes. |
905 d->m_cupsPrinterIndex = i; |
911 cups.setCurrentPrinter(i); |
|
912 const ppd_option_t* sizes = cups.pageSizes(); |
|
913 if (sizes) { |
|
914 for (int j = 0; j < sizes->num_choices; ++j) { |
|
915 d->m_paperSizes.append( |
|
916 QPrinterInfoPrivate::string2PaperSize( |
|
917 QLatin1String(sizes->choices[j].choice))); |
|
918 } |
|
919 } |
|
920 return; |
906 return; |
921 } |
907 } |
922 } |
908 } |
923 } else { |
909 } else { |
924 #endif |
910 #endif |
979 } |
965 } |
980 |
966 |
981 QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const |
967 QList< QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const |
982 { |
968 { |
983 const Q_D(QPrinterInfo); |
969 const Q_D(QPrinterInfo); |
|
970 if (d->m_mustGetPaperSizes) { |
|
971 d->m_mustGetPaperSizes = false; |
|
972 |
|
973 #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) |
|
974 QCUPSSupport cups; |
|
975 if (QCUPSSupport::isAvailable()) { |
|
976 // Find paper sizes from CUPS. |
|
977 cups.setCurrentPrinter(d->m_cupsPrinterIndex); |
|
978 const ppd_option_t* sizes = cups.pageSizes(); |
|
979 if (sizes) { |
|
980 for (int j = 0; j < sizes->num_choices; ++j) { |
|
981 d->m_paperSizes.append( |
|
982 QPrinterInfoPrivate::string2PaperSize( |
|
983 QLatin1String(sizes->choices[j].choice))); |
|
984 } |
|
985 } |
|
986 } |
|
987 #endif |
|
988 |
|
989 } |
984 return d->m_paperSizes; |
990 return d->m_paperSizes; |
985 } |
991 } |
986 |
992 |
987 ///////////////////////////////////////////////////////////////////////////// |
993 ///////////////////////////////////////////////////////////////////////////// |
988 ///////////////////////////////////////////////////////////////////////////// |
994 ///////////////////////////////////////////////////////////////////////////// |
989 |
995 |
990 QPrinterInfoPrivate::QPrinterInfoPrivate() |
996 QPrinterInfoPrivate::QPrinterInfoPrivate() |
991 { |
997 { |
992 m_isNull = true; |
998 m_isNull = true; |
993 m_default = false; |
999 m_default = false; |
|
1000 m_mustGetPaperSizes = true; |
|
1001 m_cupsPrinterIndex = 0; |
994 q_ptr = 0; |
1002 q_ptr = 0; |
995 } |
1003 } |
996 |
1004 |
997 QPrinterInfoPrivate::QPrinterInfoPrivate(const QString& name) |
1005 QPrinterInfoPrivate::QPrinterInfoPrivate(const QString& name) |
998 { |
1006 { |
999 m_name = name; |
1007 m_name = name; |
1000 m_isNull = false; |
1008 m_isNull = false; |
1001 m_default = false; |
1009 m_default = false; |
|
1010 m_mustGetPaperSizes = true; |
|
1011 m_cupsPrinterIndex = 0; |
1002 q_ptr = 0; |
1012 q_ptr = 0; |
1003 } |
1013 } |
1004 |
1014 |
1005 QPrinterInfoPrivate::~QPrinterInfoPrivate() |
1015 QPrinterInfoPrivate::~QPrinterInfoPrivate() |
1006 { |
1016 { |