kbuildimageiofactory.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "ksycoca.h"
00020 #include "ksycocadict.h"
00021 #include "kresourcelist.h"
00022
00023 #include <kglobal.h>
00024 #include <kstandarddirs.h>
00025 #include <kdebug.h>
00026 #include <klocale.h>
00027 #include <assert.h>
00028
00029 #include <kimageiofactory.h>
00030 #include <kbuildimageiofactory.h>
00031
00032 KBuildImageIOFactory::KBuildImageIOFactory() :
00033 KImageIOFactory()
00034 {
00035 m_resourceList = new KSycocaResourceList();
00036 m_resourceList->add( "services", "*.kimgio" );
00037 }
00038
00039
00040
00041 QStringList KBuildImageIOFactory::resourceTypes()
00042 {
00043 return QStringList() << "services";
00044 }
00045
00046 KBuildImageIOFactory::~KBuildImageIOFactory()
00047 {
00048 delete m_resourceList;
00049 }
00050
00051 KSycocaEntry *
00052 KBuildImageIOFactory::createEntry( const QString& file, const char *resource )
00053 {
00054 QString fullPath = locate( resource, file);
00055
00056 KImageIOFormat *format = new KImageIOFormat(fullPath);
00057 return format;
00058 }
00059
00060 void
00061 KBuildImageIOFactory::addEntry(KSycocaEntry *newEntry, const char *resource)
00062 {
00063 KSycocaFactory::addEntry(newEntry, resource);
00064
00065 KImageIOFormat *format = (KImageIOFormat *) newEntry;
00066 rPath += format->rPaths;
00067
00068
00069
00070
00071
00072 for( KImageIOFormatList::ConstIterator it = formatList->begin();
00073 it != formatList->end();
00074 ++it )
00075 {
00076 KImageIOFormat *_format = (*it);
00077 if (format->mType == _format->mType)
00078 {
00079
00080 format = 0;
00081 break;
00082 }
00083 }
00084 if (format)
00085 formatList->append( format );
00086 }
00087
00088
00089 void
00090 KBuildImageIOFactory::saveHeader(QDataStream &str)
00091 {
00092 KSycocaFactory::saveHeader(str);
00093
00094 str << mReadPattern << mWritePattern << rPath;
00095 }
00096
00097 void
00098 KBuildImageIOFactory::save(QDataStream &str)
00099 {
00100 rPath.sort();
00101
00102 QString last;
00103 for(QStringList::Iterator it = rPath.begin();
00104 it != rPath.end(); )
00105 {
00106 QStringList::Iterator it2 = it++;
00107 if (*it2 == last)
00108 {
00109
00110 rPath.remove(it2);
00111 }
00112 else
00113 {
00114 last = *it2;
00115 }
00116 }
00117 mReadPattern = createPattern( KImageIO::Reading );
00118 mWritePattern = createPattern( KImageIO::Writing );
00119
00120 KSycocaFactory::save(str);
00121 }
00122
|