author | zautrix <zautrix> | 2005-02-07 20:05:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-07 20:05:18 (UTC) |
commit | da5e47069d88fa9aa656423ce4c60bf505728e1c (patch) (unidiff) | |
tree | fdbaf29835a028f1204a19fc10dea97d469c0b29 /kabc | |
parent | 456b0246521847635fe98471691ceecae211e0c3 (diff) | |
download | kdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.zip kdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.tar.gz kdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.tar.bz2 |
fixes
-rw-r--r-- | kabc/formatfactory.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/kabc/formatfactory.cpp b/kabc/formatfactory.cpp index f2f03c6..3ae1c27 100644 --- a/kabc/formatfactory.cpp +++ b/kabc/formatfactory.cpp | |||
@@ -11,120 +11,121 @@ | |||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kdebug.h> | 21 | #include <kdebug.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <ksimpleconfig.h> | 23 | #include <ksimpleconfig.h> |
24 | #include <kstandarddirs.h> | 24 | #include <kstandarddirs.h> |
25 | #include <kstaticdeleter.h> | 25 | #include <kstaticdeleter.h> |
26 | 26 | ||
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | 29 | ||
30 | #include "vcardformatplugin.h" | 30 | #include "vcardformatplugin.h" |
31 | 31 | ||
32 | #include "formatfactory.h" | 32 | #include "formatfactory.h" |
33 | 33 | ||
34 | using namespace KABC; | 34 | using namespace KABC; |
35 | 35 | ||
36 | FormatFactory *FormatFactory::mSelf = 0; | 36 | FormatFactory *FormatFactory::mSelf = 0; |
37 | static KStaticDeleter<FormatFactory> factoryDeleter; | 37 | static KStaticDeleter<FormatFactory> factoryDeleter; |
38 | 38 | ||
39 | FormatFactory *FormatFactory::self() | 39 | FormatFactory *FormatFactory::self() |
40 | { | 40 | { |
41 | if ( !mSelf ) { | 41 | if ( !mSelf ) { |
42 | //US factoryDeleter.setObject( mSelf, new FormatFactory ); | 42 | //US factoryDeleter.setObject( mSelf, new FormatFactory ); |
43 | mSelf = factoryDeleter.setObject( new FormatFactory ); | 43 | mSelf = factoryDeleter.setObject( new FormatFactory ); |
44 | } | 44 | } |
45 | return mSelf; | 45 | return mSelf; |
46 | } | 46 | } |
47 | 47 | ||
48 | FormatFactory::FormatFactory() | 48 | FormatFactory::FormatFactory() |
49 | { | 49 | { |
50 | mFormatList.setAutoDelete( true ); | 50 | mFormatList.setAutoDelete( true ); |
51 | 51 | ||
52 | // dummy entry for default format | 52 | // dummy entry for default format |
53 | FormatInfo *info = new FormatInfo; | 53 | FormatInfo *info = new FormatInfo; |
54 | info->library = "<NoLibrary>"; | 54 | info->library = "<NoLibrary>"; |
55 | info->nameLabel = i18n( "vCard" ); | 55 | info->nameLabel = i18n( "vCard" ); |
56 | info->descriptionLabel = i18n( "vCard Format" ); | 56 | info->descriptionLabel = i18n( "vCard Format" ); |
57 | mFormatList.insert( "vcard", info ); | 57 | mFormatList.insert( "vcard", info ); |
58 | 58 | ||
59 | /*US lets enter all resources directly instead of using teh desktopfiles. | 59 | #if 0 |
60 | US lets enter all resources directly instead of using teh desktopfiles. | ||
60 | 61 | ||
61 | QStringList list = KGlobal::dirs()->findAllResources( "data" ,"kabc/formats/*.desktop", true, true ); | 62 | QStringList list = KGlobal::dirs()->findAllResources( "data" ,"kabc/formats/*.desktop", true, true ); |
62 | for ( QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) | 63 | for ( QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) |
63 | { | 64 | { |
64 | //US KSimpleConfig config( *it, true ); | 65 | //US KSimpleConfig config( *it, true ); |
65 | KConfig config( *it ); | 66 | KConfig config( *it ); |
66 | 67 | ||
67 | if ( !config.hasGroup( "Misc" ) || !config.hasGroup( "Plugin" ) ) | 68 | if ( !config.hasGroup( "Misc" ) || !config.hasGroup( "Plugin" ) ) |
68 | continue; | 69 | continue; |
69 | 70 | ||
70 | info = new FormatInfo; | 71 | info = new FormatInfo; |
71 | 72 | ||
72 | config.setGroup( "Plugin" ); | 73 | config.setGroup( "Plugin" ); |
73 | QString type = config.readEntry( "Type" ); | 74 | QString type = config.readEntry( "Type" ); |
74 | info->library = config.readEntry( "X-KDE-Library" ); | 75 | info->library = config.readEntry( "X-KDE-Library" ); |
75 | 76 | ||
76 | config.setGroup( "Misc" ); | 77 | config.setGroup( "Misc" ); |
77 | info->nameLabel = config.readEntry( "Name" ); | 78 | info->nameLabel = config.readEntry( "Name" ); |
78 | info->descriptionLabel = config.readEntry( "Comment", i18n( "No description available." ) ); | 79 | info->descriptionLabel = config.readEntry( "Comment", i18n( "No description available." ) ); |
79 | 80 | ||
80 | mFormatList.insert( type, info ); | 81 | mFormatList.insert( type, info ); |
81 | } | 82 | } |
82 | */ | 83 | #endif |
83 | //US we already have vcard as default format. | 84 | //US we already have vcard as default format. |
84 | info = new FormatInfo; | 85 | info = new FormatInfo; |
85 | info->library = i18n("microkabcformat_binary"); | 86 | info->library = i18n("microkabcformat_binary"); |
86 | info->nameLabel = i18n( "Binary" ); | 87 | info->nameLabel = i18n( "Binary" ); |
87 | info->descriptionLabel = i18n( "No description available." ); | 88 | info->descriptionLabel = i18n( "No description available." ); |
88 | mFormatList.insert( "binary", info ); | 89 | mFormatList.insert( "binary", info ); |
89 | 90 | ||
90 | } | 91 | } |
91 | 92 | ||
92 | FormatFactory::~FormatFactory() | 93 | FormatFactory::~FormatFactory() |
93 | { | 94 | { |
94 | mFormatList.clear(); | 95 | mFormatList.clear(); |
95 | } | 96 | } |
96 | 97 | ||
97 | QStringList FormatFactory::formats() | 98 | QStringList FormatFactory::formats() |
98 | { | 99 | { |
99 | QStringList retval; | 100 | QStringList retval; |
100 | 101 | ||
101 | // make sure 'vcard' is the first entry | 102 | // make sure 'vcard' is the first entry |
102 | retval << "vcard"; | 103 | retval << "vcard"; |
103 | 104 | ||
104 | QDictIterator<FormatInfo> it( mFormatList ); | 105 | QDictIterator<FormatInfo> it( mFormatList ); |
105 | for ( ; it.current(); ++it ) | 106 | for ( ; it.current(); ++it ) |
106 | if ( it.currentKey() != "vcard" ) | 107 | if ( it.currentKey() != "vcard" ) |
107 | retval << it.currentKey(); | 108 | retval << it.currentKey(); |
108 | 109 | ||
109 | return retval; | 110 | return retval; |
110 | } | 111 | } |
111 | 112 | ||
112 | FormatInfo *FormatFactory::info( const QString &type ) | 113 | FormatInfo *FormatFactory::info( const QString &type ) |
113 | { | 114 | { |
114 | if ( type.isEmpty() ) | 115 | if ( type.isEmpty() ) |
115 | return 0; | 116 | return 0; |
116 | else | 117 | else |
117 | return mFormatList[ type ]; | 118 | return mFormatList[ type ]; |
118 | } | 119 | } |
119 | 120 | ||
120 | FormatPlugin *FormatFactory::format( const QString& type ) | 121 | FormatPlugin *FormatFactory::format( const QString& type ) |
121 | { | 122 | { |
122 | FormatPlugin *format = 0; | 123 | FormatPlugin *format = 0; |
123 | 124 | ||
124 | if ( type.isEmpty() ) | 125 | if ( type.isEmpty() ) |
125 | return 0; | 126 | return 0; |
126 | 127 | ||
127 | if ( type == "vcard" ) { | 128 | if ( type == "vcard" ) { |
128 | format = new VCardFormatPlugin; | 129 | format = new VCardFormatPlugin; |
129 | format->setType( type ); | 130 | format->setType( type ); |
130 | format->setNameLabel( i18n( "vCard" ) ); | 131 | format->setNameLabel( i18n( "vCard" ) ); |