OSDN Git Service

Updated Monkey's Audio binaries to v5.54 (2020-08-24), compiled with ICL 19.1 and...
[lamexp/LameXP.git] / src / Model_FileList.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2020 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; always including the non-optional
9 // LAMEXP GNU GENERAL PUBLIC LICENSE ADDENDUM. See "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 "Model_AudioFile.h"
26
27 #include <QAbstractTableModel>
28 #include <QIcon>
29
30 class FileListModel : public QAbstractTableModel
31 {
32         Q_OBJECT
33
34 public:
35         FileListModel(void);
36         ~FileListModel(void);
37
38         //Model functions
39         int columnCount(const QModelIndex &parent = QModelIndex()) const;
40         int rowCount(const QModelIndex &parent = QModelIndex()) const;
41         QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
42         QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
43
44         //Edit functions
45         bool removeFile(const QModelIndex &index);
46         void clearFiles(void);
47         bool moveFile(const QModelIndex &index, int delta);
48         const AudioFileModel &getFile(const QModelIndex &index);
49         bool setFile(const QModelIndex &index, const AudioFileModel &audioFile);
50         AudioFileModel &operator[] (const QModelIndex &index);
51
52         //CSV export/import
53         int exportToCsv(const QString &outFile);
54         int importFromCsv(QWidget *parent, const QString &inFile);
55
56         //Public types
57         enum
58         {
59                 CsvError_OK = 0,
60                 CsvError_NoTags = 1,
61                 CsvError_FileOpen = 2,
62                 CsvError_FileRead = 3,
63                 CsvError_FileWrite = 4,
64                 CsvError_Incomplete = 5,
65                 CsvError_Aborted = 6
66         }
67         CsvError;
68
69         //Speed hacks
70         void setBlockUpdates(bool flag)
71         {
72                 m_blockUpdates = flag;
73                 if(!flag) reset();
74         }
75
76         const AudioFileModel m_nullAudioFile;
77
78 public slots:
79         void addFile(const QString &filePath);
80         void addFile(const AudioFileModel &file);
81
82 signals:
83         void rowAppended(void);
84
85 private:
86         bool m_blockUpdates;
87         QList<QString> m_fileList;
88         QHash<QString, AudioFileModel> m_fileStore;
89         const QIcon m_fileIcon;
90
91         QString int2str(const int &value) const;
92         static bool checkArray(const bool *a, const bool val, size_t len);
93 };