QCUPSSupport: clear the job-hold-until option if jobHoldToString() is empty
This changes the behavior of the code such that the option, once set, can also be unset again. Change-Id: I739f77ae1f1336806aac548f6a797ed6b2770235 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
eb5654788b
commit
8133b80e63
@ -59,6 +59,16 @@ void QCUPSSupport::setCupsOption(QStringList &cupsOptions, const QString &option
|
||||
}
|
||||
}
|
||||
|
||||
void QCUPSSupport::clearCupsOption(QStringList &cupsOptions, const QString &option)
|
||||
{
|
||||
// ### use const_iterator once QList::erase takes them
|
||||
const QStringList::iterator it = std::find(cupsOptions.begin(), cupsOptions.end(), option);
|
||||
if (it != cupsOptions.end()) {
|
||||
Q_ASSERT(it + 1 < cupsOptions.end());
|
||||
cupsOptions.erase(it, it+1);
|
||||
}
|
||||
}
|
||||
|
||||
static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold, const QTime holdUntilTime)
|
||||
{
|
||||
switch (jobHold) {
|
||||
@ -94,14 +104,16 @@ static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold,
|
||||
|
||||
void QCUPSSupport::setJobHold(QPrinter *printer, const JobHoldUntil jobHold, const QTime &holdUntilTime)
|
||||
{
|
||||
QStringList cupsOptions = cupsOptionsList(printer);
|
||||
const QString jobHoldUntilArgument = jobHoldToString(jobHold, holdUntilTime);
|
||||
if (!jobHoldUntilArgument.isEmpty()) {
|
||||
QStringList cupsOptions = cupsOptionsList(printer);
|
||||
setCupsOption(cupsOptions,
|
||||
QStringLiteral("job-hold-until"),
|
||||
jobHoldUntilArgument);
|
||||
setCupsOptions(printer, cupsOptions);
|
||||
} else {
|
||||
clearCupsOption(cupsOptions, QStringLiteral("job-hold-until"));
|
||||
}
|
||||
setCupsOptions(printer, cupsOptions);
|
||||
}
|
||||
|
||||
void QCUPSSupport::setJobBilling(QPrinter *printer, const QString &jobBilling)
|
||||
|
@ -117,6 +117,7 @@ public:
|
||||
static QStringList cupsOptionsList(QPrinter *printer);
|
||||
static void setCupsOptions(QPrinter *printer, const QStringList &cupsOptions);
|
||||
static void setCupsOption(QStringList &cupsOptions, const QString &option, const QString &value);
|
||||
static void clearCupsOption(QStringList &cupsOptions, const QString &option);
|
||||
|
||||
static void setJobHold(QPrinter *printer, const JobHoldUntil jobHold = NoHold, const QTime &holdUntilTime = QTime());
|
||||
static void setJobBilling(QPrinter *printer, const QString &jobBilling = QString());
|
||||
|
Loading…
Reference in New Issue
Block a user