Now saves using KwKWorshipFilter instead of KwDocument
[kworship.git] / kworship / KwDocument.cpp
blob870f70c39e91d64641a3a6a7d482bccde1fcaa55
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 /**
21 * @file KwDocument.cpp
22 * @brief A KWorship document (anything saved in a KWorship data file).
23 * @author James Hogan <james@albanarts.com>
26 #include "KwDocument.h"
27 #include "KwPlaylistList.h"
28 #include "KwLoadSaveFilter.h"
31 * Constructors + destructor
34 /// Primary constructor.
35 KwDocument::KwDocument(KwLoadSaveFilter* filter, const QString& mimeType, KUrl url, QObject* parent)
36 : QObject(parent)
37 , m_url(url)
38 , m_mimeType(mimeType)
39 , m_activeFilter(filter)
40 , m_modified(false)
41 , m_playlist(new KwPlaylistList())
45 /// Destructor.
46 KwDocument::~KwDocument()
48 delete m_playlist;
52 * Accessors
55 /// Find whether the document has been modified.
56 bool KwDocument::isModified() const
58 return m_modified;
61 /// Find whether the document has ever been saved.
62 bool KwDocument::isSaved() const
64 return !m_url.isEmpty();
67 /// Get the URL the document is saved at.
68 KUrl KwDocument::url() const
70 return m_url;
73 /// Get the main playlist.
74 KwPlaylistList* KwDocument::playlist()
76 return m_playlist;
79 /// Get the current mime type.
80 const QString& KwDocument::mimeType() const
82 return m_mimeType;
86 * Mutators
89 /// Set the main playlist.
90 void KwDocument::setPlaylist(KwPlaylistList* playlist)
92 delete m_playlist;
93 m_playlist = playlist;
94 emit playlistReset();
98 * Saving and loading actions
101 /// Save the file.
102 void KwDocument::save()
104 Q_ASSERT(0 != m_activeFilter);
105 bool success = m_activeFilter->save(this, m_url, m_mimeType);
106 if (success)
108 setModified(false);
112 /// Save the file to a different URL.
113 void KwDocument::saveAs(KwLoadSaveFilter* filter, const QString& mimeType, const KUrl& url)
115 bool success = filter->save(this, url, mimeType);
116 if (success)
118 m_activeFilter = filter;
119 m_mimeType = mimeType;
120 m_url = url;
125 * Other slots
128 /// Set whether the file is modified.
129 void KwDocument::setModified(bool modified)
131 if (m_modified != modified)
133 m_modified = modified;
134 modifiedChanged(modified);