Qmmp
playlistheadermodel.h
1 /***************************************************************************
2  * Copyright (C) 2015 by Ilya Kotov *
3  * forkotov02@ya.ru *
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. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #ifndef PLAYLISTHEADERMODEL_H
22 #define PLAYLISTHEADERMODEL_H
23 
24 #include <QObject>
25 #include <QWidget>
26 #include <QSettings>
27 #include <QHash>
28 #include <QVariant>
29 #include "metadataformatter.h"
30 
31 class MetaDataHelper;
32 
37 class PlayListHeaderModel : public QObject
38 {
39  Q_OBJECT
40 public:
45  explicit PlayListHeaderModel(QObject *parent = 0);
54  void restoreSettings(const QString &groupName);
59  void restoreSettings(QSettings *settings);
64  void saveSettings(const QString &groupName);
69  void saveSettings(QSettings *settings);
73  bool isSettingsLoaded() const;
80  void insert(int index, const QString &name, const QString &pattern);
85  void remove(int index);
89  void move(int from, int to);
95  void execEdit(int index, QWidget *parent = 0);
101  void execInsert(int index, QWidget *parent = 0);
105  int count();
109  const QString name(int index) const;
113  const QString pattern(int index) const;
120  void setData(int index, int key, const QVariant &data);
126  const QVariant data(int index, int key) const;
127 
128 signals:
133  void columnAdded(int index);
138  void columnRemoved(int index);
143  void columnChanged(int index);
147  void columnMoved(int from, int to);
151  void headerChanged();
152 
153 private:
154  void updatePlayLists();
155 
156  struct ColumnHeader
157  {
158  QString name;
159  QString pattern;
160  QHash<int, QVariant> data;
161  };
162  QList<ColumnHeader> m_columns;
163  bool m_settings_loaded;
164  MetaDataHelper *m_helper;
165 };
166 
167 #endif // COLUMNMANAGER_H
void move(int from, int to)
Helper class that provides access to playlist column configuration.
Definition: playlistheadermodel.h:37
void execEdit(int index, QWidget *parent=0)
void setData(int index, int key, const QVariant &data)
void columnChanged(int index)
void execInsert(int index, QWidget *parent=0)
void columnRemoved(int index)
void columnAdded(int index)
const QVariant data(int index, int key) const
void columnMoved(int from, int to)
bool isSettingsLoaded() const
const QString name(int index) const
PlayListHeaderModel(QObject *parent=0)
void insert(int index, const QString &name, const QString &pattern)
void restoreSettings(const QString &groupName)
void saveSettings(const QString &groupName)
const QString pattern(int index) const