-rw-r--r-- | kabc/vcard/VCardEntity.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/kabprefs.cpp | 1 |
2 files changed, 2 insertions, 3 deletions
diff --git a/kabc/vcard/VCardEntity.cpp b/kabc/vcard/VCardEntity.cpp index 2a9e275..81debf4 100644 --- a/kabc/vcard/VCardEntity.cpp +++ b/kabc/vcard/VCardEntity.cpp | |||
@@ -1,175 +1,175 @@ | |||
1 | /* | 1 | /* |
2 | libvcard - vCard parsing library for vCard version 3.0 | 2 | libvcard - vCard parsing library for vCard version 3.0 |
3 | 3 | ||
4 | Copyright (C) 1998 Rik Hemsley rik@kde.org | 4 | Copyright (C) 1998 Rik Hemsley rik@kde.org |
5 | 5 | ||
6 | Permission is hereby granted, free of charge, to any person obtaining a copy | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | of this software and associated documentation files (the "Software"), to | 7 | of this software and associated documentation files (the "Software"), to |
8 | deal in the Software without restriction, including without limitation the | 8 | deal in the Software without restriction, including without limitation the |
9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | 9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
10 | sell copies of the Software, and to permit persons to whom the Software is | 10 | sell copies of the Software, and to permit persons to whom the Software is |
11 | furnished to do so, subject to the following conditions: | 11 | furnished to do so, subject to the following conditions: |
12 | 12 | ||
13 | The above copyright notice and this permission notice shall be included in | 13 | The above copyright notice and this permission notice shall be included in |
14 | all copies or substantial portions of the Software. | 14 | all copies or substantial portions of the Software. |
15 | 15 | ||
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | 19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | 20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qregexp.h> | 24 | #include <qregexp.h> |
25 | #include <qdatetime.h>; | ||
25 | 26 | ||
26 | #include <VCardDefines.h> | 27 | #include <VCardDefines.h> |
27 | #include <VCardVCardEntity.h> | 28 | #include <VCardVCardEntity.h> |
28 | 29 | ||
29 | using namespace VCARD; | 30 | using namespace VCARD; |
30 | 31 | ||
31 | VCardEntity::VCardEntity() | 32 | VCardEntity::VCardEntity() |
32 | :Entity() | 33 | :Entity() |
33 | { | 34 | { |
34 | cardList_.setAutoDelete( TRUE ); | 35 | cardList_.setAutoDelete( TRUE ); |
35 | } | 36 | } |
36 | 37 | ||
37 | VCardEntity::VCardEntity(const VCardEntity & x) | 38 | VCardEntity::VCardEntity(const VCardEntity & x) |
38 | :Entity(x) | 39 | :Entity(x) |
39 | { | 40 | { |
40 | cardList_.setAutoDelete( TRUE ); | 41 | cardList_.setAutoDelete( TRUE ); |
41 | } | 42 | } |
42 | 43 | ||
43 | VCardEntity::VCardEntity(const QCString & s) | 44 | VCardEntity::VCardEntity(const QCString & s) |
44 | :Entity(s) | 45 | :Entity(s) |
45 | { | 46 | { |
46 | cardList_.setAutoDelete( TRUE ); | 47 | cardList_.setAutoDelete( TRUE ); |
47 | } | 48 | } |
48 | 49 | ||
49 | VCardEntity & | 50 | VCardEntity & |
50 | VCardEntity::operator = (VCardEntity & x) | 51 | VCardEntity::operator = (VCardEntity & x) |
51 | { | 52 | { |
52 | if (*this == x) return *this; | 53 | if (*this == x) return *this; |
53 | 54 | ||
54 | Entity::operator = (x); | 55 | Entity::operator = (x); |
55 | return *this; | 56 | return *this; |
56 | } | 57 | } |
57 | 58 | ||
58 | VCardEntity & | 59 | VCardEntity & |
59 | VCardEntity::operator = (const QCString & s) | 60 | VCardEntity::operator = (const QCString & s) |
60 | { | 61 | { |
61 | Entity::operator = (s); | 62 | Entity::operator = (s); |
62 | return *this; | 63 | return *this; |
63 | } | 64 | } |
64 | 65 | ||
65 | bool | 66 | bool |
66 | VCardEntity::operator == (VCardEntity & x) | 67 | VCardEntity::operator == (VCardEntity & x) |
67 | { | 68 | { |
68 | x.parse(); | 69 | x.parse(); |
69 | return false; | 70 | return false; |
70 | } | 71 | } |
71 | 72 | ||
72 | VCardEntity::~VCardEntity() | 73 | VCardEntity::~VCardEntity() |
73 | { | 74 | { |
74 | } | 75 | } |
75 | 76 | ||
76 | #include <qdatetime.h>; | ||
77 | void | 77 | void |
78 | VCardEntity::_parse() | 78 | VCardEntity::_parse() |
79 | { | 79 | { |
80 | #if 0 | 80 | #if 0 |
81 | QTime tim; | 81 | QTime tim; |
82 | tim.start(); | 82 | tim.start(); |
83 | int num = 0; | 83 | int num = 0; |
84 | // old code | 84 | // old code |
85 | vDebug("parse"); | 85 | vDebug("parse"); |
86 | QCString s(strRep_); | 86 | QCString s(strRep_); |
87 | 87 | ||
88 | int i = s.find(QRegExp("BEGIN:VCARD", false)); | 88 | int i = s.find(QRegExp("BEGIN:VCARD", false)); |
89 | 89 | ||
90 | while (i != -1) { | 90 | while (i != -1) { |
91 | 91 | ||
92 | i = s.find(QRegExp("BEGIN:VCARD", false), 11); | 92 | i = s.find(QRegExp("BEGIN:VCARD", false), 11); |
93 | 93 | ||
94 | QCString cardStr(s.left(i)); | 94 | QCString cardStr(s.left(i)); |
95 | 95 | ||
96 | VCard * v = new VCard(cardStr); | 96 | VCard * v = new VCard(cardStr); |
97 | 97 | ||
98 | cardList_.append(v); | 98 | cardList_.append(v); |
99 | 99 | ||
100 | v->parse(); | 100 | v->parse(); |
101 | 101 | ||
102 | s.remove(0, i); | 102 | s.remove(0, i); |
103 | } | 103 | } |
104 | 104 | ||
105 | #else | 105 | #else |
106 | // this code is up to 17 (!) times faster | 106 | // this code is up to 17 (!) times faster |
107 | int start = 0; | 107 | int start = 0; |
108 | QTime tim; | 108 | QTime tim; |
109 | tim.start(); | 109 | tim.start(); |
110 | int i = 11; | 110 | int i = 11; |
111 | int len = strRep_.length(); | 111 | int len = strRep_.length(); |
112 | int num = 0; | 112 | int num = 0; |
113 | while (i < len ) { | 113 | while (i < len ) { |
114 | while( i < len ) { | 114 | while( i < len ) { |
115 | int add = 1; | 115 | int add = 1; |
116 | if ( strRep_.at(i) == 'B' ) { | 116 | if ( strRep_.at(i) == 'B' ) { |
117 | if ( i+add < len && strRep_.at(i+add++) == 'E') | 117 | if ( i+add < len && strRep_.at(i+add++) == 'E') |
118 | if ( i+add < len && strRep_.at(i+add++) == 'G') | 118 | if ( i+add < len && strRep_.at(i+add++) == 'G') |
119 | if ( i+add < len && strRep_.at(i+add++) == 'I') | 119 | if ( i+add < len && strRep_.at(i+add++) == 'I') |
120 | if ( i+add < len && strRep_.at(i+add++) == 'N') | 120 | if ( i+add < len && strRep_.at(i+add++) == 'N') |
121 | if ( i+add < len && strRep_.at(i+add++) == ':') | 121 | if ( i+add < len && strRep_.at(i+add++) == ':') |
122 | if ( i+add < len && strRep_.at(i+add++) == 'V') | 122 | if ( i+add < len && strRep_.at(i+add++) == 'V') |
123 | if ( i+add < len && strRep_.at(i+add++) == 'C') | 123 | if ( i+add < len && strRep_.at(i+add++) == 'C') |
124 | if ( i+add < len && strRep_.at(i+add++) == 'A') | 124 | if ( i+add < len && strRep_.at(i+add++) == 'A') |
125 | if ( i+add < len && strRep_.at(i+add++) == 'R') | 125 | if ( i+add < len && strRep_.at(i+add++) == 'R') |
126 | if ( i+add < len && strRep_.at(i+add++) == 'D') | 126 | if ( i+add < len && strRep_.at(i+add++) == 'D') |
127 | if ( i+add < len && (strRep_.at(i+add) == '\r' || strRep_.at(i+add) == '\n' )) | 127 | if ( i+add < len && (strRep_.at(i+add) == '\r' || strRep_.at(i+add) == '\n' )) |
128 | break; | 128 | break; |
129 | } | 129 | } |
130 | ++i; | 130 | ++i; |
131 | } | 131 | } |
132 | if ( i <= len ) { | 132 | if ( i <= len ) { |
133 | ++num; | 133 | ++num; |
134 | char* dat = strRep_.data()+start; | 134 | char* dat = strRep_.data()+start; |
135 | VCard * v = new VCard( QCString ( dat,i-start ) ); | 135 | VCard * v = new VCard( QCString ( dat,i-start ) ); |
136 | start = i; | 136 | start = i; |
137 | cardList_.append(v); | 137 | cardList_.append(v); |
138 | v->parse(); | 138 | v->parse(); |
139 | } | 139 | } |
140 | i+= 11; | 140 | i+= 11; |
141 | } | 141 | } |
142 | #endif | 142 | #endif |
143 | qDebug("***time %d found %d", tim.elapsed(), num); | 143 | //qDebug("***time %d found %d", tim.elapsed(), num); |
144 | } | 144 | } |
145 | 145 | ||
146 | void | 146 | void |
147 | VCardEntity::_assemble() | 147 | VCardEntity::_assemble() |
148 | { | 148 | { |
149 | VCardListIterator it(cardList_); | 149 | VCardListIterator it(cardList_); |
150 | 150 | ||
151 | for (; it.current(); ++it) | 151 | for (; it.current(); ++it) |
152 | strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck. | 152 | strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck. |
153 | } | 153 | } |
154 | 154 | ||
155 | VCardList & | 155 | VCardList & |
156 | VCardEntity::cardList() | 156 | VCardEntity::cardList() |
157 | { | 157 | { |
158 | parse(); | 158 | parse(); |
159 | return cardList_; | 159 | return cardList_; |
160 | } | 160 | } |
161 | 161 | ||
162 | void | 162 | void |
163 | VCardEntity::setCardList(const VCardList & l) | 163 | VCardEntity::setCardList(const VCardList & l) |
164 | { | 164 | { |
165 | parse(); | 165 | parse(); |
166 | //UScardList_ = l; | 166 | //UScardList_ = l; |
167 | VCardListIterator it(l); | 167 | VCardListIterator it(l); |
168 | 168 | ||
169 | for (; it.current(); ++it) { | 169 | for (; it.current(); ++it) { |
170 | VCard* v = new VCard(*it.current()); | 170 | VCard* v = new VCard(*it.current()); |
171 | cardList_.append(v); | 171 | cardList_.append(v); |
172 | } | 172 | } |
173 | 173 | ||
174 | } | 174 | } |
175 | 175 | ||
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp index 4b3ee47..79fff47 100644 --- a/kaddressbook/kabprefs.cpp +++ b/kaddressbook/kabprefs.cpp | |||
@@ -1,209 +1,208 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 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 | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
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 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | //US#ifdef KAB_EMBEDDED | 24 | //US#ifdef KAB_EMBEDDED |
25 | //#include <qstring.h> | 25 | //#include <qstring.h> |
26 | //#endif //KAB_EMBEDDED | 26 | //#endif //KAB_EMBEDDED |
27 | 27 | ||
28 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | #include <libkdepim/kpimglobalprefs.h> | 31 | #include <libkdepim/kpimglobalprefs.h> |
32 | 32 | ||
33 | #include <kconfig.h> | 33 | #include <kconfig.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kstaticdeleter.h> | 35 | #include <kstaticdeleter.h> |
36 | //US#include <kdebug.h> // defines kdDebug() | 36 | //US#include <kdebug.h> // defines kdDebug() |
37 | 37 | ||
38 | #include "kabprefs.h" | 38 | #include "kabprefs.h" |
39 | 39 | ||
40 | KABPrefs *KABPrefs::sInstance = 0; | 40 | KABPrefs *KABPrefs::sInstance = 0; |
41 | static KStaticDeleter<KABPrefs> staticDeleter; | 41 | static KStaticDeleter<KABPrefs> staticDeleter; |
42 | 42 | ||
43 | KABPrefs::KABPrefs() | 43 | KABPrefs::KABPrefs() |
44 | : KPimPrefs("kaddressbookrc") | 44 | : KPimPrefs("kaddressbookrc") |
45 | { | 45 | { |
46 | 46 | ||
47 | mLocaleDict = 0; | 47 | mLocaleDict = 0; |
48 | mDetailsFont = QFont("helvetica",12); | 48 | mDetailsFont = QFont("helvetica",12); |
49 | KPrefs::setCurrentGroup( "Views" ); | 49 | KPrefs::setCurrentGroup( "Views" ); |
50 | addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); | 50 | addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); |
51 | 51 | ||
52 | KPrefs::setCurrentGroup( "General" ); | 52 | KPrefs::setCurrentGroup( "General" ); |
53 | addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); | 53 | addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); |
54 | addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); | 54 | addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); |
55 | 55 | ||
56 | #ifdef KAB_EMBEDDED | 56 | #ifdef KAB_EMBEDDED |
57 | addItemBool("AskForQuit",&mAskForQuit,true); | 57 | addItemBool("AskForQuit",&mAskForQuit,true); |
58 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 58 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
59 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 59 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
60 | addItemBool("SearchWithReturn",&mSearchWithReturn, true ); | 60 | addItemBool("SearchWithReturn",&mSearchWithReturn, true ); |
61 | addItemFont("DetailsFont",&mDetailsFont); | 61 | addItemFont("DetailsFont",&mDetailsFont); |
62 | 62 | ||
63 | 63 | ||
64 | #endif //KAB_EMBEDDED | 64 | #endif //KAB_EMBEDDED |
65 | 65 | ||
66 | KPrefs::setCurrentGroup( "MainWindow" ); | 66 | KPrefs::setCurrentGroup( "MainWindow" ); |
67 | addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); | 67 | addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); |
68 | addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); | 68 | addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); |
69 | addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); | 69 | addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); |
70 | addItemIntList( "DetailsSplitter", &mDetailsSplitter ); | 70 | addItemIntList( "DetailsSplitter", &mDetailsSplitter ); |
71 | addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); | 71 | addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); |
72 | 72 | ||
73 | 73 | ||
74 | KPrefs::setCurrentGroup( "Extensions_General" ); | 74 | KPrefs::setCurrentGroup( "Extensions_General" ); |
75 | QStringList defaultExtensions; | 75 | QStringList defaultExtensions; |
76 | defaultExtensions << "merge"; | 76 | defaultExtensions << "merge"; |
77 | defaultExtensions << "distribution_list_editor"; | 77 | defaultExtensions << "distribution_list_editor"; |
78 | addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); | 78 | addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); |
79 | addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); | 79 | addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); |
80 | 80 | ||
81 | KPrefs::setCurrentGroup( "Views" ); | 81 | KPrefs::setCurrentGroup( "Views" ); |
82 | QString defaultView = i18n( "Default Table View" ); | 82 | QString defaultView = i18n( "Default Table View" ); |
83 | addItemString( "CurrentView", &mCurrentView, defaultView ); | 83 | addItemString( "CurrentView", &mCurrentView, defaultView ); |
84 | addItemStringList( "ViewNames", &mViewNames, defaultView ); | 84 | addItemStringList( "ViewNames", &mViewNames, defaultView ); |
85 | 85 | ||
86 | KPrefs::setCurrentGroup( "Filters" ); | 86 | KPrefs::setCurrentGroup( "Filters" ); |
87 | addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); | 87 | addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); |
88 | 88 | ||
89 | } | 89 | } |
90 | 90 | ||
91 | KABPrefs::~KABPrefs() | 91 | KABPrefs::~KABPrefs() |
92 | { | 92 | { |
93 | //qDebug("KABPrefs::~KABPrefs() "); | 93 | //qDebug("KABPrefs::~KABPrefs() "); |
94 | setLocaleDict( 0 ); | 94 | setLocaleDict( 0 ); |
95 | if ( mLocaleDict ) | 95 | if ( mLocaleDict ) |
96 | delete mLocaleDict; | 96 | delete mLocaleDict; |
97 | } | 97 | } |
98 | 98 | ||
99 | KABPrefs *KABPrefs::instance() | 99 | KABPrefs *KABPrefs::instance() |
100 | { | 100 | { |
101 | if ( !sInstance ) { | 101 | if ( !sInstance ) { |
102 | #ifdef KAB_EMBEDDED | 102 | #ifdef KAB_EMBEDDED |
103 | sInstance = staticDeleter.setObject( new KABPrefs() ); | 103 | sInstance = staticDeleter.setObject( new KABPrefs() ); |
104 | #else //KAB_EMBEDDED | 104 | #else //KAB_EMBEDDED |
105 | //US the following line has changed ???. Why | 105 | //US the following line has changed ???. Why |
106 | staticDeleter.setObject( sInstance, new KABPrefs() ); | 106 | staticDeleter.setObject( sInstance, new KABPrefs() ); |
107 | #endif //KAB_EMBEDDED | 107 | #endif //KAB_EMBEDDED |
108 | sInstance->readConfig(); | 108 | sInstance->readConfig(); |
109 | } | 109 | } |
110 | 110 | ||
111 | return sInstance; | 111 | return sInstance; |
112 | } | 112 | } |
113 | 113 | ||
114 | void KABPrefs::setCategoryDefaults() | 114 | void KABPrefs::setCategoryDefaults() |
115 | { | 115 | { |
116 | mCustomCategories.clear(); | 116 | mCustomCategories.clear(); |
117 | 117 | ||
118 | mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) | 118 | mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) |
119 | << i18n( "Customer" ) << i18n( "Friend" ); | 119 | << i18n( "Customer" ) << i18n( "Friend" ); |
120 | } | 120 | } |
121 | 121 | ||
122 | // US introduce a nonconst way to return the config object. | 122 | // US introduce a nonconst way to return the config object. |
123 | KConfig* KABPrefs::getConfig() | 123 | KConfig* KABPrefs::getConfig() |
124 | { | 124 | { |
125 | return config(); | 125 | return config(); |
126 | } | 126 | } |
127 | void KABPrefs::usrReadConfig() | 127 | void KABPrefs::usrReadConfig() |
128 | { | 128 | { |
129 | QString fileName ; | 129 | QString fileName ; |
130 | #ifndef DESKTOP_VERSION | 130 | #ifndef DESKTOP_VERSION |
131 | fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/"; | 131 | fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/"; |
132 | #else | 132 | #else |
133 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/"; | 133 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/"; |
134 | #endif | 134 | #endif |
135 | int mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | 135 | int mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; |
136 | mLocaleDict = 0; | 136 | mLocaleDict = 0; |
137 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { | 137 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { |
138 | 138 | ||
139 | if ( mPreferredLanguage == 1 ) | 139 | if ( mPreferredLanguage == 1 ) |
140 | fileName = fileName+"germantranslation.txt"; | 140 | fileName = fileName+"germantranslation.txt"; |
141 | else if ( mPreferredLanguage == 4 ) | 141 | else if ( mPreferredLanguage == 4 ) |
142 | fileName = fileName+"usertranslation.txt"; | 142 | fileName = fileName+"usertranslation.txt"; |
143 | else if ( mPreferredLanguage == 2 ) | 143 | else if ( mPreferredLanguage == 2 ) |
144 | fileName = fileName+"frenchtranslation.txt"; | 144 | fileName = fileName+"frenchtranslation.txt"; |
145 | else if ( mPreferredLanguage == 3 ) | 145 | else if ( mPreferredLanguage == 3 ) |
146 | fileName = fileName+"italiantranslation.txt"; | 146 | fileName = fileName+"italiantranslation.txt"; |
147 | QFile file( fileName ); | 147 | QFile file( fileName ); |
148 | if (file.open( IO_ReadOnly ) ) { | 148 | if (file.open( IO_ReadOnly ) ) { |
149 | QTextStream ts( &file ); | 149 | QTextStream ts( &file ); |
150 | ts.setEncoding( QTextStream::Latin1 ); | 150 | ts.setEncoding( QTextStream::Latin1 ); |
151 | //ts.setCodec( QTextCodec::latin1 ); | 151 | //ts.setCodec( QTextCodec::latin1 ); |
152 | QString text = ts.read(); | 152 | QString text = ts.read(); |
153 | file.close(); | 153 | file.close(); |
154 | text.replace( QRegExp("\\\\n"), "\n" ); | 154 | text.replace( QRegExp("\\\\n"), "\n" ); |
155 | QString line; | 155 | QString line; |
156 | QString we; | 156 | QString we; |
157 | QString wt; | 157 | QString wt; |
158 | int br = 0; | 158 | int br = 0; |
159 | int nbr; | 159 | int nbr; |
160 | nbr = text.find ( "},", br ); | 160 | nbr = text.find ( "},", br ); |
161 | line = text.mid( br, nbr - br ); | 161 | line = text.mid( br, nbr - br ); |
162 | br = nbr+1; | 162 | br = nbr+1; |
163 | int se, ee, st, et; | 163 | int se, ee, st, et; |
164 | mLocaleDict = new QDict<QString>; | 164 | mLocaleDict = new QDict<QString>; |
165 | QString end = "{ \"\",\"\" }"; | 165 | QString end = "{ \"\",\"\" }"; |
166 | while ( (line != end) && (br > 1) ) { | 166 | while ( (line != end) && (br > 1) ) { |
167 | //qDebug("%d *%s* ", br, line.latin1()); | 167 | //qDebug("%d *%s* ", br, line.latin1()); |
168 | se = line.find("\"")+1; | 168 | se = line.find("\"")+1; |
169 | et = line.findRev("\"",-1); | 169 | et = line.findRev("\"",-1); |
170 | ee = line.find("\",\""); | 170 | ee = line.find("\",\""); |
171 | st = ee+3; | 171 | st = ee+3; |
172 | we = line.mid( se, ee-se ); | 172 | we = line.mid( se, ee-se ); |
173 | wt = line.mid( st, et-st ); | 173 | wt = line.mid( st, et-st ); |
174 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); | 174 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); |
175 | mLocaleDict->insert( we, new QString (wt) ); | 175 | mLocaleDict->insert( we, new QString (wt) ); |
176 | nbr = text.find ( "}", br ); | 176 | nbr = text.find ( "}", br ); |
177 | line = text.mid( br, nbr - br ); | 177 | line = text.mid( br, nbr - br ); |
178 | br = nbr+1; | 178 | br = nbr+1; |
179 | } | 179 | } |
180 | //qDebug("end *%s* ", end.latin1()); | 180 | //qDebug("end *%s* ", end.latin1()); |
181 | 181 | ||
182 | setLocaleDict( mLocaleDict ); | 182 | setLocaleDict( mLocaleDict ); |
183 | } else { | 183 | } else { |
184 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); | 184 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); |
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||
188 | } | 188 | } |
189 | qDebug("KABPrefs::usrReadConfig********************** "); | ||
190 | KPimPrefs::usrReadConfig(); | 189 | KPimPrefs::usrReadConfig(); |
191 | } | 190 | } |
192 | 191 | ||
193 | 192 | ||
194 | /*US | 193 | /*US |
195 | void KABPrefs::usrSetDefaults() | 194 | void KABPrefs::usrSetDefaults() |
196 | { | 195 | { |
197 | KPimPrefs::usrSetDefaults(); | 196 | KPimPrefs::usrSetDefaults(); |
198 | } | 197 | } |
199 | 198 | ||
200 | void KABPrefs::usrReadConfig() | 199 | void KABPrefs::usrReadConfig() |
201 | { | 200 | { |
202 | KPimPrefs::usrReadConfig(); | 201 | KPimPrefs::usrReadConfig(); |
203 | } | 202 | } |
204 | 203 | ||
205 | void KABPrefs::usrWriteConfig() | 204 | void KABPrefs::usrWriteConfig() |
206 | { | 205 | { |
207 | KPimPrefs::usrWriteConfig(); | 206 | KPimPrefs::usrWriteConfig(); |
208 | } | 207 | } |
209 | */ | 208 | */ |