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_PRINTER_DRIVERMODEL_H
18
#define USC_PRINTER_DRIVERMODEL_H
20
#include "printers_global.h"
24
#include <QAbstractListModel>
25
#include <QFutureWatcher>
26
#include <QModelIndex>
30
class PRINTERS_DECL_EXPORT DriverModel : public QAbstractListModel
33
Q_PROPERTY(int count READ count NOTIFY countChanged)
35
explicit DriverModel(PrinterBackend *backend, QObject *parent = Q_NULLPTR);
40
// Qt::DisplayRole holds driver name
41
NameRole = Qt::UserRole,
45
LastRole = MakeModelRole,
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;
54
QString filter() const;
55
void setFilter(const QString& pattern);
58
// Start loading the model.
61
// Cancel loading of the model.
65
void printerDriversLoaded(const QList<PrinterDriver> &drivers);
66
void filterFinished();
71
void filterComplete();
74
void setModel(const QList<PrinterDriver> &drivers);
75
PrinterBackend *m_backend;
76
QList<PrinterDriver> m_drivers;
77
QList<PrinterDriver> m_originalDrivers;
79
QFutureWatcher<PrinterDriver> m_watcher;
82
#endif // USC_PRINTER_DRIVERMODEL_H