console/kabcclient
formatfactory.cpp
Go to the documentation of this file.00001 // 00002 // Copyright (C) 2005 - 2006 Kevin Krammer <kevin.krammer@gmx.at> 00003 // 00004 // This program is free software; you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation; either version 2 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 // 00018 00019 // local includes 00020 #include "formatfactory.h" 00021 #include "csvtemplatefactory.h" 00022 #include "inputformatimpls.h" 00023 #include "outputformatimpls.h" 00024 00026 00027 FormatFactory::FormatFactory() : m_csvtemplateFactory(0) 00028 { 00029 m_inputFormats.append("search"); 00030 m_inputFormats.append("uid"); 00031 m_inputFormats.append("vcard"); 00032 m_inputFormats.append("email"); 00033 m_inputFormats.append("name"); 00034 m_inputFormats.append("csv"); 00035 m_inputFormats.append("dialog"); 00036 00037 m_outputFormats.append("uid"); 00038 m_outputFormats.append("vcard"); 00039 m_outputFormats.append("email"); 00040 m_outputFormats.append("mutt"); 00041 m_outputFormats.append("csv"); 00042 } 00043 00045 00046 FormatFactory::~FormatFactory() 00047 { 00048 delete m_csvtemplateFactory; 00049 } 00050 00052 00053 InputFormat* FormatFactory::inputFormat(const QByteArray& name) 00054 { 00055 if (!m_inputFormats.contains(name)) return 0; 00056 00057 if (name == "search") return new SearchInput(); 00058 00059 if (name == "uid") return new UIDInput(); 00060 00061 if (name == "vcard") return new VCardInput(); 00062 00063 if (name == "email") return new EmailInput(); 00064 00065 if (name == "name") return new NameInput(); 00066 00067 if (name == "csv") 00068 { 00069 if (m_csvtemplateFactory == 0) m_csvtemplateFactory = new CSVTemplateFactory(); 00070 00071 return new CSVInput(m_csvtemplateFactory); 00072 } 00073 00074 if (name == "dialog") return new DialogInput(); 00075 00076 return 0; 00077 } 00078 00080 00081 OutputFormat* FormatFactory::outputFormat(const QByteArray& name) 00082 { 00083 if (!m_outputFormats.contains(name)) return 0; 00084 00085 if (name == "uid") return new UIDOutput(); 00086 00087 if (name == "vcard") return new VCardOutput(); 00088 00089 if (name == "email") return new EmailOutput(); 00090 00091 if (name == "mutt") return new MuttOutput(); 00092 00093 if (name == "csv") 00094 { 00095 if (m_csvtemplateFactory == 0) m_csvtemplateFactory = new CSVTemplateFactory(); 00096 00097 return new CSVOutput(m_csvtemplateFactory); 00098 } 00099 00100 return 0; 00101 } 00102 00103 // End of file
KDE 4.2 API Reference