~ahayzen/ubuntu-ui-extras/printer-components-fix-empty-commented-tests

« back to all changes in this revision

Viewing changes to modules/Ubuntu/Components/Extras/Printers/printer/printer.h

  • Committer: Andrew Hayzen
  • Date: 2017-02-21 10:46:29 UTC
  • Revision ID: ahayzen@gmail.com-20170221104629-pbm454x5k7rr4ot5
* Add printer-components from ubuntu-settings-components to ubuntu-ui-extras (original branch https://code.launchpad.net/~phablet-team/ubuntu-settings-components/printer-components)
* Add plugin module to Extras/Printers
* Add translation support for cpp/h
* Add tests for Printers
* Add debian depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2017 Canonical, Ltd.
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 */
 
16
 
 
17
#ifndef USC_PRINTERS_PRINTER_H
 
18
#define USC_PRINTERS_PRINTER_H
 
19
 
 
20
#include "printers_global.h"
 
21
 
 
22
#include "backend/backend.h"
 
23
#include "enums.h"
 
24
#include "models/jobmodel.h"
 
25
#include "printer/printerjob.h"
 
26
#include "structs.h"
 
27
 
 
28
#include <QObject>
 
29
#include <QPageSize>
 
30
#include <QList>
 
31
#include <QScopedPointer>
 
32
#include <QSortFilterProxyModel>
 
33
#include <QString>
 
34
#include <QStringList>
 
35
 
 
36
class PrinterBackend;
 
37
class PrinterJob;
 
38
class PRINTERS_DECL_EXPORT Printer : public QObject
 
39
{
 
40
    Q_OBJECT
 
41
public:
 
42
    explicit Printer(PrinterBackend *backend, QObject *parent = nullptr);
 
43
    ~Printer();
 
44
 
 
45
    bool enabled() const;
 
46
    ColorModel defaultColorModel() const;
 
47
    QList<ColorModel> supportedColorModels() const;
 
48
    QList<PrinterEnum::DuplexMode> supportedDuplexModes() const;
 
49
    QStringList supportedDuplexStrings() const;
 
50
    PrinterEnum::DuplexMode defaultDuplexMode() const;
 
51
    QString name() 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();
 
65
 
 
66
    PrinterEnum::PrinterType type() const;
 
67
 
 
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);
 
78
 
 
79
    bool deepCompare(QSharedPointer<Printer> other) const;
 
80
    void updateFrom(QSharedPointer<Printer> other);
 
81
 
 
82
 
 
83
public Q_SLOTS:
 
84
    // Add user that is either denied or allowed printer. See AccessControl.
 
85
    void addUser(const QString &username);
 
86
 
 
87
    int printFile(const QString &filepath, const PrinterJob *options);
 
88
 
 
89
    // Removes user. See addUser.
 
90
    void removeUser(const QString &username);
 
91
 
 
92
private:
 
93
    void loadAcceptJobs();
 
94
    void loadColorModel();
 
95
    void loadPrintQualities();
 
96
 
 
97
    JobFilter m_jobs;
 
98
    PrinterBackend *m_backend;
 
99
    ColorModel m_defaultColorModel;
 
100
    QList<ColorModel> m_supportedColorModels;
 
101
    PrintQuality m_defaultPrintQuality;
 
102
    QList<PrintQuality> m_supportedPrintQualities;
 
103
    bool m_acceptJobs;
 
104
};
 
105
 
 
106
// FIXME: not necessary outside tests
 
107
Q_DECLARE_METATYPE(QList<PrinterEnum::DuplexMode>)
 
108
 
 
109
#endif // USC_PRINTERS_PRINTER_H