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 | /*! |
22 | * \class Model |
23 | * |
24 | * \inmodule ThreadWeaver |
25 | */ |
26 | class Model : public QAbstractListModel |
27 | { |
28 | Q_OBJECT |
29 | public: |
30 | /*! |
31 | * \enum Roles |
32 | * |
33 | * \value Role_SortRole |
34 | * \value Role_ImageRole |
35 | * \value Role_StepRole |
36 | */ |
37 | enum Roles { |
38 | Role_SortRole = Qt::UserRole, |
39 | Role_ImageRole, |
40 | Role_StepRole, |
41 | }; |
42 | |
43 | /*! |
44 | */ |
45 | explicit Model(QObject *parent = nullptr); |
46 | |
47 | /*! |
48 | */ |
49 | int fileLoaderCap() const; |
50 | /*! |
51 | */ |
52 | void setFileLoaderCap(int cap); |
53 | |
54 | /*! |
55 | */ |
56 | int imageLoaderCap() const; |
57 | /*! |
58 | */ |
59 | void setImageLoaderCap(int cap); |
60 | |
61 | /*! |
62 | */ |
63 | int computeThumbNailCap() const; |
64 | /*! |
65 | */ |
66 | void setComputeThumbNailCap(int cap); |
67 | |
68 | /*! |
69 | */ |
70 | int saveThumbNailCap() const; |
71 | /*! |
72 | */ |
73 | void setSaveThumbNailCap(int cap); |
74 | |
75 | /*! |
76 | */ |
77 | void clear(); |
78 | /*! |
79 | */ |
80 | void prepareConversions(const QFileInfoList &filenames, const QString &outputDirectory); |
81 | /*! |
82 | */ |
83 | bool computeThumbNailsBlockingInLoop(); |
84 | /*! |
85 | */ |
86 | bool computeThumbNailsBlockingConcurrent(); |
87 | |
88 | /*! |
89 | */ |
90 | void queueUpConversion(const QStringList &files, const QString &outputDirectory); |
91 | /*! |
92 | */ |
93 | Progress progress() const; |
94 | /*! |
95 | */ |
96 | void progressChanged(); |
97 | /*! |
98 | */ |
99 | void elementChanged(int id); |
100 | |
101 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; |
102 | QVariant data(const QModelIndex &index, int role) const override; |
103 | QVariant (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; |
104 | |
105 | Q_SIGNALS: |
106 | /*! |
107 | */ |
108 | void completed(); |
109 | /*! |
110 | */ |
111 | void progressStepChanged(int, int); |
112 | /*! |
113 | */ |
114 | void signalElementChanged(int); |
115 | |
116 | private Q_SLOTS: |
117 | /*! |
118 | */ |
119 | void slotElementChanged(int id); |
120 | |
121 | private: |
122 | QList<Image> m_images; |
123 | ThreadWeaver::ResourceRestrictionPolicy m_fileLoaderRestriction; |
124 | ThreadWeaver::ResourceRestrictionPolicy m_imageLoaderRestriction; |
125 | ThreadWeaver::ResourceRestrictionPolicy m_imageScalerRestriction; |
126 | ThreadWeaver::ResourceRestrictionPolicy m_fileWriterRestriction; |
127 | }; |
128 | |
129 | #endif // MODEL_H |
130 | |