1 | /* -*- C++ -*- |
2 | This file is part of ThreadWeaver. |
3 | |
4 | SPDX-FileCopyrightText: 2005-2014 Mirko Boehm <mirko@kde.org> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.0-or-later |
7 | */ |
8 | |
9 | #ifndef MODEL_H |
10 | #define MODEL_H |
11 | |
12 | #include <QAbstractListModel> |
13 | #include <QFileInfoList> |
14 | #include <QList> |
15 | |
16 | #include <ThreadWeaver/ResourceRestrictionPolicy> |
17 | |
18 | #include "Image.h" |
19 | #include "Progress.h" |
20 | |
21 | class Model : public QAbstractListModel |
22 | { |
23 | Q_OBJECT |
24 | public: |
25 | enum Roles { |
26 | Role_SortRole = Qt::UserRole, |
27 | Role_ImageRole, |
28 | Role_StepRole, |
29 | }; |
30 | |
31 | explicit Model(QObject *parent = nullptr); |
32 | |
33 | int fileLoaderCap() const; |
34 | void setFileLoaderCap(int cap); |
35 | |
36 | int imageLoaderCap() const; |
37 | void setImageLoaderCap(int cap); |
38 | |
39 | int computeThumbNailCap() const; |
40 | void setComputeThumbNailCap(int cap); |
41 | |
42 | int saveThumbNailCap() const; |
43 | void setSaveThumbNailCap(int cap); |
44 | |
45 | void clear(); |
46 | void prepareConversions(const QFileInfoList &filenames, const QString &outputDirectory); |
47 | bool computeThumbNailsBlockingInLoop(); |
48 | bool computeThumbNailsBlockingConcurrent(); |
49 | |
50 | void queueUpConversion(const QStringList &files, const QString &outputDirectory); |
51 | Progress progress() const; |
52 | void progressChanged(); |
53 | void elementChanged(int id); |
54 | |
55 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; |
56 | QVariant data(const QModelIndex &index, int role) const override; |
57 | QVariant (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; |
58 | |
59 | Q_SIGNALS: |
60 | void completed(); |
61 | void progressStepChanged(int, int); |
62 | void signalElementChanged(int); |
63 | |
64 | private Q_SLOTS: |
65 | void slotElementChanged(int id); |
66 | |
67 | private: |
68 | QList<Image> m_images; |
69 | ThreadWeaver::ResourceRestrictionPolicy m_fileLoaderRestriction; |
70 | ThreadWeaver::ResourceRestrictionPolicy m_imageLoaderRestriction; |
71 | ThreadWeaver::ResourceRestrictionPolicy m_imageScalerRestriction; |
72 | ThreadWeaver::ResourceRestrictionPolicy m_fileWriterRestriction; |
73 | }; |
74 | |
75 | #endif // MODEL_H |
76 | |