Warning, file /utilities/print-manager/add-printer/ChooseLpd.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2010 Daniel Nicoletti <dantti12@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "ChooseLpd.h"
0008 #include "ui_ChooseLpd.h"
0009 
0010 #include <KCupsRequest.h>
0011 #include <KLocalizedString>
0012 
0013 #include <QPainter>
0014 
0015 #include <QUrl>
0016 
0017 ChooseLpd::ChooseLpd(QWidget *parent) :
0018     GenericPage(parent),
0019     ui(new Ui::ChooseLpd),
0020     m_isValid(false)
0021 {
0022     ui->setupUi(this);
0023 
0024     // setup default options
0025     setWindowTitle(i18nc("@title:window", "Select a Printer to Add"));
0026 }
0027 
0028 ChooseLpd::~ChooseLpd()
0029 {
0030     delete ui;
0031 }
0032 
0033 void ChooseLpd::on_addressLE_textChanged(const QString &text)
0034 {
0035     Q_UNUSED(text)
0036 //    qDebug() << text;
0037 }
0038 
0039 void ChooseLpd::setValues(const QVariantHash &args)
0040 {
0041     m_args = args;
0042     const QString deviceUri = args[KCUPS_DEVICE_URI].toString();
0043     if (deviceUri.contains(QLatin1Char('/'))) {
0044         m_isValid = false;
0045         return;
0046     }
0047     m_isValid = true;
0048 
0049     ui->addressLE->setText(deviceUri);
0050     ui->addressLE->setFocus();
0051 }
0052 
0053 QVariantHash ChooseLpd::values() const
0054 {
0055     QVariantHash ret = m_args;
0056     ret[KCUPS_DEVICE_URI] = static_cast<QString>(QLatin1String("lpd://") + ui->addressLE->text());
0057     return ret;
0058 }
0059 
0060 bool ChooseLpd::canProceed() const
0061 {
0062     bool allow = false;
0063     if (!ui->addressLE->text().isEmpty()) {
0064         const QUrl url = QUrl(QLatin1String("lpd://") + ui->addressLE->text());
0065         allow = url.isValid();
0066     }
0067     return allow;
0068 }
0069 
0070 bool ChooseLpd::isValid() const
0071 {
0072     return m_isValid;
0073 }
0074 
0075 void ChooseLpd::checkSelected()
0076 {
0077 //     Q_EMIT allowProceed(!devicesLV->selectionModel()->selection().isEmpty());
0078 }
0079 
0080 #include "moc_ChooseLpd.cpp"