~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/models/drivermodel.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_PRINTER_DRIVERMODEL_H
 
18
#define USC_PRINTER_DRIVERMODEL_H
 
19
 
 
20
#include "printers_global.h"
 
21
 
 
22
#include "structs.h"
 
23
 
 
24
#include <QAbstractListModel>
 
25
#include <QFutureWatcher>
 
26
#include <QModelIndex>
 
27
#include <QObject>
 
28
#include <QVariant>
 
29
 
 
30
class PRINTERS_DECL_EXPORT DriverModel : public QAbstractListModel
 
31
{
 
32
    Q_OBJECT
 
33
    Q_PROPERTY(int count READ count NOTIFY countChanged)
 
34
public:
 
35
    explicit DriverModel(PrinterBackend *backend, QObject *parent = Q_NULLPTR);
 
36
    ~DriverModel();
 
37
 
 
38
    enum Roles
 
39
    {
 
40
        // Qt::DisplayRole holds driver name
 
41
        NameRole = Qt::UserRole,
 
42
        DeviceIdRole,
 
43
        LanguageRole,
 
44
        MakeModelRole,
 
45
        LastRole = MakeModelRole,
 
46
    };
 
47
 
 
48
    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
 
49
    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
 
50
    virtual QHash<int, QByteArray> roleNames() const override;
 
51
 
 
52
    int count() const;
 
53
 
 
54
    QString filter() const;
 
55
    void setFilter(const QString& pattern);
 
56
 
 
57
public Q_SLOTS:
 
58
    // Start loading the model.
 
59
    void load();
 
60
 
 
61
    // Cancel loading of the model.
 
62
    void cancel();
 
63
 
 
64
private Q_SLOTS:
 
65
    void printerDriversLoaded(const QList<PrinterDriver> &drivers);
 
66
    void filterFinished();
 
67
 
 
68
Q_SIGNALS:
 
69
    void countChanged();
 
70
    void filterBegin();
 
71
    void filterComplete();
 
72
 
 
73
private:
 
74
    void setModel(const QList<PrinterDriver> &drivers);
 
75
    PrinterBackend *m_backend;
 
76
    QList<PrinterDriver> m_drivers;
 
77
    QList<PrinterDriver> m_originalDrivers;
 
78
    QString m_filter;
 
79
    QFutureWatcher<PrinterDriver> m_watcher;
 
80
};
 
81
 
 
82
#endif // USC_PRINTER_DRIVERMODEL_H