Mime type based filter loading
[kworship.git] / kworship / KwKWorshipFilter.cpp
blob1c11b3be0907bf40043881c8cad50b6a47cbd136
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 KwKWorshipFilter.cpp
22 * @brief Main KWorship archive load and save filter.
23 * @author James Hogan <james@albanarts.com>
26 #include "KwKWorshipFilter.h"
27 #include "KwDocument.h"
28 #include "KwArchive.h"
29 #include "KwPlaylistList.h"
31 #include <KUrl>
32 #include <KMessageBox>
33 #include <KLocale>
36 * Constructors + destructor
39 /// Primary constructor.
40 KwKWorshipFilter::KwKWorshipFilter()
41 : KwLoadSaveFilter()
43 m_importMimeTypes += "application/x-kworship+xml";
44 m_exportMimeTypes += "application/x-kworship+xml";
45 m_importMimeTypes += "application/x-kworship-archive";
46 m_exportMimeTypes += "application/x-kworship-archive";
49 /// Destructor.
50 KwKWorshipFilter::~KwKWorshipFilter()
55 * Main interface
58 KwDocument* KwKWorshipFilter::load(const KUrl& url)
60 // Start off by opening the archive file
61 if (!url.isLocalFile())
63 KMessageBox::error(0,
64 i18n("Non-local loads not yet supported"),
65 i18n("KWorship"));
66 return 0;
69 KwDocument* doc = new KwDocument(url);
70 // Open archive object and fill it
71 KwArchive* archive = new KwArchive(url.toLocalFile(), false);
72 Q_ASSERT(archive->isReading());
74 KwPlaylistList* playlist = archive->extractPlaylist("0");
75 if (0 != playlist)
77 doc->setPlaylist(playlist);
80 delete archive;
82 doc->setModified(false);
84 return doc;
87 bool KwKWorshipFilter::save(KwDocument* doc, const KUrl& url)
89 /// @todo Implement KwKWorshipFilter::save
90 Q_ASSERT(false);
94 * Virtual interface
97 void KwKWorshipFilter::v_saveLimitations(KwDocument* doc, Limitations* o_limitations)
99 /// @todo Implement KwKWorshipFilter::v_saveLimitations
100 Q_ASSERT(false);