Sayonara Player
LibraryListModel.h
1 /* LibraryListModel.h */
2 
3 /* Copyright (C) 2011-2019 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 
23 #ifndef LIBRARYLISTMODEL_H
24 #define LIBRARYLISTMODEL_H
25 
26 #include <QAbstractListModel>
27 #include "Utils/Pimpl.h"
28 
29 using LibName=QString;
30 using LibPath=QString;
31 
33  public QAbstractListModel
34 {
35  Q_OBJECT
36  PIMPL(LibraryListModel)
37 
38 public:
39  LibraryListModel(QObject* parent=nullptr);
41 
42 public:
43  int rowCount(const QModelIndex& parent=QModelIndex()) const override;
44  QVariant data(const QModelIndex& index, int role) const override;
45 
46  void append_row(const LibName& name, const LibPath& path);
47  void rename_row(int row, const LibName& new_name);
48  void change_path(int row, const LibPath& path);
49  void move_row(int from, int to);
50  void remove_row(int row);
51 
52  QStringList all_names() const;
53  QStringList all_paths() const;
54  QString name(int idx) const;
55  QString path(int idx) const;
56 
57  void reset();
58  bool commit();
59 };
60 
61 #endif // LIBRARYLISTMODEL_H
LibraryListModel
Definition: LibraryListModel.h:32