1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
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. *
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. *
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 ***************************************************************************/
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
)
38 , m_mimeType(mimeType
)
39 , m_activeFilter(filter
)
41 , m_playlist(new KwPlaylistList())
46 KwDocument::~KwDocument()
55 /// Find whether the document has been modified.
56 bool KwDocument::isModified() const
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
73 /// Get the main playlist.
74 KwPlaylistList
* KwDocument::playlist()
79 /// Get the current mime type.
80 const QString
& KwDocument::mimeType() const
89 /// Set the main playlist.
90 void KwDocument::setPlaylist(KwPlaylistList
* playlist
)
93 m_playlist
= playlist
;
98 * Saving and loading actions
102 void KwDocument::save()
104 Q_ASSERT(0 != m_activeFilter
);
105 bool success
= m_activeFilter
->save(this, m_url
, m_mimeType
);
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
);
118 m_activeFilter
= filter
;
119 m_mimeType
= mimeType
;
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
);