Updated Changelog.
[LameXP.git] / src / Model_FileList.h
blob39fae7e985e3aab450126a23435aa2fa9452c883
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2018 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.
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.
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.
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
23 #pragma once
25 #include "Model_AudioFile.h"
27 #include <QAbstractTableModel>
28 #include <QIcon>
30 class FileListModel : public QAbstractTableModel
32 Q_OBJECT
34 public:
35 FileListModel(void);
36 ~FileListModel(void);
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;
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);
52 //CSV export/import
53 int exportToCsv(const QString &outFile);
54 int importFromCsv(QWidget *parent, const QString &inFile);
56 //Public types
57 enum
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
67 CsvError;
69 //Speed hacks
70 void setBlockUpdates(bool flag)
72 m_blockUpdates = flag;
73 if(!flag) reset();
76 const AudioFileModel m_nullAudioFile;
78 public slots:
79 void addFile(const QString &filePath);
80 void addFile(const AudioFileModel &file);
82 signals:
83 void rowAppended(void);
85 private:
86 bool m_blockUpdates;
87 QList<QString> m_fileList;
88 QHash<QString, AudioFileModel> m_fileStore;
89 const QIcon m_fileIcon;
91 QString int2str(const int &value) const;
92 static bool checkArray(const bool *a, const bool val, size_t len);