Songbook-Client  0.7
This application is a manager of customguitar songbooks
 All Classes Files Functions Variables Enumerations Enumerator Pages
songbook.hh
Go to the documentation of this file.
1 // Copyright (C) 2009-2011, Romain Goffe <romain.goffe@gmail.com>
2 // Copyright (C) 2009-2011, Alexandre Dupas <alexandre.dupas@gmail.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License as
6 // published by the Free Software Foundation; either version 2 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but
10 // WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 // 02110-1301, USA.
18 //******************************************************************************
19 #ifndef __SONGBOOK_HH__
20 #define __SONGBOOK_HH__
21 
22 #include "identity-proxy-model.hh"
23 
24 #include <QDir>
25 #include <QString>
26 #include <QStringList>
27 
28 #include <QtVariantProperty>
29 
30 class CLibrary;
31 
32 class QWidget;
33 class QComboBox;
34 class QtGroupBoxPropertyBrowser;
35 class QtGroupPropertyManager;
36 
53 {
54  Q_OBJECT
55  Q_PROPERTY(bool modified READ isModified WRITE setModified NOTIFY wasModified)
56  Q_PROPERTY(QString filename READ filename WRITE setFilename)
57  Q_PROPERTY(QString tmpl READ tmpl WRITE setTmpl)
58  Q_PROPERTY(QStringList songs READ songs WRITE setSongs)
59 
60 public slots:
65  void setFilename(const QString &filename);
66 
71  void setTmpl(const QString &tmpl);
72 
77  void setSongs(QStringList songs);
78 
82  void reset();
83 
88  void save(const QString &filename);
89 
94  void load(const QString &filename);
95 
100  void setModified(bool value);
101 
106  void changeTemplate(const QString &filename = QString());
107 
112  void checkAll();
113 
118  void uncheckAll();
119 
124  void toggleAll();
125 
130  void setChecked(const QModelIndex &index, bool value);
131 
136  void toggle(const QModelIndex &index);
137 
138 public:
140  CSongbook(QObject *parent);
141 
143  ~CSongbook();
144 
148  QString workingPath() const;
149 
154  void setLibrary(CLibrary *library);
155 
160  CLibrary * library() const;
161 
166  QString filename() const;
167 
172  QString tmpl() const;
173 
177  int selectedCount() const;
178  void selectLanguages(const QStringList &languages);
179 
184  void songsFromSelection();
185 
190  void songsToSelection();
191 
196  QStringList songs();
197 
202  bool isModified();
203 
207  void initializeEditor(QtGroupBoxPropertyBrowser *editor);
208 
212  bool isChecked(const QModelIndex &index);
213 
214  virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
215  virtual Qt::ItemFlags flags(const QModelIndex &index) const;
216  virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
217 
218 signals:
219  void wasModified(bool modified);
220  void songsChanged();
221 
222 private slots:
223  void sourceModelAboutToBeReset();
224  void sourceModelReset();
225 
226 private:
227  CLibrary *m_library;
228  QString m_filename;
229  QString m_tmpl;
230 
231  QList< bool > m_selectedSongs;
232  QStringList m_songs;
233 
234  bool m_modified;
235 
236  QtVariantPropertyManager *m_propertyManager;
237  QtGroupPropertyManager *m_groupManager;
238 
239  QMap< QString, QtVariantProperty* > m_parameters;
240 
241  QList< QtProperty*> m_mandatoryParameters;
242  QtProperty *m_advancedParameters;
243 };
244 
245 #endif // __SONGBOOK_HH__