OSDN Git Service

Small installer tweak.
[lamexp/LameXP.git] / src / Model_Progress.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version, but always including the *additional*
9 // restrictions defined in the "License.txt" file.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 //
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
22
23 #pragma once
24
25 #include <QAbstractTableModel>
26
27 #include <QString>
28 #include <QStringList>
29 #include <QHash>
30 #include <QSet>
31 #include <QUuid>
32 #include <QIcon>
33 #include <QUuid>
34
35 class ProgressModel : public QAbstractTableModel
36 {
37         Q_OBJECT
38
39 public:
40         ProgressModel(void);
41         ~ProgressModel(void);
42
43         //Enums
44         enum JobState
45         {
46                 JobRunning = 0,
47                 JobPaused = 1,
48                 JobComplete = 2,
49                 JobFailed = 3,
50                 JobSystem = 4,
51                 JobWarning = 5,
52                 JobPerformance = 6,
53                 JobSkipped = 7
54         };
55         enum SysMsgType
56         {
57                 SysMsg_Info = 0,
58                 SysMsg_Performance = 1,
59                 SysMsg_Warning = 2
60         };
61
62         //Model functions
63         int columnCount(const QModelIndex &parent = QModelIndex()) const;
64         int rowCount(const QModelIndex &parent = QModelIndex()) const;
65         QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
66         QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
67
68         //Public functions
69         const QStringList &getLogFile(const QModelIndex &index) const;
70         const QUuid &getJobId(const QModelIndex &index) const;
71         const JobState getJobState(const QModelIndex &index) const;
72         const QIcon &getIcon(ProgressModel::JobState state) const;
73         void restoreHiddenItems(void);
74
75 public slots:
76         void addJob(const QUuid &jobId, const QString &jobName, const QString &jobInitialStatus = QString("Initializing..."), int jobInitialState = JobRunning);
77         void updateJob(const QUuid &jobId, const QString &newStatus, int newState);
78         void appendToLog(const QUuid &jobId, const QString &line);
79         void addSystemMessage(const QString &text, int type = SysMsg_Info);
80
81 private:
82         QList<QUuid> m_jobList;
83         QList<QUuid> m_jobListHidden;
84         QHash<QUuid, QString> m_jobName;
85         QHash<QUuid, QString> m_jobStatus;
86         QHash<QUuid, int> m_jobState;
87         QHash<QUuid, QStringList> m_jobLogFile;
88         QHash<QUuid, int> m_jobIndexCache;
89         QSet<QUuid> m_jobIdentifiers;
90
91         const QIcon m_iconRunning;
92         const QIcon m_iconPaused;
93         const QIcon m_iconComplete;
94         const QIcon m_iconFailed;
95         const QIcon m_iconSystem;
96         const QIcon m_iconWarning;
97         const QIcon m_iconPerformance;
98         const QIcon m_iconSkipped;
99         const QIcon m_iconUndefined;
100
101         const QStringList m_emptyList;
102         const QUuid m_emptyUuid;
103 };