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 KwFilterManager.cpp
22 * @brief Manages file filters.
23 * @author James Hogan <james@albanarts.com>
26 #include "KwFilterManager.h"
27 #include "KwLoadSaveFilter.h"
30 * Constructors + destructor
33 /// Primary constructor.
34 KwFilterManager::KwFilterManager()
35 : m_defaultLoadSaveFilter(0)
43 KwFilterManager::~KwFilterManager()
45 // Delete all filters.
46 foreach (KwLoadSaveFilter
* filter
, m_loadSaveFilters
)
50 foreach (KwImportFilter
* filter
, m_importFilters
)
54 foreach (KwExportFilter
* filter
, m_exportFilters
)
64 /// Add a load save filter.
65 void KwFilterManager::addLoadSaveFilter(KwLoadSaveFilter
* loadSaveFilter
, bool makeDefault
)
67 m_loadSaveFilters
+= loadSaveFilter
;
70 m_defaultLoadSaveFilter
= loadSaveFilter
;
74 /// Add an import filter.
75 void KwFilterManager::addImportFilter(KwImportFilter
* importFilter
)
77 m_importFilters
+= importFilter
;
80 /// Add an export filter.
81 void KwFilterManager::addExportFilter(KwExportFilter
* exportFilter
)
83 m_exportFilters
+= exportFilter
;
86 /// Get load mime types.
87 QStringList
KwFilterManager::loadMimeTypes() const
90 foreach (KwLoadSaveFilter
* filter
, m_loadSaveFilters
)
92 result
+= filter
->importMimeTypes();
97 /// Get save mime types.
98 QStringList
KwFilterManager::saveMimeTypes() const
101 foreach (KwLoadSaveFilter
* filter
, m_loadSaveFilters
)
103 result
+= filter
->exportMimeTypes();
108 /// Get import mime types.
109 QStringList
KwFilterManager::importMimeTypes() const
112 foreach (KwImportFilter
* filter
, m_importFilters
)
114 result
+= filter
->importMimeTypes();
119 /// Get export mime types.
120 QStringList
KwFilterManager::exportMimeTypes() const
123 foreach (KwExportFilter
* filter
, m_exportFilters
)
125 result
+= filter
->exportMimeTypes();