Basic zionworx playlist mime data and filter plugin which doesn't do anything yet
[kworship.git] / kworship / filters / zionworx / KwZionworxFilter.cpp
blobd9aa17ef503fc9f7f1b00ad015a715207f218d1c
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 KwZionworxFilter.cpp
22 * @brief Main Zionworx load and save filter.
23 * @author James Hogan <james@albanarts.com>
26 #include "KwZionworxFilter.h"
27 #include "KwDocument.h"
28 #include "KwArchive.h"
29 #include "KwPlaylistList.h"
31 #include <KUrl>
32 #include <KMessageBox>
33 #include <KLocale>
34 #include <KSaveFile>
37 * Constructors + destructor
40 /// Primary constructor.
41 KwZionworxFilter::KwZionworxFilter()
42 : KwLoadSaveFilter()
44 m_importMimeTypes += "application/x-zionworx+xml";
45 m_exportMimeTypes += "application/x-zionworx+xml";
48 /// Destructor.
49 KwZionworxFilter::~KwZionworxFilter()
54 * Main interface
57 KwDocument* KwZionworxFilter::load(const KUrl& url, const QString& mimeType)
59 /// @todo Handle non-local files
60 if (!url.isLocalFile())
62 KMessageBox::error(0,
63 i18n("Non-local loads not yet supported"),
64 i18n("Zionworx"));
65 return 0;
68 KwDocument* doc = new KwDocument(this, mimeType, url);
70 /// @todo Implement KwZionworxFilter::load
72 doc->setModified(false);
74 return doc;
77 bool KwZionworxFilter::save(KwDocument* doc, const KUrl& url, const QString& mimeType)
79 /// @todo Handle non-local files
80 if (!url.isLocalFile())
82 KMessageBox::error(0,
83 i18n("Non-local loads not yet supported"),
84 i18n("Zionworx"));
85 return false;
87 KSaveFile file;
88 file.setFileName(url.toLocalFile());
89 if (!file.open(QFile::WriteOnly))
91 KMessageBox::error(0,
92 i18n("Cannot write file %1:\n%2.")
93 .arg(file.fileName())
94 .arg(file.errorString()),
95 i18n("Zionworx"));
96 return false;
99 /// @todo Implement KwZionworxFilter::save
101 if (!file.finalize())
103 KMessageBox::error(0,
104 i18n("Cannot finalize file %1:\n%2.")
105 .arg(file.fileName())
106 .arg(file.errorString()),
107 i18n("Zionworx"));
108 return false;
111 doc->setModified(false);
113 return true;
117 * Virtual interface
120 void KwZionworxFilter::v_saveLimitations(KwDocument* doc, const QString& mimeType, Limitations* o_limitations)
122 /// @todo Implement KwZionworxFilter::v_saveLimitations
123 Q_ASSERT(false);