Diffstat (limited to 'core/pim/addressbook/abconfig.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/abconfig.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/core/pim/addressbook/abconfig.cpp b/core/pim/addressbook/abconfig.cpp index a3fd222..2583327 100644 --- a/core/pim/addressbook/abconfig.cpp +++ b/core/pim/addressbook/abconfig.cpp | |||
@@ -1,92 +1,97 @@ | |||
1 | #include "abconfig.h" | 1 | #include "abconfig.h" |
2 | #include "version.h" | 2 | #include "version.h" |
3 | 3 | ||
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | #include <qpe/recordfields.h> | 5 | #include <qpe/recordfields.h> |
6 | 6 | ||
7 | AbConfig::AbConfig( ): | 7 | AbConfig::AbConfig( ): |
8 | m_useQtMail( true ), | 8 | m_useQtMail( true ), |
9 | m_useOpieMail( false ), | 9 | m_useOpieMail( false ), |
10 | m_useRegExp( false ), | 10 | m_useRegExp( false ), |
11 | m_beCaseSensitive( false ), | 11 | m_beCaseSensitive( false ), |
12 | m_fontSize( 1 ), | 12 | m_fontSize( 1 ), |
13 | m_barPos( QMainWindow::Top ), | 13 | m_barPos( QMainWindow::Top ), |
14 | m_fixedBars( true ), | 14 | m_fixedBars( true ), |
15 | m_lpSearchMode( LastName ), | 15 | m_lpSearchMode( LastName ), |
16 | m_changed( false ) | 16 | m_changed( false ) |
17 | { | 17 | { |
18 | } | 18 | } |
19 | 19 | ||
20 | AbConfig::~AbConfig() | 20 | AbConfig::~AbConfig() |
21 | { | 21 | { |
22 | } | 22 | } |
23 | 23 | ||
24 | bool AbConfig::useRegExp() const | 24 | bool AbConfig::useRegExp() const |
25 | { | 25 | { |
26 | return m_useRegExp; | 26 | return m_useRegExp; |
27 | } | 27 | } |
28 | bool AbConfig::useWildCards() const | 28 | bool AbConfig::useWildCards() const |
29 | { | 29 | { |
30 | return !m_useRegExp; | 30 | return !m_useRegExp; |
31 | } | 31 | } |
32 | bool AbConfig::useQtMail() const | 32 | bool AbConfig::useQtMail() const |
33 | { | 33 | { |
34 | return m_useQtMail; | 34 | return m_useQtMail; |
35 | } | 35 | } |
36 | bool AbConfig::useOpieMail() const | 36 | bool AbConfig::useOpieMail() const |
37 | { | 37 | { |
38 | return m_useOpieMail; | 38 | return m_useOpieMail; |
39 | } | 39 | } |
40 | bool AbConfig::beCaseSensitive() const | 40 | bool AbConfig::beCaseSensitive() const |
41 | { | 41 | { |
42 | return m_beCaseSensitive; | 42 | return m_beCaseSensitive; |
43 | } | 43 | } |
44 | int AbConfig::fontSize() const | 44 | int AbConfig::fontSize() const |
45 | { | 45 | { |
46 | return m_fontSize; | 46 | return m_fontSize; |
47 | } | 47 | } |
48 | 48 | ||
49 | QValueList<int> AbConfig::orderList() const | 49 | QValueList<int> AbConfig::orderList() const |
50 | { | 50 | { |
51 | return m_ordered; | 51 | return m_ordered; |
52 | } | 52 | } |
53 | 53 | ||
54 | QMainWindow::ToolBarDock AbConfig::getToolBarPos() const | 54 | QMainWindow::ToolBarDock AbConfig::getToolBarPos() const |
55 | { | 55 | { |
56 | return (QMainWindow::ToolBarDock) m_barPos; | 56 | return (QMainWindow::ToolBarDock) m_barPos; |
57 | } | 57 | } |
58 | 58 | ||
59 | bool AbConfig::fixedBars() const | 59 | bool AbConfig::fixedBars() const |
60 | { | 60 | { |
61 | return m_fixedBars; | 61 | return m_fixedBars; |
62 | } | 62 | } |
63 | 63 | ||
64 | AbConfig::LPSearchMode AbConfig::letterPickerSearch() const | 64 | AbConfig::LPSearchMode AbConfig::letterPickerSearch() const |
65 | { | 65 | { |
66 | return ( AbConfig::LPSearchMode ) m_lpSearchMode; | 66 | return ( AbConfig::LPSearchMode ) m_lpSearchMode; |
67 | } | 67 | } |
68 | 68 | ||
69 | const QString &AbConfig::category() const | ||
70 | { | ||
71 | return m_category; | ||
72 | } | ||
73 | |||
69 | void AbConfig::setUseRegExp( bool v ) | 74 | void AbConfig::setUseRegExp( bool v ) |
70 | { | 75 | { |
71 | m_useRegExp = v ; | 76 | m_useRegExp = v ; |
72 | m_changed = true; | 77 | m_changed = true; |
73 | } | 78 | } |
74 | void AbConfig::setUseWildCards( bool v ) | 79 | void AbConfig::setUseWildCards( bool v ) |
75 | { | 80 | { |
76 | m_useRegExp = !v; | 81 | m_useRegExp = !v; |
77 | m_changed = true; | 82 | m_changed = true; |
78 | } | 83 | } |
79 | void AbConfig::setBeCaseSensitive( bool v ) | 84 | void AbConfig::setBeCaseSensitive( bool v ) |
80 | { | 85 | { |
81 | m_beCaseSensitive = v; | 86 | m_beCaseSensitive = v; |
82 | m_changed = true; | 87 | m_changed = true; |
83 | } | 88 | } |
84 | void AbConfig::setUseQtMail( bool v ) | 89 | void AbConfig::setUseQtMail( bool v ) |
85 | { | 90 | { |
86 | m_useQtMail = v; | 91 | m_useQtMail = v; |
87 | m_changed = true; | 92 | m_changed = true; |
88 | } | 93 | } |
89 | void AbConfig::setUseOpieMail( bool v ) | 94 | void AbConfig::setUseOpieMail( bool v ) |
90 | { | 95 | { |
91 | m_useOpieMail = v; | 96 | m_useOpieMail = v; |
92 | m_changed = true; | 97 | m_changed = true; |
@@ -100,114 +105,125 @@ void AbConfig::setFontSize( int v ) | |||
100 | void AbConfig::setOrderList( const QValueList<int>& list ) | 105 | void AbConfig::setOrderList( const QValueList<int>& list ) |
101 | { | 106 | { |
102 | m_ordered = list; | 107 | m_ordered = list; |
103 | m_changed = true; | 108 | m_changed = true; |
104 | } | 109 | } |
105 | 110 | ||
106 | void AbConfig::setToolBarDock( const QMainWindow::ToolBarDock v ) | 111 | void AbConfig::setToolBarDock( const QMainWindow::ToolBarDock v ) |
107 | { | 112 | { |
108 | m_barPos = v; | 113 | m_barPos = v; |
109 | m_changed = true; | 114 | m_changed = true; |
110 | } | 115 | } |
111 | 116 | ||
112 | void AbConfig::setFixedBars( const bool fixed ) | 117 | void AbConfig::setFixedBars( const bool fixed ) |
113 | { | 118 | { |
114 | m_fixedBars = fixed; | 119 | m_fixedBars = fixed; |
115 | m_changed = true; | 120 | m_changed = true; |
116 | } | 121 | } |
117 | 122 | ||
118 | void AbConfig::setLetterPickerSearch( const AbConfig::LPSearchMode mode ) | 123 | void AbConfig::setLetterPickerSearch( const AbConfig::LPSearchMode mode ) |
119 | { | 124 | { |
120 | m_lpSearchMode = mode; | 125 | m_lpSearchMode = mode; |
121 | m_changed = true; | 126 | m_changed = true; |
122 | } | 127 | } |
123 | 128 | ||
129 | void AbConfig::setCategory( const QString &cat ) | ||
130 | { | ||
131 | m_category = cat; | ||
132 | } | ||
133 | |||
124 | void AbConfig::load() | 134 | void AbConfig::load() |
125 | { | 135 | { |
126 | // Read Config settings | 136 | // Read Config settings |
127 | Config cfg("AddressBook"); | 137 | Config cfg("AddressBook"); |
128 | 138 | ||
139 | cfg.setGroup( "View" ); | ||
140 | m_category = cfg.readEntry( "Category", "All" ); | ||
141 | |||
129 | cfg.setGroup("Font"); | 142 | cfg.setGroup("Font"); |
130 | m_fontSize = cfg.readNumEntry( "fontSize", 1 ); | 143 | m_fontSize = cfg.readNumEntry( "fontSize", 1 ); |
131 | 144 | ||
132 | cfg.setGroup("Search"); | 145 | cfg.setGroup("Search"); |
133 | m_useRegExp = cfg.readBoolEntry( "useRegExp", false ); | 146 | m_useRegExp = cfg.readBoolEntry( "useRegExp", false ); |
134 | m_beCaseSensitive = cfg.readBoolEntry( "caseSensitive", false ); | 147 | m_beCaseSensitive = cfg.readBoolEntry( "caseSensitive", false ); |
135 | m_lpSearchMode = cfg.readNumEntry( "lpSearchMode", FileAs ); | 148 | m_lpSearchMode = cfg.readNumEntry( "lpSearchMode", FileAs ); |
136 | 149 | ||
137 | cfg.setGroup("Mail"); | 150 | cfg.setGroup("Mail"); |
138 | m_useQtMail = cfg.readBoolEntry( "useQtMail", true ); | 151 | m_useQtMail = cfg.readBoolEntry( "useQtMail", true ); |
139 | m_useOpieMail=cfg.readBoolEntry( "useOpieMail" ); | 152 | m_useOpieMail=cfg.readBoolEntry( "useOpieMail" ); |
140 | 153 | ||
141 | cfg.setGroup("ContactOrder"); | 154 | cfg.setGroup("ContactOrder"); |
142 | int ID = 0; | 155 | int ID = 0; |
143 | int i = 0; | 156 | int i = 0; |
144 | ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 ); | 157 | ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 ); |
145 | while ( ID != 0 ){ | 158 | while ( ID != 0 ){ |
146 | m_ordered.append( ID ); | 159 | m_ordered.append( ID ); |
147 | ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 ); | 160 | ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 ); |
148 | } | 161 | } |
149 | 162 | ||
150 | // If no contact order is defined, we set the default | 163 | // If no contact order is defined, we set the default |
151 | if ( m_ordered.count() == 0 ) { | 164 | if ( m_ordered.count() == 0 ) { |
152 | m_ordered.append( Qtopia::DefaultEmail ); | 165 | m_ordered.append( Qtopia::DefaultEmail ); |
153 | m_ordered.append( Qtopia::HomePhone); | 166 | m_ordered.append( Qtopia::HomePhone); |
154 | m_ordered.append( Qtopia::HomeMobile); | 167 | m_ordered.append( Qtopia::HomeMobile); |
155 | m_ordered.append( Qtopia::BusinessPhone); | 168 | m_ordered.append( Qtopia::BusinessPhone); |
156 | } | 169 | } |
157 | 170 | ||
158 | cfg.setGroup("ToolBar"); | 171 | cfg.setGroup("ToolBar"); |
159 | m_barPos = cfg.readNumEntry( "Position", QMainWindow::Top ); | 172 | m_barPos = cfg.readNumEntry( "Position", QMainWindow::Top ); |
160 | m_fixedBars= cfg.readBoolEntry( "fixedBars", true ); | 173 | m_fixedBars= cfg.readBoolEntry( "fixedBars", true ); |
161 | 174 | ||
162 | m_changed = false; | 175 | m_changed = false; |
163 | } | 176 | } |
164 | 177 | ||
165 | void AbConfig::save() | 178 | void AbConfig::save() |
166 | { | 179 | { |
167 | if ( m_changed ){ | 180 | if ( m_changed ){ |
168 | Config cfg("AddressBook"); | 181 | Config cfg("AddressBook"); |
182 | cfg.setGroup( "View" ); | ||
183 | cfg.writeEntry( "Category", m_category ); | ||
184 | |||
169 | cfg.setGroup("Font"); | 185 | cfg.setGroup("Font"); |
170 | cfg.writeEntry("fontSize", m_fontSize); | 186 | cfg.writeEntry("fontSize", m_fontSize); |
171 | 187 | ||
172 | cfg.setGroup("Search"); | 188 | cfg.setGroup("Search"); |
173 | cfg.writeEntry("useRegExp", m_useRegExp); | 189 | cfg.writeEntry("useRegExp", m_useRegExp); |
174 | cfg.writeEntry("caseSensitive", m_beCaseSensitive); | 190 | cfg.writeEntry("caseSensitive", m_beCaseSensitive); |
175 | cfg.writeEntry("lpSearchMode", m_lpSearchMode ); | 191 | cfg.writeEntry("lpSearchMode", m_lpSearchMode ); |
176 | 192 | ||
177 | cfg.setGroup("Mail"); | 193 | cfg.setGroup("Mail"); |
178 | cfg.writeEntry( "useQtMail", m_useQtMail ); | 194 | cfg.writeEntry( "useQtMail", m_useQtMail ); |
179 | cfg.writeEntry( "useOpieMail", m_useOpieMail); | 195 | cfg.writeEntry( "useOpieMail", m_useOpieMail); |
180 | 196 | ||
181 | cfg.setGroup("ContactOrder"); | 197 | cfg.setGroup("ContactOrder"); |
182 | cfg.clearGroup(); | 198 | cfg.clearGroup(); |
183 | for ( uint i = 0; i < m_ordered.count(); i++ ){ | 199 | for ( uint i = 0; i < m_ordered.count(); i++ ){ |
184 | cfg.writeEntry( "ContactID_"+QString::number(i), m_ordered[i] ); | 200 | cfg.writeEntry( "ContactID_"+QString::number(i), m_ordered[i] ); |
185 | } | 201 | } |
186 | 202 | ||
187 | cfg.setGroup("ToolBar"); | 203 | cfg.setGroup("ToolBar"); |
188 | cfg.writeEntry( "Position", m_barPos ); | 204 | cfg.writeEntry( "Position", m_barPos ); |
189 | cfg.writeEntry( "fixedBars", m_fixedBars ); | 205 | cfg.writeEntry( "fixedBars", m_fixedBars ); |
190 | 206 | ||
191 | cfg.setGroup("Version"); | 207 | cfg.setGroup("Version"); |
192 | cfg.writeEntry( "AppName", APPNAME + QString(" V" ) + MAINVERSION + QString(".") + SUBVERSION + QString(".") + PATCHVERSION); | 208 | cfg.writeEntry( "AppName", APPNAME + QString(" V" ) + MAINVERSION + QString(".") + SUBVERSION + QString(".") + PATCHVERSION); |
193 | cfg.writeEntry( "Mainversion", MAINVERSION ); | 209 | cfg.writeEntry( "Mainversion", MAINVERSION ); |
194 | cfg.writeEntry( "SubVersion", SUBVERSION ); | 210 | cfg.writeEntry( "SubVersion", SUBVERSION ); |
195 | cfg.writeEntry( "PatchVersion", PATCHVERSION ); | 211 | cfg.writeEntry( "PatchVersion", PATCHVERSION ); |
196 | 212 | ||
197 | } | 213 | } |
198 | 214 | ||
199 | } | 215 | } |
200 | 216 | ||
201 | void AbConfig::operator= ( const AbConfig& cnf ) | 217 | void AbConfig::operator= ( const AbConfig& cnf ) |
202 | { | 218 | { |
203 | m_useQtMail = cnf.m_useQtMail; | 219 | m_useQtMail = cnf.m_useQtMail; |
204 | m_useOpieMail = cnf.m_useOpieMail; | 220 | m_useOpieMail = cnf.m_useOpieMail; |
205 | m_useRegExp = cnf.m_useRegExp; | 221 | m_useRegExp = cnf.m_useRegExp; |
206 | m_beCaseSensitive = cnf.m_beCaseSensitive; | 222 | m_beCaseSensitive = cnf.m_beCaseSensitive; |
207 | m_fontSize = cnf.m_fontSize; | 223 | m_fontSize = cnf.m_fontSize; |
208 | m_ordered = cnf.m_ordered; | 224 | m_ordered = cnf.m_ordered; |
209 | m_barPos = cnf.m_barPos; | 225 | m_barPos = cnf.m_barPos; |
210 | m_fixedBars = cnf.m_fixedBars; | 226 | m_fixedBars = cnf.m_fixedBars; |
211 | m_lpSearchMode = cnf.m_lpSearchMode; | 227 | m_lpSearchMode = cnf.m_lpSearchMode; |
212 | } | 228 | } |
213 | 229 | ||