author | eilers <eilers> | 2003-05-11 12:53:01 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-05-11 12:53:01 (UTC) |
commit | c24cd890fe8219dcfc740c2e234d2427965d5831 (patch) (unidiff) | |
tree | 826600681c77e14a11e36d5c96e3baa50567aa3f | |
parent | 597215b1c9e92df95ace33306d93b6c20df8b8c7 (diff) | |
download | opie-c24cd890fe8219dcfc740c2e234d2427965d5831.zip opie-c24cd890fe8219dcfc740c2e234d2427965d5831.tar.gz opie-c24cd890fe8219dcfc740c2e234d2427965d5831.tar.bz2 |
Just internal renaming.. Will not affect anything..
-rw-r--r-- | core/pim/addressbook/abconfig.cpp | 2 | ||||
-rw-r--r-- | core/pim/addressbook/abconfig.h | 2 | ||||
-rw-r--r-- | core/pim/addressbook/abview.cpp | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/core/pim/addressbook/abconfig.cpp b/core/pim/addressbook/abconfig.cpp index 4a0875b..a3fd222 100644 --- a/core/pim/addressbook/abconfig.cpp +++ b/core/pim/addressbook/abconfig.cpp | |||
@@ -1,213 +1,213 @@ | |||
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 | void AbConfig::setUseRegExp( bool v ) | 69 | void AbConfig::setUseRegExp( bool v ) |
70 | { | 70 | { |
71 | m_useRegExp = v ; | 71 | m_useRegExp = v ; |
72 | m_changed = true; | 72 | m_changed = true; |
73 | } | 73 | } |
74 | void AbConfig::setUseWildCards( bool v ) | 74 | void AbConfig::setUseWildCards( bool v ) |
75 | { | 75 | { |
76 | m_useRegExp = !v; | 76 | m_useRegExp = !v; |
77 | m_changed = true; | 77 | m_changed = true; |
78 | } | 78 | } |
79 | void AbConfig::setBeCaseSensitive( bool v ) | 79 | void AbConfig::setBeCaseSensitive( bool v ) |
80 | { | 80 | { |
81 | m_beCaseSensitive = v; | 81 | m_beCaseSensitive = v; |
82 | m_changed = true; | 82 | m_changed = true; |
83 | } | 83 | } |
84 | void AbConfig::setUseQtMail( bool v ) | 84 | void AbConfig::setUseQtMail( bool v ) |
85 | { | 85 | { |
86 | m_useQtMail = v; | 86 | m_useQtMail = v; |
87 | m_changed = true; | 87 | m_changed = true; |
88 | } | 88 | } |
89 | void AbConfig::setUseOpieMail( bool v ) | 89 | void AbConfig::setUseOpieMail( bool v ) |
90 | { | 90 | { |
91 | m_useOpieMail = v; | 91 | m_useOpieMail = v; |
92 | m_changed = true; | 92 | m_changed = true; |
93 | } | 93 | } |
94 | void AbConfig::setFontSize( int v ) | 94 | void AbConfig::setFontSize( int v ) |
95 | { | 95 | { |
96 | m_fontSize = v; | 96 | m_fontSize = v; |
97 | m_changed = true; | 97 | m_changed = true; |
98 | } | 98 | } |
99 | 99 | ||
100 | void AbConfig::setOrderList( const QValueList<int>& list ) | 100 | void AbConfig::setOrderList( const QValueList<int>& list ) |
101 | { | 101 | { |
102 | m_ordered = list; | 102 | m_ordered = list; |
103 | m_changed = true; | 103 | m_changed = true; |
104 | } | 104 | } |
105 | 105 | ||
106 | void AbConfig::setToolBarDock( const QMainWindow::ToolBarDock v ) | 106 | void AbConfig::setToolBarDock( const QMainWindow::ToolBarDock v ) |
107 | { | 107 | { |
108 | m_barPos = v; | 108 | m_barPos = v; |
109 | m_changed = true; | 109 | m_changed = true; |
110 | } | 110 | } |
111 | 111 | ||
112 | void AbConfig::setFixedBars( const bool fixed ) | 112 | void AbConfig::setFixedBars( const bool fixed ) |
113 | { | 113 | { |
114 | m_fixedBars = fixed; | 114 | m_fixedBars = fixed; |
115 | m_changed = true; | 115 | m_changed = true; |
116 | } | 116 | } |
117 | 117 | ||
118 | void AbConfig::setLetterPickerSearch( const AbConfig::LPSearchMode mode ) | 118 | void AbConfig::setLetterPickerSearch( const AbConfig::LPSearchMode mode ) |
119 | { | 119 | { |
120 | m_lpSearchMode = mode; | 120 | m_lpSearchMode = mode; |
121 | m_changed = true; | 121 | m_changed = true; |
122 | } | 122 | } |
123 | 123 | ||
124 | void AbConfig::load() | 124 | void AbConfig::load() |
125 | { | 125 | { |
126 | // Read Config settings | 126 | // Read Config settings |
127 | Config cfg("AddressBook"); | 127 | Config cfg("AddressBook"); |
128 | 128 | ||
129 | cfg.setGroup("Font"); | 129 | cfg.setGroup("Font"); |
130 | m_fontSize = cfg.readNumEntry( "fontSize", 1 ); | 130 | m_fontSize = cfg.readNumEntry( "fontSize", 1 ); |
131 | 131 | ||
132 | cfg.setGroup("Search"); | 132 | cfg.setGroup("Search"); |
133 | m_useRegExp = cfg.readBoolEntry( "useRegExp", false ); | 133 | m_useRegExp = cfg.readBoolEntry( "useRegExp", false ); |
134 | m_beCaseSensitive = cfg.readBoolEntry( "caseSensitive", false ); | 134 | m_beCaseSensitive = cfg.readBoolEntry( "caseSensitive", false ); |
135 | m_lpSearchMode = cfg.readNumEntry( "lpSearchMode", FullName ); | 135 | m_lpSearchMode = cfg.readNumEntry( "lpSearchMode", FileAs ); |
136 | 136 | ||
137 | cfg.setGroup("Mail"); | 137 | cfg.setGroup("Mail"); |
138 | m_useQtMail = cfg.readBoolEntry( "useQtMail", true ); | 138 | m_useQtMail = cfg.readBoolEntry( "useQtMail", true ); |
139 | m_useOpieMail=cfg.readBoolEntry( "useOpieMail" ); | 139 | m_useOpieMail=cfg.readBoolEntry( "useOpieMail" ); |
140 | 140 | ||
141 | cfg.setGroup("ContactOrder"); | 141 | cfg.setGroup("ContactOrder"); |
142 | int ID = 0; | 142 | int ID = 0; |
143 | int i = 0; | 143 | int i = 0; |
144 | ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 ); | 144 | ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 ); |
145 | while ( ID != 0 ){ | 145 | while ( ID != 0 ){ |
146 | m_ordered.append( ID ); | 146 | m_ordered.append( ID ); |
147 | ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 ); | 147 | ID = cfg.readNumEntry( "ContactID_"+QString::number(i++), 0 ); |
148 | } | 148 | } |
149 | 149 | ||
150 | // If no contact order is defined, we set the default | 150 | // If no contact order is defined, we set the default |
151 | if ( m_ordered.count() == 0 ) { | 151 | if ( m_ordered.count() == 0 ) { |
152 | m_ordered.append( Qtopia::DefaultEmail ); | 152 | m_ordered.append( Qtopia::DefaultEmail ); |
153 | m_ordered.append( Qtopia::HomePhone); | 153 | m_ordered.append( Qtopia::HomePhone); |
154 | m_ordered.append( Qtopia::HomeMobile); | 154 | m_ordered.append( Qtopia::HomeMobile); |
155 | m_ordered.append( Qtopia::BusinessPhone); | 155 | m_ordered.append( Qtopia::BusinessPhone); |
156 | } | 156 | } |
157 | 157 | ||
158 | cfg.setGroup("ToolBar"); | 158 | cfg.setGroup("ToolBar"); |
159 | m_barPos = cfg.readNumEntry( "Position", QMainWindow::Top ); | 159 | m_barPos = cfg.readNumEntry( "Position", QMainWindow::Top ); |
160 | m_fixedBars= cfg.readBoolEntry( "fixedBars", true ); | 160 | m_fixedBars= cfg.readBoolEntry( "fixedBars", true ); |
161 | 161 | ||
162 | m_changed = false; | 162 | m_changed = false; |
163 | } | 163 | } |
164 | 164 | ||
165 | void AbConfig::save() | 165 | void AbConfig::save() |
166 | { | 166 | { |
167 | if ( m_changed ){ | 167 | if ( m_changed ){ |
168 | Config cfg("AddressBook"); | 168 | Config cfg("AddressBook"); |
169 | cfg.setGroup("Font"); | 169 | cfg.setGroup("Font"); |
170 | cfg.writeEntry("fontSize", m_fontSize); | 170 | cfg.writeEntry("fontSize", m_fontSize); |
171 | 171 | ||
172 | cfg.setGroup("Search"); | 172 | cfg.setGroup("Search"); |
173 | cfg.writeEntry("useRegExp", m_useRegExp); | 173 | cfg.writeEntry("useRegExp", m_useRegExp); |
174 | cfg.writeEntry("caseSensitive", m_beCaseSensitive); | 174 | cfg.writeEntry("caseSensitive", m_beCaseSensitive); |
175 | cfg.writeEntry("lpSearchMode", m_lpSearchMode ); | 175 | cfg.writeEntry("lpSearchMode", m_lpSearchMode ); |
176 | 176 | ||
177 | cfg.setGroup("Mail"); | 177 | cfg.setGroup("Mail"); |
178 | cfg.writeEntry( "useQtMail", m_useQtMail ); | 178 | cfg.writeEntry( "useQtMail", m_useQtMail ); |
179 | cfg.writeEntry( "useOpieMail", m_useOpieMail); | 179 | cfg.writeEntry( "useOpieMail", m_useOpieMail); |
180 | 180 | ||
181 | cfg.setGroup("ContactOrder"); | 181 | cfg.setGroup("ContactOrder"); |
182 | cfg.clearGroup(); | 182 | cfg.clearGroup(); |
183 | for ( uint i = 0; i < m_ordered.count(); i++ ){ | 183 | for ( uint i = 0; i < m_ordered.count(); i++ ){ |
184 | cfg.writeEntry( "ContactID_"+QString::number(i), m_ordered[i] ); | 184 | cfg.writeEntry( "ContactID_"+QString::number(i), m_ordered[i] ); |
185 | } | 185 | } |
186 | 186 | ||
187 | cfg.setGroup("ToolBar"); | 187 | cfg.setGroup("ToolBar"); |
188 | cfg.writeEntry( "Position", m_barPos ); | 188 | cfg.writeEntry( "Position", m_barPos ); |
189 | cfg.writeEntry( "fixedBars", m_fixedBars ); | 189 | cfg.writeEntry( "fixedBars", m_fixedBars ); |
190 | 190 | ||
191 | cfg.setGroup("Version"); | 191 | cfg.setGroup("Version"); |
192 | cfg.writeEntry( "AppName", APPNAME + QString(" V" ) + MAINVERSION + QString(".") + SUBVERSION + QString(".") + PATCHVERSION); | 192 | cfg.writeEntry( "AppName", APPNAME + QString(" V" ) + MAINVERSION + QString(".") + SUBVERSION + QString(".") + PATCHVERSION); |
193 | cfg.writeEntry( "Mainversion", MAINVERSION ); | 193 | cfg.writeEntry( "Mainversion", MAINVERSION ); |
194 | cfg.writeEntry( "SubVersion", SUBVERSION ); | 194 | cfg.writeEntry( "SubVersion", SUBVERSION ); |
195 | cfg.writeEntry( "PatchVersion", PATCHVERSION ); | 195 | cfg.writeEntry( "PatchVersion", PATCHVERSION ); |
196 | 196 | ||
197 | } | 197 | } |
198 | 198 | ||
199 | } | 199 | } |
200 | 200 | ||
201 | void AbConfig::operator= ( const AbConfig& cnf ) | 201 | void AbConfig::operator= ( const AbConfig& cnf ) |
202 | { | 202 | { |
203 | m_useQtMail = cnf.m_useQtMail; | 203 | m_useQtMail = cnf.m_useQtMail; |
204 | m_useOpieMail = cnf.m_useOpieMail; | 204 | m_useOpieMail = cnf.m_useOpieMail; |
205 | m_useRegExp = cnf.m_useRegExp; | 205 | m_useRegExp = cnf.m_useRegExp; |
206 | m_beCaseSensitive = cnf.m_beCaseSensitive; | 206 | m_beCaseSensitive = cnf.m_beCaseSensitive; |
207 | m_fontSize = cnf.m_fontSize; | 207 | m_fontSize = cnf.m_fontSize; |
208 | m_ordered = cnf.m_ordered; | 208 | m_ordered = cnf.m_ordered; |
209 | m_barPos = cnf.m_barPos; | 209 | m_barPos = cnf.m_barPos; |
210 | m_fixedBars = cnf.m_fixedBars; | 210 | m_fixedBars = cnf.m_fixedBars; |
211 | m_lpSearchMode = cnf.m_lpSearchMode; | 211 | m_lpSearchMode = cnf.m_lpSearchMode; |
212 | } | 212 | } |
213 | 213 | ||
diff --git a/core/pim/addressbook/abconfig.h b/core/pim/addressbook/abconfig.h index 93764f2..c312179 100644 --- a/core/pim/addressbook/abconfig.h +++ b/core/pim/addressbook/abconfig.h | |||
@@ -1,69 +1,69 @@ | |||
1 | #ifndef _ABCONFIG_H_ | 1 | #ifndef _ABCONFIG_H_ |
2 | #define _ABCONFIG_H_ | 2 | #define _ABCONFIG_H_ |
3 | 3 | ||
4 | #include <qstringlist.h> | 4 | #include <qstringlist.h> |
5 | #include <qmainwindow.h> | 5 | #include <qmainwindow.h> |
6 | 6 | ||
7 | class AbConfig | 7 | class AbConfig |
8 | { | 8 | { |
9 | public: | 9 | public: |
10 | enum LPSearchMode{ | 10 | enum LPSearchMode{ |
11 | LastName = 0, | 11 | LastName = 0, |
12 | FullName, | 12 | FileAs, |
13 | LASTELEMENT | 13 | LASTELEMENT |
14 | }; | 14 | }; |
15 | 15 | ||
16 | 16 | ||
17 | 17 | ||
18 | AbConfig(); | 18 | AbConfig(); |
19 | ~AbConfig(); | 19 | ~AbConfig(); |
20 | 20 | ||
21 | // Search Settings | 21 | // Search Settings |
22 | bool useRegExp() const; | 22 | bool useRegExp() const; |
23 | bool useWildCards() const; | 23 | bool useWildCards() const; |
24 | bool beCaseSensitive() const; | 24 | bool beCaseSensitive() const; |
25 | bool useQtMail() const; | 25 | bool useQtMail() const; |
26 | bool useOpieMail() const; | 26 | bool useOpieMail() const; |
27 | int fontSize() const; | 27 | int fontSize() const; |
28 | QValueList<int> orderList() const; | 28 | QValueList<int> orderList() const; |
29 | QMainWindow::ToolBarDock getToolBarPos() const; | 29 | QMainWindow::ToolBarDock getToolBarPos() const; |
30 | bool fixedBars() const; | 30 | bool fixedBars() const; |
31 | LPSearchMode letterPickerSearch() const; | 31 | LPSearchMode letterPickerSearch() const; |
32 | 32 | ||
33 | void setUseRegExp( bool v ); | 33 | void setUseRegExp( bool v ); |
34 | void setUseWildCards( bool v ); | 34 | void setUseWildCards( bool v ); |
35 | void setBeCaseSensitive( bool v ); | 35 | void setBeCaseSensitive( bool v ); |
36 | void setUseQtMail( bool v ); | 36 | void setUseQtMail( bool v ); |
37 | void setUseOpieMail( bool v ); | 37 | void setUseOpieMail( bool v ); |
38 | void setFontSize( int v ); | 38 | void setFontSize( int v ); |
39 | void setOrderList( const QValueList<int>& list ); | 39 | void setOrderList( const QValueList<int>& list ); |
40 | void setToolBarDock( const QMainWindow::ToolBarDock v ); | 40 | void setToolBarDock( const QMainWindow::ToolBarDock v ); |
41 | void setFixedBars( const bool fixed ); | 41 | void setFixedBars( const bool fixed ); |
42 | void setLetterPickerSearch( const LPSearchMode mode ); | 42 | void setLetterPickerSearch( const LPSearchMode mode ); |
43 | 43 | ||
44 | void operator= ( const AbConfig& cnf ); | 44 | void operator= ( const AbConfig& cnf ); |
45 | 45 | ||
46 | void load(); | 46 | void load(); |
47 | void save(); | 47 | void save(); |
48 | 48 | ||
49 | protected: | 49 | protected: |
50 | /* virtual void itemUp(); */ | 50 | /* virtual void itemUp(); */ |
51 | /* virtual void itemDown(); */ | 51 | /* virtual void itemDown(); */ |
52 | 52 | ||
53 | QStringList contFields; | 53 | QStringList contFields; |
54 | 54 | ||
55 | bool m_useQtMail; | 55 | bool m_useQtMail; |
56 | bool m_useOpieMail; | 56 | bool m_useOpieMail; |
57 | bool m_useRegExp; | 57 | bool m_useRegExp; |
58 | bool m_beCaseSensitive; | 58 | bool m_beCaseSensitive; |
59 | int m_fontSize; | 59 | int m_fontSize; |
60 | QValueList<int> m_ordered; | 60 | QValueList<int> m_ordered; |
61 | int m_barPos; | 61 | int m_barPos; |
62 | bool m_fixedBars; | 62 | bool m_fixedBars; |
63 | int m_lpSearchMode; | 63 | int m_lpSearchMode; |
64 | 64 | ||
65 | bool m_changed; | 65 | bool m_changed; |
66 | }; | 66 | }; |
67 | 67 | ||
68 | 68 | ||
69 | #endif | 69 | #endif |
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp index 664bd3f..477f85b 100644 --- a/core/pim/addressbook/abview.cpp +++ b/core/pim/addressbook/abview.cpp | |||
@@ -1,500 +1,500 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) | 2 | ** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de) |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** | 14 | ** |
15 | **********************************************************************/ | 15 | **********************************************************************/ |
16 | 16 | ||
17 | #include "abview.h" | 17 | #include "abview.h" |
18 | 18 | ||
19 | #include <qlayout.h> | 19 | #include <qlayout.h> |
20 | 20 | ||
21 | #include <qpe/global.h> | 21 | #include <qpe/global.h> |
22 | 22 | ||
23 | #include <opie/ocontactaccessbackend_vcard.h> | 23 | #include <opie/ocontactaccessbackend_vcard.h> |
24 | 24 | ||
25 | #include <assert.h> | 25 | #include <assert.h> |
26 | 26 | ||
27 | 27 | ||
28 | // Is defined in LibQPE | 28 | // Is defined in LibQPE |
29 | extern QString categoryFileName(); | 29 | extern QString categoryFileName(); |
30 | 30 | ||
31 | QString addressbookPersonalVCardName() | 31 | QString addressbookPersonalVCardName() |
32 | { | 32 | { |
33 | QString filename = Global::applicationFileName("addressbook", | 33 | QString filename = Global::applicationFileName("addressbook", |
34 | "businesscard.vcf"); | 34 | "businesscard.vcf"); |
35 | return filename; | 35 | return filename; |
36 | } | 36 | } |
37 | 37 | ||
38 | 38 | ||
39 | AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): | 39 | AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): |
40 | QWidget(parent), | 40 | QWidget(parent), |
41 | mCat(0), | 41 | mCat(0), |
42 | m_inSearch( false ), | 42 | m_inSearch( false ), |
43 | m_inPersonal( false ), | 43 | m_inPersonal( false ), |
44 | m_curr_category( -1 ), | 44 | m_curr_category( -1 ), |
45 | m_curr_View( TableView ), | 45 | m_curr_View( TableView ), |
46 | m_prev_View( TableView ), | 46 | m_prev_View( TableView ), |
47 | m_curr_Contact ( 0 ), | 47 | m_curr_Contact ( 0 ), |
48 | m_contactdb ( 0l ), | 48 | m_contactdb ( 0l ), |
49 | m_storedDB ( 0l ), | 49 | m_storedDB ( 0l ), |
50 | m_viewStack( 0l ), | 50 | m_viewStack( 0l ), |
51 | m_abTable( 0l ), | 51 | m_abTable( 0l ), |
52 | m_orderedFields( ordered ) | 52 | m_orderedFields( ordered ) |
53 | { | 53 | { |
54 | // Load default database and handle syncing myself.. ! | 54 | // Load default database and handle syncing myself.. ! |
55 | m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false ), | 55 | m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false ), |
56 | mCat.load( categoryFileName() ); | 56 | mCat.load( categoryFileName() ); |
57 | 57 | ||
58 | // Create Layout and put WidgetStack into it. | 58 | // Create Layout and put WidgetStack into it. |
59 | QVBoxLayout *vb = new QVBoxLayout( this ); | 59 | QVBoxLayout *vb = new QVBoxLayout( this ); |
60 | m_viewStack = new QWidgetStack( this ); | 60 | m_viewStack = new QWidgetStack( this ); |
61 | vb->addWidget( m_viewStack ); | 61 | vb->addWidget( m_viewStack ); |
62 | 62 | ||
63 | // Creat TableView | 63 | // Creat TableView |
64 | QVBox* tableBox = new QVBox( m_viewStack ); | 64 | QVBox* tableBox = new QVBox( m_viewStack ); |
65 | m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); | 65 | m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); |
66 | m_abTable->setCurrentCell( 0, 0 ); | 66 | m_abTable->setCurrentCell( 0, 0 ); |
67 | m_abTable->setFocus(); | 67 | m_abTable->setFocus(); |
68 | 68 | ||
69 | // Add TableView to WidgetStack and raise it | 69 | // Add TableView to WidgetStack and raise it |
70 | m_viewStack -> addWidget( tableBox , TableView ); | 70 | m_viewStack -> addWidget( tableBox , TableView ); |
71 | 71 | ||
72 | // Create CardView and add it to WidgetStack | 72 | // Create CardView and add it to WidgetStack |
73 | QVBox* cardBox = new QVBox( m_viewStack ); | 73 | QVBox* cardBox = new QVBox( m_viewStack ); |
74 | m_ablabel = new AbLabel( cardBox, "CardView"); | 74 | m_ablabel = new AbLabel( cardBox, "CardView"); |
75 | m_viewStack -> addWidget( cardBox , CardView ); | 75 | m_viewStack -> addWidget( cardBox , CardView ); |
76 | 76 | ||
77 | // Connect views to me | 77 | // Connect views to me |
78 | connect ( m_abTable, SIGNAL( signalSwitch( void ) ), | 78 | connect ( m_abTable, SIGNAL( signalSwitch( void ) ), |
79 | this, SLOT( slotSwitch( void ) ) ); | 79 | this, SLOT( slotSwitch( void ) ) ); |
80 | connect ( m_ablabel, SIGNAL( signalOkPressed( void ) ), | 80 | connect ( m_ablabel, SIGNAL( signalOkPressed( void ) ), |
81 | this, SLOT( slotSwitch( void ) ) ); | 81 | this, SLOT( slotSwitch( void ) ) ); |
82 | 82 | ||
83 | load(); | 83 | load(); |
84 | } | 84 | } |
85 | 85 | ||
86 | AbView::~AbView() | 86 | AbView::~AbView() |
87 | { | 87 | { |
88 | m_contactdb -> save(); | 88 | m_contactdb -> save(); |
89 | delete m_contactdb; | 89 | delete m_contactdb; |
90 | 90 | ||
91 | if ( m_storedDB ){ | 91 | if ( m_storedDB ){ |
92 | m_storedDB -> save(); | 92 | m_storedDB -> save(); |
93 | delete m_storedDB; | 93 | delete m_storedDB; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | void AbView::setView( Views view ) | 98 | void AbView::setView( Views view ) |
99 | { | 99 | { |
100 | //qWarning("AbView::setView( Views view )"); | 100 | //qWarning("AbView::setView( Views view )"); |
101 | m_curr_View = view; | 101 | m_curr_View = view; |
102 | load(); | 102 | load(); |
103 | } | 103 | } |
104 | 104 | ||
105 | void AbView::addEntry( const OContact &newContact ) | 105 | void AbView::addEntry( const OContact &newContact ) |
106 | { | 106 | { |
107 | //qWarning("abview:AddContact"); | 107 | //qWarning("abview:AddContact"); |
108 | m_contactdb->add ( newContact ); | 108 | m_contactdb->add ( newContact ); |
109 | load(); | 109 | load(); |
110 | 110 | ||
111 | } | 111 | } |
112 | void AbView::removeEntry( const int UID ) | 112 | void AbView::removeEntry( const int UID ) |
113 | { | 113 | { |
114 | //qWarning("abview:RemoveContact"); | 114 | //qWarning("abview:RemoveContact"); |
115 | m_contactdb->remove( UID ); | 115 | m_contactdb->remove( UID ); |
116 | load(); | 116 | load(); |
117 | } | 117 | } |
118 | 118 | ||
119 | void AbView::replaceEntry( const OContact &contact ) | 119 | void AbView::replaceEntry( const OContact &contact ) |
120 | { | 120 | { |
121 | //qWarning("abview:ReplaceContact"); | 121 | //qWarning("abview:ReplaceContact"); |
122 | m_contactdb->replace( contact ); | 122 | m_contactdb->replace( contact ); |
123 | load(); | 123 | load(); |
124 | 124 | ||
125 | } | 125 | } |
126 | 126 | ||
127 | OContact AbView::currentEntry() | 127 | OContact AbView::currentEntry() |
128 | { | 128 | { |
129 | OContact currentContact; | 129 | OContact currentContact; |
130 | 130 | ||
131 | switch ( (int) m_curr_View ) { | 131 | switch ( (int) m_curr_View ) { |
132 | case TableView: | 132 | case TableView: |
133 | currentContact = m_abTable -> currentEntry(); | 133 | currentContact = m_abTable -> currentEntry(); |
134 | break; | 134 | break; |
135 | case CardView: | 135 | case CardView: |
136 | currentContact = m_ablabel -> currentEntry(); | 136 | currentContact = m_ablabel -> currentEntry(); |
137 | break; | 137 | break; |
138 | } | 138 | } |
139 | m_curr_Contact = currentContact.uid(); | 139 | m_curr_Contact = currentContact.uid(); |
140 | return currentContact; | 140 | return currentContact; |
141 | } | 141 | } |
142 | 142 | ||
143 | bool AbView::save() | 143 | bool AbView::save() |
144 | { | 144 | { |
145 | //qWarning("abView:Save data"); | 145 | //qWarning("abView:Save data"); |
146 | 146 | ||
147 | return m_contactdb->save(); | 147 | return m_contactdb->save(); |
148 | } | 148 | } |
149 | 149 | ||
150 | void AbView::load() | 150 | void AbView::load() |
151 | { | 151 | { |
152 | //qWarning("abView:Load data"); | 152 | //qWarning("abView:Load data"); |
153 | 153 | ||
154 | // Letter Search is stopped at this place | 154 | // Letter Search is stopped at this place |
155 | emit signalClearLetterPicker(); | 155 | emit signalClearLetterPicker(); |
156 | 156 | ||
157 | if ( m_inPersonal ) | 157 | if ( m_inPersonal ) |
158 | // VCard Backend does not sort.. | 158 | // VCard Backend does not sort.. |
159 | m_list = m_contactdb->allRecords(); | 159 | m_list = m_contactdb->allRecords(); |
160 | else{ | 160 | else{ |
161 | m_list = m_contactdb->sorted( true, 0, 0, 0 ); | 161 | m_list = m_contactdb->sorted( true, 0, 0, 0 ); |
162 | clearForCategory(); | 162 | clearForCategory(); |
163 | } | 163 | } |
164 | 164 | ||
165 | qWarning ("Number of contacts: %d", m_list.count()); | 165 | qWarning ("Number of contacts: %d", m_list.count()); |
166 | 166 | ||
167 | updateView( true ); | 167 | updateView( true ); |
168 | 168 | ||
169 | } | 169 | } |
170 | 170 | ||
171 | void AbView::reload() | 171 | void AbView::reload() |
172 | { | 172 | { |
173 | //qWarning( "void AbView::reload()" ); | 173 | //qWarning( "void AbView::reload()" ); |
174 | 174 | ||
175 | m_contactdb->reload(); | 175 | m_contactdb->reload(); |
176 | load(); | 176 | load(); |
177 | } | 177 | } |
178 | 178 | ||
179 | void AbView::clear() | 179 | void AbView::clear() |
180 | { | 180 | { |
181 | // :SX | 181 | // :SX |
182 | } | 182 | } |
183 | 183 | ||
184 | void AbView::setShowByCategory( const QString& cat ) | 184 | void AbView::setShowByCategory( const QString& cat ) |
185 | { | 185 | { |
186 | //qWarning("AbView::setShowCategory( const QString& cat )"); | 186 | //qWarning("AbView::setShowCategory( const QString& cat )"); |
187 | 187 | ||
188 | int intCat = 0; | 188 | int intCat = 0; |
189 | 189 | ||
190 | // All (cat == NULL) will be stored as -1 | 190 | // All (cat == NULL) will be stored as -1 |
191 | if ( cat.isNull() ) | 191 | if ( cat.isNull() ) |
192 | intCat = -1; | 192 | intCat = -1; |
193 | else | 193 | else |
194 | intCat = mCat.id("Contacts", cat ); | 194 | intCat = mCat.id("Contacts", cat ); |
195 | 195 | ||
196 | // Just do anything if we really change the category | 196 | // Just do anything if we really change the category |
197 | if ( intCat != m_curr_category ){ | 197 | if ( intCat != m_curr_category ){ |
198 | // qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); | 198 | // qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); |
199 | 199 | ||
200 | m_curr_category = intCat; | 200 | m_curr_category = intCat; |
201 | emit signalClearLetterPicker(); | 201 | emit signalClearLetterPicker(); |
202 | 202 | ||
203 | load(); | 203 | load(); |
204 | } | 204 | } |
205 | 205 | ||
206 | } | 206 | } |
207 | 207 | ||
208 | void AbView::setShowToView( Views view ) | 208 | void AbView::setShowToView( Views view ) |
209 | { | 209 | { |
210 | //qWarning("void AbView::setShowToView( View %d )", view); | 210 | //qWarning("void AbView::setShowToView( View %d )", view); |
211 | 211 | ||
212 | //qWarning ("Change the View (Category is: %d)", m_curr_category); | 212 | //qWarning ("Change the View (Category is: %d)", m_curr_category); |
213 | 213 | ||
214 | if ( m_curr_View != view ){ | 214 | if ( m_curr_View != view ){ |
215 | m_prev_View = m_curr_View; | 215 | m_prev_View = m_curr_View; |
216 | m_curr_View = view; | 216 | m_curr_View = view; |
217 | 217 | ||
218 | updateView(); | 218 | updateView(); |
219 | } | 219 | } |
220 | 220 | ||
221 | } | 221 | } |
222 | 222 | ||
223 | void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) | 223 | void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) |
224 | { | 224 | { |
225 | qWarning("void AbView::setShowByLetter( %c, %d )", c, mode ); | 225 | qWarning("void AbView::setShowByLetter( %c, %d )", c, mode ); |
226 | 226 | ||
227 | assert( mode < AbConfig::LASTELEMENT ); | 227 | assert( mode < AbConfig::LASTELEMENT ); |
228 | 228 | ||
229 | OContact query; | 229 | OContact query; |
230 | if ( c == 0 ){ | 230 | if ( c == 0 ){ |
231 | load(); | 231 | load(); |
232 | return; | 232 | return; |
233 | }else{ | 233 | }else{ |
234 | // If the current Backend is unable to solve the query, we will | 234 | // If the current Backend is unable to solve the query, we will |
235 | // ignore the request .. | 235 | // ignore the request .. |
236 | if ( ! m_contactdb->hasQuerySettings( OContactAccess::WildCards | OContactAccess::IgnoreCase ) ){ | 236 | if ( ! m_contactdb->hasQuerySettings( OContactAccess::WildCards | OContactAccess::IgnoreCase ) ){ |
237 | return; | 237 | return; |
238 | } | 238 | } |
239 | 239 | ||
240 | switch( mode ){ | 240 | switch( mode ){ |
241 | case AbConfig::LastName: | 241 | case AbConfig::LastName: |
242 | query.setLastName( QString("%1*").arg(c) ); | 242 | query.setLastName( QString("%1*").arg(c) ); |
243 | break; | 243 | break; |
244 | case AbConfig::FullName: | 244 | case AbConfig::FileAs: |
245 | query.setFileAs( QString("%1*").arg(c) ); | 245 | query.setFileAs( QString("%1*").arg(c) ); |
246 | break; | 246 | break; |
247 | default: | 247 | default: |
248 | qWarning( "Unknown Searchmode for AbView::setShowByLetter ! -> %d", mode ); | 248 | qWarning( "Unknown Searchmode for AbView::setShowByLetter ! -> %d", mode ); |
249 | qWarning( "I will ignore it.." ); | 249 | qWarning( "I will ignore it.." ); |
250 | return; | 250 | return; |
251 | } | 251 | } |
252 | m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase ); | 252 | m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase ); |
253 | clearForCategory(); | 253 | clearForCategory(); |
254 | m_curr_Contact = 0; | 254 | m_curr_Contact = 0; |
255 | } | 255 | } |
256 | updateView( true ); | 256 | updateView( true ); |
257 | } | 257 | } |
258 | 258 | ||
259 | void AbView::setListOrder( const QValueList<int>& ordered ) | 259 | void AbView::setListOrder( const QValueList<int>& ordered ) |
260 | { | 260 | { |
261 | m_orderedFields = ordered; | 261 | m_orderedFields = ordered; |
262 | if ( m_abTable ){ | 262 | if ( m_abTable ){ |
263 | m_abTable->setOrderedList( ordered ); | 263 | m_abTable->setOrderedList( ordered ); |
264 | m_abTable->refresh(); | 264 | m_abTable->refresh(); |
265 | } | 265 | } |
266 | updateView(); | 266 | updateView(); |
267 | } | 267 | } |
268 | 268 | ||
269 | 269 | ||
270 | QString AbView::showCategory() const | 270 | QString AbView::showCategory() const |
271 | { | 271 | { |
272 | return mCat.label( "Contacts", m_curr_category ); | 272 | return mCat.label( "Contacts", m_curr_category ); |
273 | } | 273 | } |
274 | 274 | ||
275 | void AbView::showPersonal( bool personal ) | 275 | void AbView::showPersonal( bool personal ) |
276 | { | 276 | { |
277 | //qWarning ("void AbView::showPersonal( %d )", personal); | 277 | //qWarning ("void AbView::showPersonal( %d )", personal); |
278 | 278 | ||
279 | if ( personal ){ | 279 | if ( personal ){ |
280 | 280 | ||
281 | if ( m_inPersonal ) | 281 | if ( m_inPersonal ) |
282 | return; | 282 | return; |
283 | 283 | ||
284 | // Now switch to vCard Backend and load data. | 284 | // Now switch to vCard Backend and load data. |
285 | // The current default backend will be stored | 285 | // The current default backend will be stored |
286 | // to avoid unneeded load/stores. | 286 | // to avoid unneeded load/stores. |
287 | m_storedDB = m_contactdb; | 287 | m_storedDB = m_contactdb; |
288 | 288 | ||
289 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 289 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
290 | addressbookPersonalVCardName() ); | 290 | addressbookPersonalVCardName() ); |
291 | m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 291 | m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
292 | 292 | ||
293 | m_inPersonal = true; | 293 | m_inPersonal = true; |
294 | m_curr_View = CardView; | 294 | m_curr_View = CardView; |
295 | 295 | ||
296 | }else{ | 296 | }else{ |
297 | 297 | ||
298 | if ( !m_inPersonal ) | 298 | if ( !m_inPersonal ) |
299 | return; | 299 | return; |
300 | 300 | ||
301 | // Remove vCard Backend and restore default | 301 | // Remove vCard Backend and restore default |
302 | m_contactdb->save(); | 302 | m_contactdb->save(); |
303 | delete m_contactdb; | 303 | delete m_contactdb; |
304 | 304 | ||
305 | m_contactdb = m_storedDB; | 305 | m_contactdb = m_storedDB; |
306 | m_storedDB = 0l; | 306 | m_storedDB = 0l; |
307 | 307 | ||
308 | m_curr_View = TableView; | 308 | m_curr_View = TableView; |
309 | m_inPersonal = false; | 309 | m_inPersonal = false; |
310 | 310 | ||
311 | } | 311 | } |
312 | load(); | 312 | load(); |
313 | } | 313 | } |
314 | 314 | ||
315 | void AbView::setCurrentUid( int uid ){ | 315 | void AbView::setCurrentUid( int uid ){ |
316 | 316 | ||
317 | m_curr_Contact = uid; | 317 | m_curr_Contact = uid; |
318 | updateView( true ); //true: Don't modificate the UID ! | 318 | updateView( true ); //true: Don't modificate the UID ! |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | QStringList AbView::categories() | 322 | QStringList AbView::categories() |
323 | { | 323 | { |
324 | mCat.load( categoryFileName() ); | 324 | mCat.load( categoryFileName() ); |
325 | QStringList categoryList = mCat.labels( "Contacts" ); | 325 | QStringList categoryList = mCat.labels( "Contacts" ); |
326 | return categoryList; | 326 | return categoryList; |
327 | } | 327 | } |
328 | 328 | ||
329 | // BEGIN: Slots | 329 | // BEGIN: Slots |
330 | void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, | 330 | void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, |
331 | bool , QString cat ) | 331 | bool , QString cat ) |
332 | { | 332 | { |
333 | //qWarning( "void AbView::slotDoFind" ); | 333 | //qWarning( "void AbView::slotDoFind" ); |
334 | 334 | ||
335 | // We reloading the data: Deselect Letterpicker | 335 | // We reloading the data: Deselect Letterpicker |
336 | emit signalClearLetterPicker(); | 336 | emit signalClearLetterPicker(); |
337 | 337 | ||
338 | // Use the current Category if nothing else selected | 338 | // Use the current Category if nothing else selected |
339 | int category = 0; | 339 | int category = 0; |
340 | 340 | ||
341 | if ( cat.isEmpty() ) | 341 | if ( cat.isEmpty() ) |
342 | category = m_curr_category; | 342 | category = m_curr_category; |
343 | else{ | 343 | else{ |
344 | category = mCat.id("Contacts", cat ); | 344 | category = mCat.id("Contacts", cat ); |
345 | } | 345 | } |
346 | 346 | ||
347 | //qWarning ("Find in Category %d", category); | 347 | //qWarning ("Find in Category %d", category); |
348 | 348 | ||
349 | QRegExp r( str ); | 349 | QRegExp r( str ); |
350 | r.setCaseSensitive( caseSensitive ); | 350 | r.setCaseSensitive( caseSensitive ); |
351 | r.setWildcard( !useRegExp ); | 351 | r.setWildcard( !useRegExp ); |
352 | 352 | ||
353 | // Get all matching entries out of the database | 353 | // Get all matching entries out of the database |
354 | m_list = m_contactdb->matchRegexp( r ); | 354 | m_list = m_contactdb->matchRegexp( r ); |
355 | 355 | ||
356 | //qWarning( "found: %d", m_list.count() ); | 356 | //qWarning( "found: %d", m_list.count() ); |
357 | if ( m_list.count() == 0 ){ | 357 | if ( m_list.count() == 0 ){ |
358 | emit signalNotFound(); | 358 | emit signalNotFound(); |
359 | return; | 359 | return; |
360 | } | 360 | } |
361 | 361 | ||
362 | // Now remove all contacts with wrong category (if any selected) | 362 | // Now remove all contacts with wrong category (if any selected) |
363 | // This algorithm is a litte bit ineffective, but | 363 | // This algorithm is a litte bit ineffective, but |
364 | // we will not have a lot of matching entries.. | 364 | // we will not have a lot of matching entries.. |
365 | clearForCategory(); | 365 | clearForCategory(); |
366 | 366 | ||
367 | // Now show all found entries | 367 | // Now show all found entries |
368 | updateView( true ); | 368 | updateView( true ); |
369 | } | 369 | } |
370 | 370 | ||
371 | void AbView::offSearch() | 371 | void AbView::offSearch() |
372 | { | 372 | { |
373 | m_inSearch = false; | 373 | m_inSearch = false; |
374 | 374 | ||
375 | load(); | 375 | load(); |
376 | } | 376 | } |
377 | 377 | ||
378 | void AbView::slotSwitch(){ | 378 | void AbView::slotSwitch(){ |
379 | //qWarning("AbView::slotSwitch()"); | 379 | //qWarning("AbView::slotSwitch()"); |
380 | 380 | ||
381 | m_prev_View = m_curr_View; | 381 | m_prev_View = m_curr_View; |
382 | switch ( (int) m_curr_View ){ | 382 | switch ( (int) m_curr_View ){ |
383 | case TableView: | 383 | case TableView: |
384 | qWarning("Switching to CardView"); | 384 | qWarning("Switching to CardView"); |
385 | m_curr_View = CardView; | 385 | m_curr_View = CardView; |
386 | break; | 386 | break; |
387 | case CardView: | 387 | case CardView: |
388 | qWarning("Switching to TableView"); | 388 | qWarning("Switching to TableView"); |
389 | m_curr_View = TableView; | 389 | m_curr_View = TableView; |
390 | break; | 390 | break; |
391 | } | 391 | } |
392 | updateView(); | 392 | updateView(); |
393 | 393 | ||
394 | } | 394 | } |
395 | 395 | ||
396 | // END: Slots | 396 | // END: Slots |
397 | 397 | ||
398 | void AbView::clearForCategory() | 398 | void AbView::clearForCategory() |
399 | { | 399 | { |
400 | OContactAccess::List::Iterator it; | 400 | OContactAccess::List::Iterator it; |
401 | // Now remove all contacts with wrong category if any category selected | 401 | // Now remove all contacts with wrong category if any category selected |
402 | 402 | ||
403 | OContactAccess::List allList = m_list; | 403 | OContactAccess::List allList = m_list; |
404 | if ( m_curr_category != -1 ){ | 404 | if ( m_curr_category != -1 ){ |
405 | for ( it = allList.begin(); it != allList.end(); ++it ){ | 405 | for ( it = allList.begin(); it != allList.end(); ++it ){ |
406 | if ( !contactCompare( *it, m_curr_category ) ){ | 406 | if ( !contactCompare( *it, m_curr_category ) ){ |
407 | // qWarning("Removing %d", (*it).uid()); | 407 | // qWarning("Removing %d", (*it).uid()); |
408 | m_list.remove( (*it).uid() ); | 408 | m_list.remove( (*it).uid() ); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | } | 411 | } |
412 | 412 | ||
413 | } | 413 | } |
414 | 414 | ||
415 | bool AbView::contactCompare( const OContact &cnt, int category ) | 415 | bool AbView::contactCompare( const OContact &cnt, int category ) |
416 | { | 416 | { |
417 | //qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category); | 417 | //qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category); |
418 | 418 | ||
419 | bool returnMe; | 419 | bool returnMe; |
420 | QArray<int> cats; | 420 | QArray<int> cats; |
421 | cats = cnt.categories(); | 421 | cats = cnt.categories(); |
422 | 422 | ||
423 | //qWarning ("Number of categories: %d", cats.count() ); | 423 | //qWarning ("Number of categories: %d", cats.count() ); |
424 | 424 | ||
425 | returnMe = false; | 425 | returnMe = false; |
426 | if ( cats.count() == 0 && category == 0 ) | 426 | if ( cats.count() == 0 && category == 0 ) |
427 | // Contacts with no category will just shown on "All" and "Unfiled" | 427 | // Contacts with no category will just shown on "All" and "Unfiled" |
428 | returnMe = true; | 428 | returnMe = true; |
429 | else { | 429 | else { |
430 | int i; | 430 | int i; |
431 | for ( i = 0; i < int(cats.count()); i++ ) { | 431 | for ( i = 0; i < int(cats.count()); i++ ) { |
432 | // qWarning("Comparing %d with %d",cats[i],category ); | 432 | // qWarning("Comparing %d with %d",cats[i],category ); |
433 | if ( cats[i] == category ) { | 433 | if ( cats[i] == category ) { |
434 | returnMe = true; | 434 | returnMe = true; |
435 | break; | 435 | break; |
436 | } | 436 | } |
437 | } | 437 | } |
438 | } | 438 | } |
439 | //qWarning ("Return: %d", returnMe); | 439 | //qWarning ("Return: %d", returnMe); |
440 | return returnMe; | 440 | return returnMe; |
441 | } | 441 | } |
442 | 442 | ||
443 | // In Some rare cases we have to update all lists.. | 443 | // In Some rare cases we have to update all lists.. |
444 | void AbView::updateListinViews() | 444 | void AbView::updateListinViews() |
445 | { | 445 | { |
446 | m_abTable -> setContacts( m_list ); | 446 | m_abTable -> setContacts( m_list ); |
447 | m_ablabel -> setContacts( m_list ); | 447 | m_ablabel -> setContacts( m_list ); |
448 | } | 448 | } |
449 | 449 | ||
450 | void AbView::updateView( bool newdata ) | 450 | void AbView::updateView( bool newdata ) |
451 | { | 451 | { |
452 | //qWarning("AbView::updateView()"); | 452 | //qWarning("AbView::updateView()"); |
453 | 453 | ||
454 | if ( m_viewStack -> visibleWidget() ){ | 454 | if ( m_viewStack -> visibleWidget() ){ |
455 | m_viewStack -> visibleWidget() -> clearFocus(); | 455 | m_viewStack -> visibleWidget() -> clearFocus(); |
456 | } | 456 | } |
457 | 457 | ||
458 | // If we switching the view, we have to store some information | 458 | // If we switching the view, we have to store some information |
459 | if ( !newdata ){ | 459 | if ( !newdata ){ |
460 | if ( m_list.count() ){ | 460 | if ( m_list.count() ){ |
461 | switch ( (int) m_prev_View ) { | 461 | switch ( (int) m_prev_View ) { |
462 | case TableView: | 462 | case TableView: |
463 | m_curr_Contact = m_abTable -> currentEntry_UID(); | 463 | m_curr_Contact = m_abTable -> currentEntry_UID(); |
464 | break; | 464 | break; |
465 | case CardView: | 465 | case CardView: |
466 | m_curr_Contact = m_ablabel -> currentEntry_UID(); | 466 | m_curr_Contact = m_ablabel -> currentEntry_UID(); |
467 | break; | 467 | break; |
468 | } | 468 | } |
469 | }else | 469 | }else |
470 | m_curr_Contact = 0; | 470 | m_curr_Contact = 0; |
471 | } | 471 | } |
472 | 472 | ||
473 | // Feed all views with new lists | 473 | // Feed all views with new lists |
474 | if ( newdata ) | 474 | if ( newdata ) |
475 | updateListinViews(); | 475 | updateListinViews(); |
476 | 476 | ||
477 | // Tell the world that the view is changed | 477 | // Tell the world that the view is changed |
478 | if ( m_curr_View != m_prev_View ) | 478 | if ( m_curr_View != m_prev_View ) |
479 | emit signalViewSwitched ( (int) m_curr_View ); | 479 | emit signalViewSwitched ( (int) m_curr_View ); |
480 | 480 | ||
481 | m_prev_View = m_curr_View; | 481 | m_prev_View = m_curr_View; |
482 | 482 | ||
483 | // Switch to new View | 483 | // Switch to new View |
484 | switch ( (int) m_curr_View ) { | 484 | switch ( (int) m_curr_View ) { |
485 | case TableView: | 485 | case TableView: |
486 | m_abTable -> setChoiceSelection( m_orderedFields ); | 486 | m_abTable -> setChoiceSelection( m_orderedFields ); |
487 | if ( m_curr_Contact != 0 ) | 487 | if ( m_curr_Contact != 0 ) |
488 | m_abTable -> selectContact ( m_curr_Contact ); | 488 | m_abTable -> selectContact ( m_curr_Contact ); |
489 | m_abTable -> setFocus(); | 489 | m_abTable -> setFocus(); |
490 | break; | 490 | break; |
491 | case CardView: | 491 | case CardView: |
492 | if ( m_curr_Contact != 0 ) | 492 | if ( m_curr_Contact != 0 ) |
493 | m_ablabel -> selectContact( m_curr_Contact ); | 493 | m_ablabel -> selectContact( m_curr_Contact ); |
494 | m_ablabel -> setFocus(); | 494 | m_ablabel -> setFocus(); |
495 | break; | 495 | break; |
496 | } | 496 | } |
497 | 497 | ||
498 | // Raise the current View | 498 | // Raise the current View |
499 | m_viewStack -> raiseWidget( m_curr_View ); | 499 | m_viewStack -> raiseWidget( m_curr_View ); |
500 | } | 500 | } |