-rw-r--r-- | core/pim/addressbook/abview.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp index 34035fd..8a2db96 100644 --- a/core/pim/addressbook/abview.cpp +++ b/core/pim/addressbook/abview.cpp | |||
@@ -64,197 +64,207 @@ AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): | |||
64 | vb->addWidget( m_viewStack ); | 64 | vb->addWidget( m_viewStack ); |
65 | 65 | ||
66 | // Creat TableView | 66 | // Creat TableView |
67 | QVBox* tableBox = new QVBox( m_viewStack ); | 67 | QVBox* tableBox = new QVBox( m_viewStack ); |
68 | m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); | 68 | m_abTable = new AbTable( m_orderedFields, tableBox, "table" ); |
69 | m_abTable->setCurrentCell( 0, 0 ); | 69 | m_abTable->setCurrentCell( 0, 0 ); |
70 | m_abTable->setFocus(); | 70 | m_abTable->setFocus(); |
71 | 71 | ||
72 | // Add TableView to WidgetStack and raise it | 72 | // Add TableView to WidgetStack and raise it |
73 | m_viewStack -> addWidget( tableBox , TableView ); | 73 | m_viewStack -> addWidget( tableBox , TableView ); |
74 | 74 | ||
75 | // Create CardView and add it to WidgetStack | 75 | // Create CardView and add it to WidgetStack |
76 | QVBox* cardBox = new QVBox( m_viewStack ); | 76 | QVBox* cardBox = new QVBox( m_viewStack ); |
77 | m_ablabel = new AbLabel( cardBox, "CardView"); | 77 | m_ablabel = new AbLabel( cardBox, "CardView"); |
78 | m_viewStack -> addWidget( cardBox , CardView ); | 78 | m_viewStack -> addWidget( cardBox , CardView ); |
79 | 79 | ||
80 | // Connect views to me | 80 | // Connect views to me |
81 | connect ( m_abTable, SIGNAL( signalSwitch(void) ), | 81 | connect ( m_abTable, SIGNAL( signalSwitch(void) ), |
82 | this, SLOT( slotSwitch(void) ) ); | 82 | this, SLOT( slotSwitch(void) ) ); |
83 | connect ( m_ablabel, SIGNAL( signalOkPressed(void) ), | 83 | connect ( m_ablabel, SIGNAL( signalOkPressed(void) ), |
84 | this, SLOT( slotSwitch(void) ) ); | 84 | this, SLOT( slotSwitch(void) ) ); |
85 | 85 | ||
86 | load(); | 86 | load(); |
87 | } | 87 | } |
88 | 88 | ||
89 | AbView::~AbView() | 89 | AbView::~AbView() |
90 | { | 90 | { |
91 | m_contactdb -> save(); | 91 | m_contactdb -> save(); |
92 | delete m_contactdb; | 92 | delete m_contactdb; |
93 | 93 | ||
94 | if ( m_storedDB ){ | 94 | if ( m_storedDB ){ |
95 | m_storedDB -> save(); | 95 | m_storedDB -> save(); |
96 | delete m_storedDB; | 96 | delete m_storedDB; |
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | 100 | ||
101 | void AbView::setView( Views view ) | 101 | void AbView::setView( Views view ) |
102 | { | 102 | { |
103 | odebug << "AbView::setView( Views view )" << oendl; | 103 | odebug << "AbView::setView( Views view )" << oendl; |
104 | m_curr_View = view; | 104 | m_curr_View = view; |
105 | load(); | 105 | load(); |
106 | } | 106 | } |
107 | 107 | ||
108 | void AbView::addEntry( const Opie::OPimContact &newContact ) | 108 | void AbView::addEntry( const Opie::OPimContact &newContact ) |
109 | { | 109 | { |
110 | odebug << "AbView::AddContact" << oendl; | 110 | odebug << "AbView::AddContact" << oendl; |
111 | m_contactdb->add ( newContact ); | 111 | m_contactdb->add ( newContact ); |
112 | load(); | 112 | load(); |
113 | 113 | ||
114 | } | 114 | } |
115 | void AbView::removeEntry( const int UID ) | 115 | void AbView::removeEntry( const int UID ) |
116 | { | 116 | { |
117 | odebug << "AbView;:RemoveContact" << oendl; | 117 | odebug << "AbView;:RemoveContact" << oendl; |
118 | m_contactdb->remove( UID ); | 118 | m_contactdb->remove( UID ); |
119 | load(); | 119 | load(); |
120 | } | 120 | } |
121 | 121 | ||
122 | void AbView::replaceEntry( const Opie::OPimContact &contact ) | 122 | void AbView::replaceEntry( const Opie::OPimContact &contact ) |
123 | { | 123 | { |
124 | odebug << "AbView::ReplaceContact" << oendl; | 124 | odebug << "AbView::ReplaceContact" << oendl; |
125 | m_contactdb->replace( contact ); | 125 | m_contactdb->replace( contact ); |
126 | load(); | 126 | load(); |
127 | 127 | ||
128 | } | 128 | } |
129 | 129 | ||
130 | Opie::OPimContact AbView::currentEntry() | 130 | Opie::OPimContact AbView::currentEntry() |
131 | { | 131 | { |
132 | Opie::OPimContact currentContact; | 132 | Opie::OPimContact currentContact; |
133 | 133 | ||
134 | switch ( (int) m_curr_View ) { | 134 | switch ( (int) m_curr_View ) { |
135 | case TableView: | 135 | case TableView: |
136 | currentContact = m_abTable -> currentEntry(); | 136 | currentContact = m_abTable -> currentEntry(); |
137 | break; | 137 | break; |
138 | case CardView: | 138 | case CardView: |
139 | currentContact = m_ablabel -> currentEntry(); | 139 | currentContact = m_ablabel -> currentEntry(); |
140 | break; | 140 | break; |
141 | } | 141 | } |
142 | m_curr_Contact = currentContact.uid(); | 142 | m_curr_Contact = currentContact.uid(); |
143 | return currentContact; | 143 | return currentContact; |
144 | } | 144 | } |
145 | 145 | ||
146 | bool AbView::save() | 146 | bool AbView::save() |
147 | { | 147 | { |
148 | //odebug << "AbView::Save data" << oendl; | 148 | //odebug << "AbView::Save data" << oendl; |
149 | 149 | ||
150 | return m_contactdb->save(); | 150 | return m_contactdb->save(); |
151 | } | 151 | } |
152 | 152 | ||
153 | void AbView::load() | 153 | void AbView::load() |
154 | { | 154 | { |
155 | odebug << "AbView::Load data" << oendl; | 155 | odebug << "AbView::Load data" << oendl; |
156 | 156 | ||
157 | // Letter Search is stopped at this place | 157 | // Letter Search is stopped at this place |
158 | emit signalClearLetterPicker(); | 158 | emit signalClearLetterPicker(); |
159 | 159 | ||
160 | m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, | 160 | odebug << "selected Category: " << m_curr_category << oendl; |
161 | Opie::OPimContactAccess::FilterCategory, m_curr_category ); | 161 | |
162 | 162 | if ( m_curr_category == -1 ) { | |
163 | // if ( m_curr_category != -1 ) | 163 | // Show just unfiled contacts |
164 | // clearForCategory(); | 164 | m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, |
165 | Opie::OPimContactAccess::DoNotShowWithCategory, 0 ); | ||
166 | } elseif ( m_curr_category == 0 ){ | ||
167 | // Just show all contacts | ||
168 | m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, | ||
169 | Opie::OPimBase::FilterOff, 0 ); | ||
170 | } else { | ||
171 | // Show contacts with given categories | ||
172 | m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, | ||
173 | Opie::OPimBase::FilterCategory, m_curr_category ); | ||
174 | } | ||
165 | 175 | ||
166 | odebug << "Number of contacts: " << m_list.count() << oendl; | 176 | odebug << "Number of contacts: " << m_list.count() << oendl; |
167 | 177 | ||
168 | updateView( true ); | 178 | updateView( true ); |
169 | 179 | ||
170 | } | 180 | } |
171 | 181 | ||
172 | void AbView::reload() | 182 | void AbView::reload() |
173 | { | 183 | { |
174 | odebug << "AbView::::reload()" << oendl; | 184 | odebug << "AbView::::reload()" << oendl; |
175 | 185 | ||
176 | m_contactdb->reload(); | 186 | m_contactdb->reload(); |
177 | load(); | 187 | load(); |
178 | } | 188 | } |
179 | 189 | ||
180 | void AbView::clear() | 190 | void AbView::clear() |
181 | { | 191 | { |
182 | // :SX | 192 | // :SX |
183 | } | 193 | } |
184 | 194 | ||
185 | void AbView::setShowByCategory( const QString& cat ) | 195 | void AbView::setShowByCategory( const QString& cat ) |
186 | { | 196 | { |
187 | odebug << "AbView::setShowCategory( const QString& cat )" << oendl; | 197 | odebug << "AbView::setShowCategory( const QString& cat )" << oendl; |
188 | 198 | ||
189 | int intCat = 0; | 199 | int intCat = 0; |
190 | 200 | ||
191 | // Unfiled will be stored as -1 | 201 | // Unfiled will be stored as -1 |
192 | if ( cat == tr( "Unfiled" ) ) | 202 | if ( cat == tr( "Unfiled" ) ) |
193 | intCat = -1; | 203 | intCat = -1; |
194 | else if ( cat.isNull() ) | 204 | else if ( cat.isNull() ) |
195 | intCat = 0; | 205 | intCat = 0; |
196 | else | 206 | else |
197 | intCat = mCat.id("Contacts", cat ); | 207 | intCat = mCat.id("Contacts", cat ); |
198 | 208 | ||
199 | // Just do anything if we really change the category | 209 | // Just do anything if we really change the category |
200 | if ( intCat != m_curr_category ){ | 210 | if ( intCat != m_curr_category ){ |
201 | // odebug << "Categories: Selected " << cat << ".. Number: " | 211 | // odebug << "Categories: Selected " << cat << ".. Number: " |
202 | // << m_curr_category << oendl; | 212 | // << m_curr_category << oendl; |
203 | 213 | ||
204 | m_curr_category = intCat; | 214 | m_curr_category = intCat; |
205 | emit signalClearLetterPicker(); | 215 | emit signalClearLetterPicker(); |
206 | load(); | 216 | load(); |
207 | } | 217 | } |
208 | m_curr_category = intCat; | 218 | m_curr_category = intCat; |
209 | 219 | ||
210 | } | 220 | } |
211 | 221 | ||
212 | void AbView::setShowToView( Views view ) | 222 | void AbView::setShowToView( Views view ) |
213 | { | 223 | { |
214 | odebug << "void AbView::setShowToView( View " << view << " )" << oendl; | 224 | odebug << "void AbView::setShowToView( View " << view << " )" << oendl; |
215 | 225 | ||
216 | if ( m_curr_View != view ){ | 226 | if ( m_curr_View != view ){ |
217 | odebug << "Change the View (Category is: " << m_curr_category << ")" << oendl; | 227 | odebug << "Change the View (Category is: " << m_curr_category << ")" << oendl; |
218 | m_prev_View = m_curr_View; | 228 | m_prev_View = m_curr_View; |
219 | m_curr_View = view; | 229 | m_curr_View = view; |
220 | 230 | ||
221 | updateView(); | 231 | updateView(); |
222 | } | 232 | } |
223 | 233 | ||
224 | } | 234 | } |
225 | 235 | ||
226 | void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) | 236 | void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) |
227 | { | 237 | { |
228 | odebug << "void AbView::setShowByLetter( " << c << ", " << mode << " )" << oendl; | 238 | odebug << "void AbView::setShowByLetter( " << c << ", " << mode << " )" << oendl; |
229 | 239 | ||
230 | assert( mode < AbConfig::LASTELEMENT ); | 240 | assert( mode < AbConfig::LASTELEMENT ); |
231 | 241 | ||
232 | Opie::OPimContact query; | 242 | Opie::OPimContact query; |
233 | if ( c == 0 ){ | 243 | if ( c == 0 ){ |
234 | load(); | 244 | load(); |
235 | return; | 245 | return; |
236 | }else{ | 246 | }else{ |
237 | // If the current Backend is unable to solve the query, we will | 247 | // If the current Backend is unable to solve the query, we will |
238 | // ignore the request .. | 248 | // ignore the request .. |
239 | if ( ! m_contactdb->hasQuerySettings( Opie::OPimContactAccess::WildCards | | 249 | if ( ! m_contactdb->hasQuerySettings( Opie::OPimContactAccess::WildCards | |
240 | Opie::OPimContactAccess::IgnoreCase ) ){ | 250 | Opie::OPimContactAccess::IgnoreCase ) ){ |
241 | owarn << "Tried to access queryByExample which is not supported by the current backend!!" << oendl; | 251 | owarn << "Tried to access queryByExample which is not supported by the current backend!!" << oendl; |
242 | owarn << "I have to ignore this access!" << oendl; | 252 | owarn << "I have to ignore this access!" << oendl; |
243 | return; | 253 | return; |
244 | } | 254 | } |
245 | 255 | ||
246 | switch( mode ){ | 256 | switch( mode ){ |
247 | case AbConfig::LastName: | 257 | case AbConfig::LastName: |
248 | query.setLastName( QString("%1*").arg(c) ); | 258 | query.setLastName( QString("%1*").arg(c) ); |
249 | break; | 259 | break; |
250 | case AbConfig::FileAs: | 260 | case AbConfig::FileAs: |
251 | query.setFileAs( QString("%1*").arg(c) ); | 261 | query.setFileAs( QString("%1*").arg(c) ); |
252 | break; | 262 | break; |
253 | default: | 263 | default: |
254 | owarn << "Unknown Searchmode for AbView::setShowByLetter ! -> " << mode << oendl | 264 | owarn << "Unknown Searchmode for AbView::setShowByLetter ! -> " << mode << oendl |
255 | << "I will ignore it.." << oendl; | 265 | << "I will ignore it.." << oendl; |
256 | return; | 266 | return; |
257 | } | 267 | } |
258 | m_list = m_contactdb->queryByExample( query, Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase ); | 268 | m_list = m_contactdb->queryByExample( query, Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase ); |
259 | 269 | ||
260 | if ( m_curr_category != 0 ) | 270 | if ( m_curr_category != 0 ) |