Loading of song data from zionworx
[kworship.git] / kworship / songdb / KwSongdbVersion.h
blobb87e5bf32d9be902fe31f45fa99294ee40b6f105
1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
4 * *
5 * KWorship 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 * KWorship 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 KWorship. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 #ifndef _KwSongdbVersion_h_
21 #define _KwSongdbVersion_h_
23 /**
24 * @file KwSongdbVersion.h
25 * @brief A song version from the database.
26 * @author James Hogan <james@albanarts.com>
29 #include "KwSongdbLyrics.h"
31 #include <kdemacros.h>
33 #include <QHash>
34 #include <QVector>
36 class KwSongdbSong;
37 class KwSongdbSongBookSong;
39 /// A song version from the database.
40 class KDE_EXPORT KwSongdbVersion
42 public:
45 * Types
48 /// Version data fields.
49 enum Field
51 Name = 0x1,
52 Writer = 0x2,
53 Copyright = 0x4,
54 Lyrics = 0x8
56 Q_DECLARE_FLAGS(Fields, Field)
59 * Constructors + destructor
62 /** Construct a new version for database insertion.
63 * This constructs a blank song version which will be inserted into the
64 * database when it is saved.
65 * @param song The song for the version to belong to.
67 KwSongdbVersion(KwSongdbSong* song);
69 /** Construct from the database.
70 * Loads the version information from the database.
71 * @param id Database id of version.
73 KwSongdbVersion(int id);
75 /// Destructor.
76 virtual ~KwSongdbVersion();
79 * Accessors
82 /// Get the version id.
83 int id();
85 /// Get the song this is a version of.
86 KwSongdbSong* song();
88 /// Get the name of this version.
89 QString name() const;
91 /** Get a non-empty name of this version.
92 * @return The name or i18n("Default version").
94 QString niceName() const;
96 /// Get the name of the writer.
97 QString writer() const;
99 /// Get the copyright notice.
100 QString copyright() const;
102 /// Get the lyrics.
103 const KwSongdbLyrics& lyrics() const;
105 /// Get song book numbers.
106 QList<KwSongdbSongBookSong*> songBookNumbers();
109 * Mutators
112 /// Set the name.
113 void setName(const QString& name);
115 /// Set the writer.
116 void setWriter(const QString& writer);
118 /// Set the copyright notice.
119 void setCopyright(const QString& copyright);
121 /// Set the lyrics markup.
122 void setLyricsMarkup(const QString& markup);
124 /// Set the lyrics plain text verses.
125 void setLyricsPlainVerses(const QStringList& plainVerses);
127 /// Set the lyrics.
128 void setLyrics(const KwSongdbLyrics& lyrics);
130 /// Save changes to the version data.
131 void save();
133 private:
136 * Variables
139 /// Version id.
140 int m_id;
142 /// Song object.
143 KwSongdbSong* m_song;
145 /// Which fields have been modified.
146 Fields m_modifiedFields;
148 /// Name of this version.
149 QString m_name;
151 /// Name of the writer.
152 QString m_writer;
154 /// Copyright notice.
155 QString m_copyright;
157 /// Lyrics.
158 KwSongdbLyrics m_lyrics;
160 /// Whether song book numbers have been loaded.
161 bool m_songBookNumbersLoaded;
163 /// Song book numbers.
164 QList<KwSongdbSongBookSong*> m_songBookNumbers;
167 Q_DECLARE_OPERATORS_FOR_FLAGS(KwSongdbVersion::Fields)
169 #endif // _KwSongdbVersion_h_