2
* Copyright (C) 2017 Canonical, Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
#ifndef USC_PRINTERS_PRINTER_H
18
#define USC_PRINTERS_PRINTER_H
20
#include "printers_global.h"
22
#include "backend/backend.h"
24
#include "models/jobmodel.h"
25
#include "printer/printerjob.h"
31
#include <QScopedPointer>
32
#include <QSortFilterProxyModel>
34
#include <QStringList>
38
class PRINTERS_DECL_EXPORT Printer : public QObject
42
explicit Printer(PrinterBackend *backend, QObject *parent = nullptr);
46
ColorModel defaultColorModel() const;
47
QList<ColorModel> supportedColorModels() const;
48
QList<PrinterEnum::DuplexMode> supportedDuplexModes() const;
49
QStringList supportedDuplexStrings() const;
50
PrinterEnum::DuplexMode defaultDuplexMode() const;
52
PrintQuality defaultPrintQuality() const;
53
QList<PrintQuality> supportedPrintQualities() const;
54
QString description() const;
55
QPageSize defaultPageSize() const;
56
QList<QPageSize> supportedPageSizes() const;
57
PrinterEnum::AccessControl accessControl() const;
58
PrinterEnum::ErrorPolicy errorPolicy() const;
59
QStringList users() const;
60
PrinterEnum::State state() const;
61
QString lastStateMessage() const;
62
bool acceptJobs() const;
63
bool holdsDefinition() const;
64
QAbstractItemModel* jobs();
66
PrinterEnum::PrinterType type() const;
68
void setAccessControl(const PrinterEnum::AccessControl &accessControl);
69
void setDefaultColorModel(const ColorModel &colorModel);
70
void setDescription(const QString &description);
71
void setDefaultDuplexMode(const PrinterEnum::DuplexMode &duplexMode);
72
void setEnabled(const bool enabled);
73
void setAcceptJobs(const bool accepting);
74
void setErrorPolicy(const PrinterEnum::ErrorPolicy &errorPolicy);
75
void setDefaultPrintQuality(const PrintQuality &quality);
76
void setDefaultPageSize(const QPageSize &pageSize);
77
void setJobModel(JobModel* jobModel);
79
bool deepCompare(QSharedPointer<Printer> other) const;
80
void updateFrom(QSharedPointer<Printer> other);
84
// Add user that is either denied or allowed printer. See AccessControl.
85
void addUser(const QString &username);
87
int printFile(const QString &filepath, const PrinterJob *options);
89
// Removes user. See addUser.
90
void removeUser(const QString &username);
93
void loadAcceptJobs();
94
void loadColorModel();
95
void loadPrintQualities();
98
PrinterBackend *m_backend;
99
ColorModel m_defaultColorModel;
100
QList<ColorModel> m_supportedColorModels;
101
PrintQuality m_defaultPrintQuality;
102
QList<PrintQuality> m_supportedPrintQualities;
106
// FIXME: not necessary outside tests
107
Q_DECLARE_METATYPE(QList<PrinterEnum::DuplexMode>)
109
#endif // USC_PRINTERS_PRINTER_H