author | eilers <eilers> | 2002-10-19 17:54:00 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-10-19 17:54:00 (UTC) |
commit | 8c9e2e893540c0a405637f10ac2f656df69991a7 (patch) (unidiff) | |
tree | ec9841bdd08c95ef1dc4e1a239d7736e760c2a46 | |
parent | ccdf857edfb52f788c5b00440cce24d1bced2a18 (diff) | |
download | opie-8c9e2e893540c0a405637f10ac2f656df69991a7.zip opie-8c9e2e893540c0a405637f10ac2f656df69991a7.tar.gz opie-8c9e2e893540c0a405637f10ac2f656df69991a7.tar.bz2 |
New find widget works. Settings moved into a config dialog.
-rw-r--r-- | core/pim/addressbook/TODO | 4 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 18 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.h | 2 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 75 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.h | 6 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.pro | 9 | ||||
-rw-r--r-- | core/pim/addressbook/configdlg.cpp | 45 | ||||
-rw-r--r-- | core/pim/addressbook/configdlg.h | 25 | ||||
-rw-r--r-- | core/pim/addressbook/configdlg_base.ui | 232 | ||||
-rw-r--r-- | core/pim/addressbook/ofloatbar.h | 2 |
10 files changed, 381 insertions, 37 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO index d8720b3..0accd87 100644 --- a/core/pim/addressbook/TODO +++ b/core/pim/addressbook/TODO | |||
@@ -1,29 +1,31 @@ | |||
1 | Stuff todo: | 1 | Stuff todo: |
2 | 2 | ||
3 | Urgent: | 3 | Urgent: |
4 | 4 | ||
5 | - Font menu is invisible using german translation | 5 | - Font menu is invisible using german translation |
6 | 6 | ||
7 | Important: | 7 | Important: |
8 | 8 | ||
9 | - Finishing of new View functions (List, Phonebook...) | 9 | - Finishing of new View functions (List, Phonebook...) |
10 | - Reload if contacts were changed externally | 10 | - Reload if contacts were changed externally |
11 | - "What's this" should be added | 11 | - "What's this" should be added |
12 | - The names of the countries are sorted by there english names, only.. | 12 | - The names of the countries are sorted by there english names, only.. |
13 | Even if they are translated.. :S | 13 | Even if they are translated.. :S |
14 | - Store last settings of combo-boxes | 14 | - Store last settings of combo-boxes |
15 | - Mail-Icon is missing | 15 | - Mail-Icon is missing |
16 | 16 | ||
17 | Less important: | 17 | Less important: |
18 | 18 | ||
19 | - Find widget should be replaced by something like | 19 | - Find widget should be replaced by something like |
20 | qpdf has. | 20 | qpdf has. |
21 | - The picker (alphabetical sort widget) should be | 21 | - The picker (alphabetical sort widget) should be |
22 | placed verticaly or horizontally (configurable) | 22 | placed verticaly or horizontally (configurable) |
23 | 23 | - Use advanced database functions in abtable to decrease | |
24 | memory footprint and to make everything more easy ! | ||
25 | (abtable should store Iterator for selected Category) | ||
24 | 26 | ||
25 | Should be Fixed (not absolute sure, need validation): | 27 | Should be Fixed (not absolute sure, need validation): |
26 | - "Nonenglish" translation bug has to be fixed. | 28 | - "Nonenglish" translation bug has to be fixed. |
27 | 29 | ||
28 | Fixed: | 30 | Fixed: |
29 | - Syncing: abtable not reloaded after sync. | 31 | - Syncing: abtable not reloaded after sync. |
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 9297d6a..97f4a8f 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -1,323 +1,323 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
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 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_CONTACT_MRE | 21 | #define QTOPIA_INTERNAL_CONTACT_MRE |
22 | 22 | ||
23 | #include <qpe/categoryselect.h> | 23 | #include <qpe/categoryselect.h> |
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | #include <qpe/stringutil.h> | 25 | #include <qpe/stringutil.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | 27 | ||
28 | #include <opie/orecordlist.h> | 28 | #include <opie/orecordlist.h> |
29 | 29 | ||
30 | #include <qasciidict.h> | 30 | #include <qasciidict.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qregexp.h> | 33 | #include <qregexp.h> |
34 | #include <qmessagebox.h> | 34 | #include <qmessagebox.h> |
35 | 35 | ||
36 | #include "abtable.h" | 36 | #include "abtable.h" |
37 | 37 | ||
38 | #include <errno.h> | 38 | #include <errno.h> |
39 | #include <fcntl.h> | 39 | #include <fcntl.h> |
40 | #include <unistd.h> | 40 | #include <unistd.h> |
41 | #include <stdlib.h> | 41 | #include <stdlib.h> |
42 | 42 | ||
43 | #include <ctype.h> //toupper() for key hack | 43 | #include <ctype.h> //toupper() for key hack |
44 | 44 | ||
45 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ); | 45 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ); |
46 | 46 | ||
47 | 47 | ||
48 | /*! | 48 | /*! |
49 | \class AbTableItem abtable.h | 49 | \class AbTableItem abtable.h |
50 | 50 | ||
51 | \brief QTableItem based class for showing a field of an entry | 51 | \brief QTableItem based class for showing a field of an entry |
52 | */ | 52 | */ |
53 | 53 | ||
54 | AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, | 54 | AbTableItem::AbTableItem( QTable *t, EditType et, const QString &s, |
55 | const QString &secondSortKey) | 55 | const QString &secondSortKey) |
56 | : QTableItem( t, et, s ) | 56 | : QTableItem( t, et, s ) |
57 | { | 57 | { |
58 | // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); | 58 | // sortKey = s.lower() + QChar( '\0' ) + secondSortKey.lower(); |
59 | sortKey = Qtopia::buildSortKey( s, secondSortKey ); | 59 | sortKey = Qtopia::buildSortKey( s, secondSortKey ); |
60 | } | 60 | } |
61 | 61 | ||
62 | int AbTableItem::alignment() const | 62 | int AbTableItem::alignment() const |
63 | { | 63 | { |
64 | return AlignLeft|AlignVCenter; | 64 | return AlignLeft|AlignVCenter; |
65 | } | 65 | } |
66 | 66 | ||
67 | QString AbTableItem::key() const | 67 | QString AbTableItem::key() const |
68 | { | 68 | { |
69 | return sortKey; | 69 | return sortKey; |
70 | } | 70 | } |
71 | 71 | ||
72 | // A way to reset the item, without out doing a delete or a new... | 72 | // A way to reset the item, without out doing a delete or a new... |
73 | void AbTableItem::setItem( const QString &txt, const QString &secondKey ) | 73 | void AbTableItem::setItem( const QString &txt, const QString &secondKey ) |
74 | { | 74 | { |
75 | setText( txt ); | 75 | setText( txt ); |
76 | sortKey = Qtopia::buildSortKey( txt, secondKey ); | 76 | sortKey = Qtopia::buildSortKey( txt, secondKey ); |
77 | 77 | ||
78 | // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); | 78 | // sortKey = txt.lower() + QChar( '\0' ) + secondKey.lower(); |
79 | } | 79 | } |
80 | 80 | ||
81 | /*! | 81 | /*! |
82 | \class AbPickItem abtable.h | 82 | \class AbPickItem abtable.h |
83 | 83 | ||
84 | \brief QTableItem based class for showing slection of an entry | 84 | \brief QTableItem based class for showing slection of an entry |
85 | */ | 85 | */ |
86 | 86 | ||
87 | AbPickItem::AbPickItem( QTable *t ) : | 87 | AbPickItem::AbPickItem( QTable *t ) : |
88 | QTableItem(t, WhenCurrent, "?") | 88 | QTableItem(t, WhenCurrent, "?") |
89 | { | 89 | { |
90 | } | 90 | } |
91 | 91 | ||
92 | QWidget *AbPickItem::createEditor() const | 92 | QWidget *AbPickItem::createEditor() const |
93 | { | 93 | { |
94 | QComboBox* combo = new QComboBox( table()->viewport() ); | 94 | QComboBox* combo = new QComboBox( table()->viewport() ); |
95 | ( (AbPickItem*)this )->cb = combo; | 95 | ( (AbPickItem*)this )->cb = combo; |
96 | AbTable* t = static_cast<AbTable*>(table()); | 96 | AbTable* t = static_cast<AbTable*>(table()); |
97 | QStringList c = t->choiceNames(); | 97 | QStringList c = t->choiceNames(); |
98 | int cur = 0; | 98 | int cur = 0; |
99 | for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { | 99 | for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) { |
100 | if ( *it == text() ) | 100 | if ( *it == text() ) |
101 | cur = combo->count(); | 101 | cur = combo->count(); |
102 | combo->insertItem(*it); | 102 | combo->insertItem(*it); |
103 | } | 103 | } |
104 | combo->setCurrentItem(cur); | 104 | combo->setCurrentItem(cur); |
105 | return combo; | 105 | return combo; |
106 | } | 106 | } |
107 | 107 | ||
108 | void AbPickItem::setContentFromEditor( QWidget *w ) | 108 | void AbPickItem::setContentFromEditor( QWidget *w ) |
109 | { | 109 | { |
110 | if ( w->inherits("QComboBox") ) | 110 | if ( w->inherits("QComboBox") ) |
111 | setText( ( (QComboBox*)w )->currentText() ); | 111 | setText( ( (QComboBox*)w )->currentText() ); |
112 | else | 112 | else |
113 | QTableItem::setContentFromEditor( w ); | 113 | QTableItem::setContentFromEditor( w ); |
114 | } | 114 | } |
115 | 115 | ||
116 | /*! | 116 | /*! |
117 | \class AbTable abtable.h | 117 | \class AbTable abtable.h |
118 | 118 | ||
119 | \brief QTable based class for showing a list of entries | 119 | \brief QTable based class for showing a list of entries |
120 | */ | 120 | */ |
121 | 121 | ||
122 | AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name ) | 122 | AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *name ) |
123 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR | 123 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR |
124 | // : QTable( 0, 0, parent, name, TRUE ), | 124 | // : QTable( 0, 0, parent, name, TRUE ), |
125 | // #else | 125 | // #else |
126 | : QTable( parent, name ), | 126 | : QTable( parent, name ), |
127 | // #endif | 127 | // #endif |
128 | lastSortCol( -1 ), | 128 | lastSortCol( -1 ), |
129 | asc( TRUE ), | 129 | asc( TRUE ), |
130 | intFields( order ), | 130 | intFields( order ), |
131 | currFindRow( -2 ), | 131 | currFindRow( -1 ), |
132 | mCat( 0 ), | 132 | mCat( 0 ), |
133 | m_contactdb ("addressbook", 0l, 0l, false) // Handle syncing myself.. ! | 133 | m_contactdb ("addressbook", 0l, 0l, false) // Handle syncing myself.. ! |
134 | { | 134 | { |
135 | mCat.load( categoryFileName() ); | 135 | mCat.load( categoryFileName() ); |
136 | setSelectionMode( NoSelection ); | 136 | setSelectionMode( NoSelection ); |
137 | init(); | 137 | init(); |
138 | setSorting( TRUE ); | 138 | setSorting( TRUE ); |
139 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), | 139 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), |
140 | this, SLOT(itemClicked(int,int)) ); | 140 | this, SLOT(itemClicked(int,int)) ); |
141 | } | 141 | } |
142 | 142 | ||
143 | AbTable::~AbTable() | 143 | AbTable::~AbTable() |
144 | { | 144 | { |
145 | } | 145 | } |
146 | 146 | ||
147 | void AbTable::init() | 147 | void AbTable::init() |
148 | { | 148 | { |
149 | showChar = '\0'; | 149 | showChar = '\0'; |
150 | setNumRows( 0 ); | 150 | setNumRows( 0 ); |
151 | setNumCols( 2 ); | 151 | setNumCols( 2 ); |
152 | 152 | ||
153 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); | 153 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); |
154 | horizontalHeader()->setLabel( 1, tr( "Contact" )); | 154 | horizontalHeader()->setLabel( 1, tr( "Contact" )); |
155 | setLeftMargin( 0 ); | 155 | setLeftMargin( 0 ); |
156 | verticalHeader()->hide(); | 156 | verticalHeader()->hide(); |
157 | columnVisible = true; | 157 | columnVisible = true; |
158 | } | 158 | } |
159 | 159 | ||
160 | void AbTable::columnClicked( int col ) | 160 | void AbTable::columnClicked( int col ) |
161 | { | 161 | { |
162 | if ( !sorting() ) | 162 | if ( !sorting() ) |
163 | return; | 163 | return; |
164 | 164 | ||
165 | if ( lastSortCol == -1 ) | 165 | if ( lastSortCol == -1 ) |
166 | lastSortCol = col; | 166 | lastSortCol = col; |
167 | 167 | ||
168 | if ( col == lastSortCol ) { | 168 | if ( col == lastSortCol ) { |
169 | asc = !asc; | 169 | asc = !asc; |
170 | } else { | 170 | } else { |
171 | lastSortCol = col; | 171 | lastSortCol = col; |
172 | asc = TRUE; | 172 | asc = TRUE; |
173 | } | 173 | } |
174 | //QMessageBox::information( this, "resort", "columnClicked" ); | 174 | //QMessageBox::information( this, "resort", "columnClicked" ); |
175 | resort(); | 175 | resort(); |
176 | } | 176 | } |
177 | 177 | ||
178 | void AbTable::resort() | 178 | void AbTable::resort() |
179 | { | 179 | { |
180 | if ( sorting() ) { | 180 | if ( sorting() ) { |
181 | if ( lastSortCol == -1 ) | 181 | if ( lastSortCol == -1 ) |
182 | lastSortCol = 0; | 182 | lastSortCol = 0; |
183 | sortColumn( lastSortCol, asc, TRUE ); | 183 | sortColumn( lastSortCol, asc, TRUE ); |
184 | //QMessageBox::information( this, "resort", "resort" ); | 184 | //QMessageBox::information( this, "resort", "resort" ); |
185 | updateVisible(); | 185 | updateVisible(); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | OContact AbTable::currentEntry() | 189 | OContact AbTable::currentEntry() |
190 | { | 190 | { |
191 | OContact cnt; | 191 | OContact cnt; |
192 | AbTableItem *abItem; | 192 | AbTableItem *abItem; |
193 | abItem = static_cast<AbTableItem*>(item( currentRow(), 0 )); | 193 | abItem = static_cast<AbTableItem*>(item( currentRow(), 0 )); |
194 | if ( abItem ) { | 194 | if ( abItem ) { |
195 | cnt = contactList[abItem]; | 195 | cnt = contactList[abItem]; |
196 | //cnt = contactList[currentRow()]; | 196 | //cnt = contactList[currentRow()]; |
197 | } | 197 | } |
198 | return cnt; | 198 | return cnt; |
199 | } | 199 | } |
200 | 200 | ||
201 | void AbTable::replaceCurrentEntry( const OContact &newContact ) | 201 | void AbTable::replaceCurrentEntry( const OContact &newContact ) |
202 | { | 202 | { |
203 | int row = currentRow(); | 203 | int row = currentRow(); |
204 | updateVisible(); | 204 | updateVisible(); |
205 | 205 | ||
206 | journalFreeReplace( newContact, row ); | 206 | journalFreeReplace( newContact, row ); |
207 | 207 | ||
208 | } | 208 | } |
209 | 209 | ||
210 | void AbTable::deleteCurrentEntry() | 210 | void AbTable::deleteCurrentEntry() |
211 | { | 211 | { |
212 | int row = currentRow(); | 212 | int row = currentRow(); |
213 | 213 | ||
214 | // a little wasteful, but it ensure's there is only one place | 214 | // a little wasteful, but it ensure's there is only one place |
215 | // where we delete. | 215 | // where we delete. |
216 | journalFreeRemove( row ); | 216 | journalFreeRemove( row ); |
217 | updateVisible(); | 217 | updateVisible(); |
218 | 218 | ||
219 | if ( numRows() == 0 ) | 219 | if ( numRows() == 0 ) |
220 | emit empty( TRUE ); | 220 | emit empty( TRUE ); |
221 | 221 | ||
222 | } | 222 | } |
223 | 223 | ||
224 | void AbTable::clear() | 224 | void AbTable::clear() |
225 | { | 225 | { |
226 | contactList.clear(); | 226 | contactList.clear(); |
227 | for ( int r = 0; r < numRows(); ++r ) { | 227 | for ( int r = 0; r < numRows(); ++r ) { |
228 | for ( int c = 0; c < numCols(); ++c ) { | 228 | for ( int c = 0; c < numCols(); ++c ) { |
229 | if ( cellWidget( r, c ) ) | 229 | if ( cellWidget( r, c ) ) |
230 | clearCellWidget( r, c ); | 230 | clearCellWidget( r, c ); |
231 | clearCell( r, c ); | 231 | clearCell( r, c ); |
232 | } | 232 | } |
233 | } | 233 | } |
234 | setNumRows( 0 ); | 234 | setNumRows( 0 ); |
235 | } | 235 | } |
236 | 236 | ||
237 | void AbTable::refresh() | 237 | void AbTable::refresh() |
238 | { | 238 | { |
239 | int rows = numRows(); | 239 | int rows = numRows(); |
240 | QString value; | 240 | QString value; |
241 | AbTableItem *abi; | 241 | AbTableItem *abi; |
242 | 242 | ||
243 | // hide columns so no flashing ? | 243 | // hide columns so no flashing ? |
244 | if ( showBk == "Cards" ) { | 244 | if ( showBk == "Cards" ) { |
245 | hideColumn(0); | 245 | hideColumn(0); |
246 | hideColumn(1); | 246 | hideColumn(1); |
247 | } | 247 | } |
248 | for ( int r = 0; r < rows; ++r ) { | 248 | for ( int r = 0; r < rows; ++r ) { |
249 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 249 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
250 | value = findContactContact( contactList[abi], r ); | 250 | value = findContactContact( contactList[abi], r ); |
251 | static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); | 251 | static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); |
252 | } | 252 | } |
253 | resort(); | 253 | resort(); |
254 | } | 254 | } |
255 | 255 | ||
256 | void AbTable::keyPressEvent( QKeyEvent *e ) | 256 | void AbTable::keyPressEvent( QKeyEvent *e ) |
257 | { | 257 | { |
258 | char key = toupper( e->ascii() ); | 258 | char key = toupper( e->ascii() ); |
259 | 259 | ||
260 | if ( key >= 'A' && key <= 'Z' ) | 260 | if ( key >= 'A' && key <= 'Z' ) |
261 | moveTo( key ); | 261 | moveTo( key ); |
262 | 262 | ||
263 | switch( e->key() ) { | 263 | switch( e->key() ) { |
264 | case Qt::Key_Space: | 264 | case Qt::Key_Space: |
265 | case Qt::Key_Return: | 265 | case Qt::Key_Return: |
266 | case Qt::Key_Enter: | 266 | case Qt::Key_Enter: |
267 | emit details(); | 267 | emit details(); |
268 | break; | 268 | break; |
269 | default: | 269 | default: |
270 | QTable::keyPressEvent( e ); | 270 | QTable::keyPressEvent( e ); |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
274 | void AbTable::moveTo( char c ) | 274 | void AbTable::moveTo( char c ) |
275 | { | 275 | { |
276 | 276 | ||
277 | int rows = numRows(); | 277 | int rows = numRows(); |
278 | QString value; | 278 | QString value; |
279 | AbTableItem *abi; | 279 | AbTableItem *abi; |
280 | int r; | 280 | int r; |
281 | if ( asc ) { | 281 | if ( asc ) { |
282 | r = 0; | 282 | r = 0; |
283 | while ( r < rows-1) { | 283 | while ( r < rows-1) { |
284 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 284 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
285 | QChar first = abi->key()[0]; | 285 | QChar first = abi->key()[0]; |
286 | //### is there a bug in QChar to char comparison??? | 286 | //### is there a bug in QChar to char comparison??? |
287 | if ( first.row() || first.cell() >= c ) | 287 | if ( first.row() || first.cell() >= c ) |
288 | break; | 288 | break; |
289 | r++; | 289 | r++; |
290 | } | 290 | } |
291 | } else { | 291 | } else { |
292 | //### should probably disable reverse sorting instead | 292 | //### should probably disable reverse sorting instead |
293 | r = rows - 1; | 293 | r = rows - 1; |
294 | while ( r > 0 ) { | 294 | while ( r > 0 ) { |
295 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 295 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
296 | QChar first = abi->key()[0]; | 296 | QChar first = abi->key()[0]; |
297 | //### is there a bug in QChar to char comparison??? | 297 | //### is there a bug in QChar to char comparison??? |
298 | if ( first.row() || first.cell() >= c ) | 298 | if ( first.row() || first.cell() >= c ) |
299 | break; | 299 | break; |
300 | r--; | 300 | r--; |
301 | } | 301 | } |
302 | } | 302 | } |
303 | setCurrentCell( r, currentColumn() ); | 303 | setCurrentCell( r, currentColumn() ); |
304 | } | 304 | } |
305 | 305 | ||
306 | 306 | ||
307 | QString AbTable::findContactName( const OContact &entry ) | 307 | QString AbTable::findContactName( const OContact &entry ) |
308 | { | 308 | { |
309 | // We use the fileAs, then company, defaultEmail | 309 | // We use the fileAs, then company, defaultEmail |
310 | QString str; | 310 | QString str; |
311 | str = entry.fileAs(); | 311 | str = entry.fileAs(); |
312 | if ( str.isEmpty() ) { | 312 | if ( str.isEmpty() ) { |
313 | str = entry.company(); | 313 | str = entry.company(); |
314 | if ( str.isEmpty() ) { | 314 | if ( str.isEmpty() ) { |
315 | str = entry.defaultEmail(); | 315 | str = entry.defaultEmail(); |
316 | } | 316 | } |
317 | } | 317 | } |
318 | return str; | 318 | return str; |
319 | } | 319 | } |
320 | 320 | ||
321 | QString AbTable::findContactContact( const OContact &entry, int /* row */ ) | 321 | QString AbTable::findContactContact( const OContact &entry, int /* row */ ) |
322 | { | 322 | { |
323 | QString value; | 323 | QString value; |
@@ -449,447 +449,449 @@ void AbTable::addEntry( const OContact &newCnt ) | |||
449 | int row = numRows(); | 449 | int row = numRows(); |
450 | 450 | ||
451 | setNumRows( row + 1 ); | 451 | setNumRows( row + 1 ); |
452 | insertIntoTable( newCnt, row ); | 452 | insertIntoTable( newCnt, row ); |
453 | 453 | ||
454 | qWarning("abtable:AddContact"); | 454 | qWarning("abtable:AddContact"); |
455 | m_contactdb.add ( newCnt ); | 455 | m_contactdb.add ( newCnt ); |
456 | 456 | ||
457 | setCurrentCell( row, 0 ); | 457 | setCurrentCell( row, 0 ); |
458 | // updateVisible(); | 458 | // updateVisible(); |
459 | } | 459 | } |
460 | 460 | ||
461 | void AbTable::resizeRows() { | 461 | void AbTable::resizeRows() { |
462 | /* | 462 | /* |
463 | if (numRows()) { | 463 | if (numRows()) { |
464 | for (int i = 0; i < numRows(); i++) { | 464 | for (int i = 0; i < numRows(); i++) { |
465 | setRowHeight( i, size ); | 465 | setRowHeight( i, size ); |
466 | } | 466 | } |
467 | } | 467 | } |
468 | updateVisible(); | 468 | updateVisible(); |
469 | */ | 469 | */ |
470 | } | 470 | } |
471 | 471 | ||
472 | 472 | ||
473 | bool AbTable::save() | 473 | bool AbTable::save() |
474 | { | 474 | { |
475 | // QTime t; | 475 | // QTime t; |
476 | // t.start(); | 476 | // t.start(); |
477 | qWarning("abtable:Save data"); | 477 | qWarning("abtable:Save data"); |
478 | 478 | ||
479 | return m_contactdb.save(); | 479 | return m_contactdb.save(); |
480 | } | 480 | } |
481 | 481 | ||
482 | void AbTable::load() | 482 | void AbTable::load() |
483 | { | 483 | { |
484 | setSorting( false ); | 484 | setSorting( false ); |
485 | setUpdatesEnabled( FALSE ); | 485 | setUpdatesEnabled( FALSE ); |
486 | 486 | ||
487 | qWarning("abtable:Load data"); | 487 | qWarning("abtable:Load data"); |
488 | 488 | ||
489 | OContactAccess::List list = m_contactdb.allRecords(); | 489 | OContactAccess::List list = m_contactdb.allRecords(); |
490 | OContactAccess::List::Iterator it; | 490 | OContactAccess::List::Iterator it; |
491 | setNumRows( list.count() ); | 491 | setNumRows( list.count() ); |
492 | int row = 0; | 492 | int row = 0; |
493 | for ( it = list.begin(); it != list.end(); ++it ) | 493 | for ( it = list.begin(); it != list.end(); ++it ) |
494 | insertIntoTable( *it, row++ ); | 494 | insertIntoTable( *it, row++ ); |
495 | 495 | ||
496 | setUpdatesEnabled( TRUE ); | 496 | setUpdatesEnabled( TRUE ); |
497 | 497 | ||
498 | setSorting( true ); | 498 | setSorting( true ); |
499 | resort(); | 499 | resort(); |
500 | } | 500 | } |
501 | 501 | ||
502 | 502 | ||
503 | void AbTable::reload() | 503 | void AbTable::reload() |
504 | { | 504 | { |
505 | m_contactdb.reload(); | 505 | m_contactdb.reload(); |
506 | load(); | 506 | load(); |
507 | } | 507 | } |
508 | 508 | ||
509 | void AbTable::realignTable( int row ) | 509 | void AbTable::realignTable( int row ) |
510 | { | 510 | { |
511 | QTableItem *ti1, | 511 | QTableItem *ti1, |
512 | *ti2; | 512 | *ti2; |
513 | int totalRows = numRows(); | 513 | int totalRows = numRows(); |
514 | for ( int curr = row; curr < totalRows - 1; curr++ ) { | 514 | for ( int curr = row; curr < totalRows - 1; curr++ ) { |
515 | // the same info from the todo list still applies, but I | 515 | // the same info from the todo list still applies, but I |
516 | // don't think it is _too_ bad. | 516 | // don't think it is _too_ bad. |
517 | ti1 = item( curr + 1, 0 ); | 517 | ti1 = item( curr + 1, 0 ); |
518 | ti2 = item( curr + 1, 1 ); | 518 | ti2 = item( curr + 1, 1 ); |
519 | takeItem( ti1 ); | 519 | takeItem( ti1 ); |
520 | takeItem( ti2 ); | 520 | takeItem( ti2 ); |
521 | setItem( curr, 0, ti1 ); | 521 | setItem( curr, 0, ti1 ); |
522 | setItem( curr, 1, ti2 ); | 522 | setItem( curr, 1, ti2 ); |
523 | } | 523 | } |
524 | setNumRows( totalRows - 1 ); | 524 | setNumRows( totalRows - 1 ); |
525 | resort(); | 525 | resort(); |
526 | } | 526 | } |
527 | 527 | ||
528 | // Add contact into table. | 528 | // Add contact into table. |
529 | void AbTable::insertIntoTable( const OContact &cnt, int row ) | 529 | void AbTable::insertIntoTable( const OContact &cnt, int row ) |
530 | { | 530 | { |
531 | QString strName, | 531 | QString strName, |
532 | strContact; | 532 | strContact; |
533 | 533 | ||
534 | strName = findContactName( cnt ); | 534 | strName = findContactName( cnt ); |
535 | strContact = findContactContact( cnt, row ); | 535 | strContact = findContactContact( cnt, row ); |
536 | 536 | ||
537 | AbTableItem *ati; | 537 | AbTableItem *ati; |
538 | ati = new AbTableItem( this, QTableItem::Never, strName, strContact); | 538 | ati = new AbTableItem( this, QTableItem::Never, strName, strContact); |
539 | contactList.insert( ati, cnt ); | 539 | contactList.insert( ati, cnt ); |
540 | setItem( row, 0, ati ); | 540 | setItem( row, 0, ati ); |
541 | ati = new AbTableItem( this, QTableItem::Never, strContact, strName); | 541 | ati = new AbTableItem( this, QTableItem::Never, strContact, strName); |
542 | setItem( row, 1, ati ); | 542 | setItem( row, 1, ati ); |
543 | 543 | ||
544 | //### cannot do this; table only has two columns at this point | 544 | //### cannot do this; table only has two columns at this point |
545 | // setItem( row, 2, new AbPickItem( this ) ); | 545 | // setItem( row, 2, new AbPickItem( this ) ); |
546 | 546 | ||
547 | // resort at some point? | 547 | // resort at some point? |
548 | } | 548 | } |
549 | 549 | ||
550 | 550 | ||
551 | // Replace or add an entry | 551 | // Replace or add an entry |
552 | void AbTable::journalFreeReplace( const OContact &cnt, int row ) | 552 | void AbTable::journalFreeReplace( const OContact &cnt, int row ) |
553 | { | 553 | { |
554 | QString strName, | 554 | QString strName, |
555 | strContact; | 555 | strContact; |
556 | AbTableItem *ati = 0l; | 556 | AbTableItem *ati = 0l; |
557 | 557 | ||
558 | strName = findContactName( cnt ); | 558 | strName = findContactName( cnt ); |
559 | strContact = findContactContact( cnt, row ); | 559 | strContact = findContactContact( cnt, row ); |
560 | ati = static_cast<AbTableItem*>(item(row, 0)); | 560 | ati = static_cast<AbTableItem*>(item(row, 0)); |
561 | 561 | ||
562 | // Replace element if found in row "row" | 562 | // Replace element if found in row "row" |
563 | // or add this element if not. | 563 | // or add this element if not. |
564 | if ( ati != 0 ) { // replace | 564 | if ( ati != 0 ) { // replace |
565 | // :SX db access -> replace | 565 | // :SX db access -> replace |
566 | qWarning ("Replace Contact in DB ! UID: %d", contactList[ati].uid() ); | 566 | qWarning ("Replace Contact in DB ! UID: %d", contactList[ati].uid() ); |
567 | m_contactdb.replace ( cnt ); | 567 | m_contactdb.replace ( cnt ); |
568 | 568 | ||
569 | contactList.remove( ati ); | 569 | contactList.remove( ati ); |
570 | ati->setItem( strName, strContact ); | 570 | ati->setItem( strName, strContact ); |
571 | contactList.insert( ati, cnt ); | 571 | contactList.insert( ati, cnt ); |
572 | 572 | ||
573 | ati = static_cast<AbTableItem*>(item(row, 1)); | 573 | ati = static_cast<AbTableItem*>(item(row, 1)); |
574 | ati->setItem( strContact, strName ); | 574 | ati->setItem( strContact, strName ); |
575 | 575 | ||
576 | }else{ // add | 576 | }else{ // add |
577 | int myrows = numRows(); | 577 | int myrows = numRows(); |
578 | setNumRows( myrows + 1 ); | 578 | setNumRows( myrows + 1 ); |
579 | insertIntoTable( cnt, myrows ); | 579 | insertIntoTable( cnt, myrows ); |
580 | // gets deleted when returning -- Why ? (se) | 580 | // gets deleted when returning -- Why ? (se) |
581 | // :SX db access -> add | 581 | // :SX db access -> add |
582 | qWarning ("Are you sure to add to database ? -> Currently disabled !!"); | 582 | qWarning ("Are you sure to add to database ? -> Currently disabled !!"); |
583 | // m_contactdb.add( cnt ); | 583 | // m_contactdb.add( cnt ); |
584 | } | 584 | } |
585 | } | 585 | } |
586 | 586 | ||
587 | // Remove entry | 587 | // Remove entry |
588 | void AbTable::journalFreeRemove( int row ) | 588 | void AbTable::journalFreeRemove( int row ) |
589 | { | 589 | { |
590 | AbTableItem *ati; | 590 | AbTableItem *ati; |
591 | ati = static_cast<AbTableItem*>(item(row, 0)); | 591 | ati = static_cast<AbTableItem*>(item(row, 0)); |
592 | if ( !ati ) | 592 | if ( !ati ) |
593 | return; | 593 | return; |
594 | 594 | ||
595 | // :SX db access -> remove | 595 | // :SX db access -> remove |
596 | qWarning ("Remove Contact from DB ! UID: %d",contactList[ati].uid() ); | 596 | qWarning ("Remove Contact from DB ! UID: %d",contactList[ati].uid() ); |
597 | m_contactdb.remove( contactList[ati].uid() ); | 597 | m_contactdb.remove( contactList[ati].uid() ); |
598 | 598 | ||
599 | contactList.remove( ati ); | 599 | contactList.remove( ati ); |
600 | 600 | ||
601 | realignTable( row ); | 601 | realignTable( row ); |
602 | 602 | ||
603 | } | 603 | } |
604 | 604 | ||
605 | #if QT_VERSION <= 230 | 605 | #if QT_VERSION <= 230 |
606 | #ifndef SINGLE_APP | 606 | #ifndef SINGLE_APP |
607 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) | 607 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) |
608 | { | 608 | { |
609 | // Region of the rect we should draw | 609 | // Region of the rect we should draw |
610 | QRegion reg( QRect( cx, cy, cw, ch ) ); | 610 | QRegion reg( QRect( cx, cy, cw, ch ) ); |
611 | // Subtract the table from it | 611 | // Subtract the table from it |
612 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); | 612 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); |
613 | // And draw the rectangles (transformed as needed) | 613 | // And draw the rectangles (transformed as needed) |
614 | QArray<QRect> r = reg.rects(); | 614 | QArray<QRect> r = reg.rects(); |
615 | for (unsigned int i=0; i<r.count(); i++) | 615 | for (unsigned int i=0; i<r.count(); i++) |
616 | p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); | 616 | p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); |
617 | } | 617 | } |
618 | #endif | 618 | #endif |
619 | #endif | 619 | #endif |
620 | 620 | ||
621 | 621 | ||
622 | // int AbTable::rowHeight( int ) const | 622 | // int AbTable::rowHeight( int ) const |
623 | // { | 623 | // { |
624 | // return 18; | 624 | // return 18; |
625 | // } | 625 | // } |
626 | 626 | ||
627 | // int AbTable::rowPos( int row ) const | 627 | // int AbTable::rowPos( int row ) const |
628 | // { | 628 | // { |
629 | // return 18*row; | 629 | // return 18*row; |
630 | // } | 630 | // } |
631 | 631 | ||
632 | // int AbTable::rowAt( int pos ) const | 632 | // int AbTable::rowAt( int pos ) const |
633 | // { | 633 | // { |
634 | // return QMIN( pos/18, numRows()-1 ); | 634 | // return QMIN( pos/18, numRows()-1 ); |
635 | // } | 635 | // } |
636 | 636 | ||
637 | void AbTable::slotDoFind( const QString &findString, bool caseSensitive, | 637 | void AbTable::slotDoFind( const QString &findString, bool caseSensitive, |
638 | bool backwards, QString cat /* int category */ ) | 638 | bool backwards, QString cat /* int category */ ) |
639 | { | 639 | { |
640 | int category = 0; | 640 | int category = 0; |
641 | |||
642 | // Use the current Category if nothing else selected | ||
641 | if ( cat.isEmpty() ) | 643 | if ( cat.isEmpty() ) |
642 | category = -2; // mCat.id("Contacts", "All"); | 644 | category = mCat.id( "Contacts", showCat ); |
643 | else | 645 | else{ |
644 | category = mCat.id("Contacts", cat ); | 646 | category = mCat.id("Contacts", cat ); |
647 | } | ||
645 | 648 | ||
646 | qWarning ("Found in Category %d", category); | 649 | qWarning ("Found in Category %d", category); |
647 | 650 | ||
648 | if ( currFindRow < -1 ) | 651 | if ( currFindRow < -1 ) |
649 | currFindRow = currentRow() - 1; | 652 | currFindRow = - 1; |
653 | |||
650 | clearSelection( TRUE ); | 654 | clearSelection( TRUE ); |
651 | int rows, row; | 655 | int rows, row; |
652 | AbTableItem *ati; | 656 | AbTableItem *ati; |
653 | QRegExp r( findString ); | 657 | QRegExp r( findString ); |
654 | r.setCaseSensitive( caseSensitive ); | 658 | r.setCaseSensitive( caseSensitive ); |
655 | rows = numRows(); | 659 | rows = numRows(); |
656 | static bool wrapAround = true; | 660 | static bool wrapAround = true; |
657 | 661 | ||
658 | if ( !backwards ) { | 662 | if ( !backwards ) { |
659 | for ( row = currFindRow + 1; row < rows; row++ ) { | 663 | for ( row = currFindRow + 1; row < rows; row++ ) { |
660 | ati = static_cast<AbTableItem*>( item(row, 0) ); | 664 | ati = static_cast<AbTableItem*>( item(row, 0) ); |
661 | if ( contactCompare( contactList[ati], r, category ) ) | 665 | if ( contactCompare( contactList[ati], r, category ) ) |
662 | //if ( contactCompare( contactList[row], r, category ) ) | ||
663 | break; | 666 | break; |
664 | } | 667 | } |
665 | } else { | 668 | } else { |
666 | for ( row = currFindRow - 1; row > -1; row-- ) { | 669 | for ( row = currFindRow - 1; row > -1; row-- ) { |
667 | ati = static_cast<AbTableItem*>( item(row, 0) ); | 670 | ati = static_cast<AbTableItem*>( item(row, 0) ); |
668 | if ( contactCompare( contactList[ati], r, category ) ) | 671 | if ( contactCompare( contactList[ati], r, category ) ) |
669 | //if ( contactCompare( contactList[row], r, category ) ) | ||
670 | break; | 672 | break; |
671 | } | 673 | } |
672 | } | 674 | } |
673 | if ( row >= rows || row < 0 ) { | 675 | if ( row >= rows || row < 0 ) { |
674 | if ( row < 0 ) | 676 | if ( row < 0 ) |
675 | currFindRow = rows; | 677 | currFindRow = rows; |
676 | else | 678 | else |
677 | currFindRow = -1; | 679 | currFindRow = -1; |
678 | 680 | ||
679 | if ( wrapAround ) | 681 | if ( wrapAround ) |
680 | emit signalWrapAround(); | 682 | emit signalWrapAround(); |
681 | else | 683 | else |
682 | emit signalNotFound(); | 684 | emit signalNotFound(); |
683 | 685 | ||
684 | wrapAround = !wrapAround; | 686 | wrapAround = !wrapAround; |
685 | } else { | 687 | } else { |
686 | currFindRow = row; | 688 | currFindRow = row; |
687 | QTableSelection foundSelection; | 689 | QTableSelection foundSelection; |
688 | foundSelection.init( currFindRow, 0 ); | 690 | foundSelection.init( currFindRow, 0 ); |
689 | foundSelection.expandTo( currFindRow, numCols() - 1 ); | 691 | foundSelection.expandTo( currFindRow, numCols() - 1 ); |
690 | addSelection( foundSelection ); | 692 | addSelection( foundSelection ); |
691 | setCurrentCell( currFindRow, numCols() - 1 ); | 693 | setCurrentCell( currFindRow, 0 /* numCols() - 1 */ ); |
692 | wrapAround = true; | 694 | wrapAround = true; |
693 | } | 695 | } |
694 | } | 696 | } |
695 | 697 | ||
696 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) | 698 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) |
697 | { | 699 | { |
698 | bool returnMe; | 700 | bool returnMe; |
699 | QArray<int> cats; | 701 | QArray<int> cats; |
700 | cats = cnt.categories(); | 702 | cats = cnt.categories(); |
701 | 703 | ||
702 | returnMe = false; | 704 | returnMe = false; |
703 | if ( (category == -1 && cats.count() == 0) || category == -2 ) | 705 | if ( (cats.count() == 0) || (category == 0) ) |
704 | returnMe = cnt.match( r ); | 706 | returnMe = cnt.match( r ); |
705 | else { | 707 | else { |
706 | int i; | 708 | int i; |
707 | for ( i = 0; i < int(cats.count()); i++ ) { | 709 | for ( i = 0; i < int(cats.count()); i++ ) { |
708 | if ( cats[i] == category ) { | 710 | if ( cats[i] == category ) { |
709 | returnMe = cnt.match( r ); | 711 | returnMe = cnt.match( r ); |
710 | break; | 712 | break; |
711 | } | 713 | } |
712 | } | 714 | } |
713 | } | 715 | } |
714 | 716 | ||
715 | return returnMe; | 717 | return returnMe; |
716 | } | 718 | } |
717 | 719 | ||
718 | void AbTable::fitColumns() | 720 | void AbTable::fitColumns() |
719 | { | 721 | { |
720 | int contentsWidth = visibleWidth() / 2; | 722 | int contentsWidth = visibleWidth() / 2; |
721 | 723 | ||
722 | if ( showBk == "Cards" ) { | 724 | if ( showBk == "Cards" ) { |
723 | showColumn(1); | 725 | showColumn(1); |
724 | //adjustColumn(1); | 726 | //adjustColumn(1); |
725 | setColumnWidth( 1, visibleWidth() ); | 727 | setColumnWidth( 1, visibleWidth() ); |
726 | columnVisible = false; | 728 | columnVisible = false; |
727 | } else { | 729 | } else { |
728 | if ( columnVisible == false ){ | 730 | if ( columnVisible == false ){ |
729 | showColumn(0); | 731 | showColumn(0); |
730 | columnVisible = true; | 732 | columnVisible = true; |
731 | } | 733 | } |
732 | setColumnWidth( 0, contentsWidth ); | 734 | setColumnWidth( 0, contentsWidth ); |
733 | adjustColumn(1); | 735 | adjustColumn(1); |
734 | if ( columnWidth(1) < contentsWidth ) | 736 | if ( columnWidth(1) < contentsWidth ) |
735 | setColumnWidth( 1, contentsWidth ); | 737 | setColumnWidth( 1, contentsWidth ); |
736 | } | 738 | } |
737 | } | 739 | } |
738 | 740 | ||
739 | void AbTable::show() | 741 | void AbTable::show() |
740 | { | 742 | { |
741 | fitColumns(); | 743 | fitColumns(); |
742 | QTable::show(); | 744 | QTable::show(); |
743 | } | 745 | } |
744 | 746 | ||
745 | void AbTable::setChoiceNames( const QStringList& list) | 747 | void AbTable::setChoiceNames( const QStringList& list) |
746 | { | 748 | { |
747 | choicenames = list; | 749 | choicenames = list; |
748 | if ( choicenames.isEmpty() ) { | 750 | if ( choicenames.isEmpty() ) { |
749 | // hide pick column | 751 | // hide pick column |
750 | setNumCols( 2 ); | 752 | setNumCols( 2 ); |
751 | } else { | 753 | } else { |
752 | // show pick column | 754 | // show pick column |
753 | setNumCols( 3 ); | 755 | setNumCols( 3 ); |
754 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); | 756 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); |
755 | horizontalHeader()->setLabel( 2, tr( "Pick" )); | 757 | horizontalHeader()->setLabel( 2, tr( "Pick" )); |
756 | } | 758 | } |
757 | fitColumns(); | 759 | fitColumns(); |
758 | } | 760 | } |
759 | 761 | ||
760 | void AbTable::itemClicked(int,int col) | 762 | void AbTable::itemClicked(int,int col) |
761 | { | 763 | { |
762 | if ( col == 2 ) { | 764 | if ( col == 2 ) { |
763 | return; | 765 | return; |
764 | } else { | 766 | } else { |
765 | emit details(); | 767 | emit details(); |
766 | } | 768 | } |
767 | } | 769 | } |
768 | 770 | ||
769 | QStringList AbTable::choiceNames() const | 771 | QStringList AbTable::choiceNames() const |
770 | { | 772 | { |
771 | return choicenames; | 773 | return choicenames; |
772 | } | 774 | } |
773 | 775 | ||
774 | void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/) | 776 | void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/) |
775 | { | 777 | { |
776 | /* ###### | 778 | /* ###### |
777 | 779 | ||
778 | QString selname = choicenames.at(index); | 780 | QString selname = choicenames.at(index); |
779 | for (each row) { | 781 | for (each row) { |
780 | OContact *c = contactForRow(row); | 782 | OContact *c = contactForRow(row); |
781 | if ( list.contains(c->email) ) { | 783 | if ( list.contains(c->email) ) { |
782 | list.remove(c->email); | 784 | list.remove(c->email); |
783 | setText(row, 2, selname); | 785 | setText(row, 2, selname); |
784 | } | 786 | } |
785 | } | 787 | } |
786 | for (remaining list items) { | 788 | for (remaining list items) { |
787 | OContact *c = new contact(item); | 789 | OContact *c = new contact(item); |
788 | setText(newrow, 2, selname); | 790 | setText(newrow, 2, selname); |
789 | } | 791 | } |
790 | 792 | ||
791 | */ | 793 | */ |
792 | } | 794 | } |
793 | 795 | ||
794 | QStringList AbTable::choiceSelection(int /*index*/) const | 796 | QStringList AbTable::choiceSelection(int /*index*/) const |
795 | { | 797 | { |
796 | QStringList r; | 798 | QStringList r; |
797 | /* ###### | 799 | /* ###### |
798 | 800 | ||
799 | QString selname = choicenames.at(index); | 801 | QString selname = choicenames.at(index); |
800 | for (each row) { | 802 | for (each row) { |
801 | OContact *c = contactForRow(row); | 803 | OContact *c = contactForRow(row); |
802 | if ( text(row,2) == selname ) { | 804 | if ( text(row,2) == selname ) { |
803 | r.append(c->email); | 805 | r.append(c->email); |
804 | } | 806 | } |
805 | } | 807 | } |
806 | 808 | ||
807 | */ | 809 | */ |
808 | return r; | 810 | return r; |
809 | } | 811 | } |
810 | 812 | ||
811 | void AbTable::setShowCategory( const QString &b, const QString &c ) | 813 | void AbTable::setShowCategory( const QString &b, const QString &c ) |
812 | { | 814 | { |
813 | showBk = b; | 815 | showBk = b; |
814 | showCat = c; | 816 | showCat = c; |
815 | //QMessageBox::information( this, "setShowCategory", "setShowCategory" ); | 817 | //QMessageBox::information( this, "setShowCategory", "setShowCategory" ); |
816 | //updateVisible(); | 818 | //updateVisible(); |
817 | refresh(); | 819 | refresh(); |
818 | ensureCellVisible( currentRow(), 0 ); | 820 | ensureCellVisible( currentRow(), 0 ); |
819 | updateVisible(); // :SX | 821 | updateVisible(); // :SX |
820 | } | 822 | } |
821 | 823 | ||
822 | void AbTable::setShowByLetter( char c ) | 824 | void AbTable::setShowByLetter( char c ) |
823 | { | 825 | { |
824 | showChar = tolower(c); | 826 | showChar = tolower(c); |
825 | updateVisible(); | 827 | updateVisible(); |
826 | } | 828 | } |
827 | 829 | ||
828 | QString AbTable::showCategory() const | 830 | QString AbTable::showCategory() const |
829 | { | 831 | { |
830 | return showCat; | 832 | return showCat; |
831 | } | 833 | } |
832 | 834 | ||
833 | QString AbTable::showBook() const | 835 | QString AbTable::showBook() const |
834 | { | 836 | { |
835 | return showBk; | 837 | return showBk; |
836 | } | 838 | } |
837 | 839 | ||
838 | QStringList AbTable::categories() | 840 | QStringList AbTable::categories() |
839 | { | 841 | { |
840 | mCat.load( categoryFileName() ); | 842 | mCat.load( categoryFileName() ); |
841 | QStringList categoryList = mCat.labels( "Contacts" ); | 843 | QStringList categoryList = mCat.labels( "Contacts" ); |
842 | return categoryList; | 844 | return categoryList; |
843 | } | 845 | } |
844 | 846 | ||
845 | void AbTable::updateVisible() | 847 | void AbTable::updateVisible() |
846 | { | 848 | { |
847 | int visible, | 849 | int visible, |
848 | totalRows, | 850 | totalRows, |
849 | id, | 851 | id, |
850 | totalCats, | 852 | totalCats, |
851 | it, | 853 | it, |
852 | row; | 854 | row; |
853 | bool hide; | 855 | bool hide; |
854 | AbTableItem *ati; | 856 | AbTableItem *ati; |
855 | OContact *cnt; | 857 | OContact *cnt; |
856 | QString fileAsName; | 858 | QString fileAsName; |
857 | QString tmpStr; | 859 | QString tmpStr; |
858 | visible = 0; | 860 | visible = 0; |
859 | 861 | ||
860 | setPaintingEnabled( FALSE ); | 862 | setPaintingEnabled( FALSE ); |
861 | 863 | ||
862 | totalRows = numRows(); | 864 | totalRows = numRows(); |
863 | id = mCat.id( "Contacts", showCat ); | 865 | id = mCat.id( "Contacts", showCat ); |
864 | QArray<int> cats; | 866 | QArray<int> cats; |
865 | for ( row = 0; row < totalRows; row++ ) { | 867 | for ( row = 0; row < totalRows; row++ ) { |
866 | ati = static_cast<AbTableItem*>( item(row, 0) ); | 868 | ati = static_cast<AbTableItem*>( item(row, 0) ); |
867 | cnt = &contactList[ati]; | 869 | cnt = &contactList[ati]; |
868 | cats = cnt->categories(); | 870 | cats = cnt->categories(); |
869 | fileAsName = cnt->fileAs(); | 871 | fileAsName = cnt->fileAs(); |
870 | hide = false; | 872 | hide = false; |
871 | if ( !showCat.isEmpty() ) { | 873 | if ( !showCat.isEmpty() ) { |
872 | if ( showCat == tr( "Unfiled" ) ) { | 874 | if ( showCat == tr( "Unfiled" ) ) { |
873 | if ( cats.count() > 0 ) | 875 | if ( cats.count() > 0 ) |
874 | hide = true; | 876 | hide = true; |
875 | } else { | 877 | } else { |
876 | // do some comparing | 878 | // do some comparing |
877 | if ( !hide ) { | 879 | if ( !hide ) { |
878 | hide = true; | 880 | hide = true; |
879 | totalCats = int(cats.count()); | 881 | totalCats = int(cats.count()); |
880 | for ( it = 0; it < totalCats; it++ ) { | 882 | for ( it = 0; it < totalCats; it++ ) { |
881 | if ( cats[it] == id ) { | 883 | if ( cats[it] == id ) { |
882 | hide = false; | 884 | hide = false; |
883 | break; | 885 | break; |
884 | } | 886 | } |
885 | } | 887 | } |
886 | } | 888 | } |
887 | } | 889 | } |
888 | } | 890 | } |
889 | if ( showChar != '\0' ) { | 891 | if ( showChar != '\0' ) { |
890 | tmpStr = fileAsName.left(1); | 892 | tmpStr = fileAsName.left(1); |
891 | tmpStr = tmpStr.lower(); | 893 | tmpStr = tmpStr.lower(); |
892 | if ( tmpStr != QString(QChar(showChar)) && showChar != '#' ) { | 894 | if ( tmpStr != QString(QChar(showChar)) && showChar != '#' ) { |
893 | hide = true; | 895 | hide = true; |
894 | } | 896 | } |
895 | if ( showChar == '#' ) { | 897 | if ( showChar == '#' ) { |
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h index a603e17..1039e66 100644 --- a/core/pim/addressbook/abtable.h +++ b/core/pim/addressbook/abtable.h | |||
@@ -1,154 +1,154 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
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 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef ABTABLE_H | 21 | #ifndef ABTABLE_H |
22 | #define ABTABLE_H | 22 | #define ABTABLE_H |
23 | 23 | ||
24 | #include <qpe/categories.h> | 24 | #include <qpe/categories.h> |
25 | #include <opie/ocontact.h> | 25 | #include <opie/ocontact.h> |
26 | 26 | ||
27 | #include <qmap.h> | 27 | #include <qmap.h> |
28 | #include <qtable.h> | 28 | #include <qtable.h> |
29 | #include <qstringlist.h> | 29 | #include <qstringlist.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | 31 | ||
32 | #include <opie/ocontactaccess.h> | 32 | #include <opie/ocontactaccess.h> |
33 | 33 | ||
34 | class AbTableItem : public QTableItem | 34 | class AbTableItem : public QTableItem |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | AbTableItem( QTable *t, EditType et, const QString &s, | 37 | AbTableItem( QTable *t, EditType et, const QString &s, |
38 | const QString &secondSortKey); | 38 | const QString &secondSortKey); |
39 | QString entryKey() const; | 39 | QString entryKey() const; |
40 | void setEntryKey( const QString & k ); | 40 | void setEntryKey( const QString & k ); |
41 | virtual int alignment() const; | 41 | virtual int alignment() const; |
42 | virtual QString key() const; | 42 | virtual QString key() const; |
43 | void setItem( const QString &txt, const QString &secondKey ); | 43 | void setItem( const QString &txt, const QString &secondKey ); |
44 | 44 | ||
45 | private: | 45 | private: |
46 | QString sortKey; | 46 | QString sortKey; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | class AbPickItem : public QTableItem | 49 | class AbPickItem : public QTableItem |
50 | { | 50 | { |
51 | public: | 51 | public: |
52 | AbPickItem( QTable *t ); | 52 | AbPickItem( QTable *t ); |
53 | 53 | ||
54 | QWidget *createEditor() const; | 54 | QWidget *createEditor() const; |
55 | void setContentFromEditor( QWidget *w ); | 55 | void setContentFromEditor( QWidget *w ); |
56 | 56 | ||
57 | private: | 57 | private: |
58 | QGuardedPtr<QComboBox> cb; | 58 | QGuardedPtr<QComboBox> cb; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | class AbTable : public QTable | 61 | class AbTable : public QTable |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | 64 | ||
65 | public: | 65 | public: |
66 | AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 ); | 66 | AbTable( const QValueList<int> *ordered, QWidget *parent, const char *name=0 ); |
67 | ~AbTable(); | 67 | ~AbTable(); |
68 | // NEW | 68 | // NEW |
69 | void addEntry( const OContact &newContact ); | 69 | void addEntry( const OContact &newContact ); |
70 | OContact currentEntry(); | 70 | OContact currentEntry(); |
71 | void replaceCurrentEntry( const OContact &newContact ); | 71 | void replaceCurrentEntry( const OContact &newContact ); |
72 | 72 | ||
73 | void init(); | 73 | void init(); |
74 | 74 | ||
75 | void deleteCurrentEntry(); | 75 | void deleteCurrentEntry(); |
76 | void clear(); | 76 | void clear(); |
77 | void clearFindRow() { currFindRow = -2; } | 77 | void clearFindRow() { currFindRow = -1; } |
78 | void loadFields(); | 78 | void loadFields(); |
79 | void refresh(); | 79 | void refresh(); |
80 | bool save(); | 80 | bool save(); |
81 | void load(); | 81 | void load(); |
82 | void reload(); | 82 | void reload(); |
83 | 83 | ||
84 | // addresspicker mode | 84 | // addresspicker mode |
85 | void setChoiceNames( const QStringList& list); | 85 | void setChoiceNames( const QStringList& list); |
86 | QStringList choiceNames() const; | 86 | QStringList choiceNames() const; |
87 | void setChoiceSelection(int index, const QStringList& list); | 87 | void setChoiceSelection(int index, const QStringList& list); |
88 | QStringList choiceSelection(int index) const; | 88 | QStringList choiceSelection(int index) const; |
89 | void setShowCategory( const QString &b, const QString &c ); | 89 | void setShowCategory( const QString &b, const QString &c ); |
90 | void setShowByLetter( char c ); | 90 | void setShowByLetter( char c ); |
91 | QString showCategory() const; | 91 | QString showCategory() const; |
92 | QStringList categories(); | 92 | QStringList categories(); |
93 | 93 | ||
94 | void resizeRows(); | 94 | void resizeRows(); |
95 | 95 | ||
96 | void show(); | 96 | void show(); |
97 | void setPaintingEnabled( bool e ); | 97 | void setPaintingEnabled( bool e ); |
98 | 98 | ||
99 | QString showBook() const; | 99 | QString showBook() const; |
100 | 100 | ||
101 | public slots: | 101 | public slots: |
102 | void slotDoFind( const QString &str, bool caseSensitive, bool backwards, | 102 | void slotDoFind( const QString &str, bool caseSensitive, bool backwards, |
103 | QString category = QString::null ); | 103 | QString category = QString::null ); |
104 | signals: | 104 | signals: |
105 | void empty( bool ); | 105 | void empty( bool ); |
106 | void details(); | 106 | void details(); |
107 | void signalNotFound(); | 107 | void signalNotFound(); |
108 | void signalWrapAround(); | 108 | void signalWrapAround(); |
109 | 109 | ||
110 | protected: | 110 | protected: |
111 | virtual void keyPressEvent( QKeyEvent *e ); | 111 | virtual void keyPressEvent( QKeyEvent *e ); |
112 | 112 | ||
113 | // int rowHeight( int ) const; | 113 | // int rowHeight( int ) const; |
114 | // int rowPos( int row ) const; | 114 | // int rowPos( int row ) const; |
115 | // virtual int rowAt( int pos ) const; | 115 | // virtual int rowAt( int pos ) const; |
116 | 116 | ||
117 | 117 | ||
118 | protected slots: | 118 | protected slots: |
119 | void moveTo( char ); | 119 | void moveTo( char ); |
120 | virtual void columnClicked( int col ); | 120 | virtual void columnClicked( int col ); |
121 | void itemClicked(int,int col); | 121 | void itemClicked(int,int col); |
122 | void rowHeightChanged( int row ); | 122 | void rowHeightChanged( int row ); |
123 | 123 | ||
124 | private: | 124 | private: |
125 | void loadFile( const QString &strFile, bool journalFile ); | 125 | void loadFile( const QString &strFile, bool journalFile ); |
126 | void fitColumns(); | 126 | void fitColumns(); |
127 | void resort(); | 127 | void resort(); |
128 | void updateJournal( const OContact &contact, OContact::journal_action action, | 128 | void updateJournal( const OContact &contact, OContact::journal_action action, |
129 | int row = -1 ); | 129 | int row = -1 ); |
130 | void insertIntoTable( const OContact &contact, int row ); | 130 | void insertIntoTable( const OContact &contact, int row ); |
131 | QString findContactName( const OContact &entry ); | 131 | QString findContactName( const OContact &entry ); |
132 | QString findContactContact( const OContact &entry, int row ); | 132 | QString findContactContact( const OContact &entry, int row ); |
133 | void journalFreeReplace( const OContact &cnt, int row ); | 133 | void journalFreeReplace( const OContact &cnt, int row ); |
134 | void journalFreeRemove( int row ); | 134 | void journalFreeRemove( int row ); |
135 | void realignTable( int ); | 135 | void realignTable( int ); |
136 | void updateVisible(); | 136 | void updateVisible(); |
137 | int lastSortCol; | 137 | int lastSortCol; |
138 | bool asc; | 138 | bool asc; |
139 | char showChar; | 139 | char showChar; |
140 | QMap<AbTableItem*, OContact> contactList; | 140 | QMap<AbTableItem*, OContact> contactList; |
141 | const QValueList<int> *intFields; | 141 | const QValueList<int> *intFields; |
142 | int currFindRow; | 142 | int currFindRow; |
143 | QString showCat; | 143 | QString showCat; |
144 | QStringList choicenames; | 144 | QStringList choicenames; |
145 | bool enablePainting; | 145 | bool enablePainting; |
146 | Categories mCat; | 146 | Categories mCat; |
147 | 147 | ||
148 | QString showBk; | 148 | QString showBk; |
149 | bool columnVisible; | 149 | bool columnVisible; |
150 | 150 | ||
151 | OContactAccess m_contactdb; | 151 | OContactAccess m_contactdb; |
152 | 152 | ||
153 | }; | 153 | }; |
154 | #endif // ABTABLE_H | 154 | #endif // ABTABLE_H |
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 8335d8b..84e66fb 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -1,534 +1,568 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
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 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** OContact info@trolltech.com if any conditions of this licensing are | 16 | ** OContact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_FD | 21 | #define QTOPIA_INTERNAL_FD |
22 | 22 | ||
23 | #include "contacteditor.h" | 23 | #include "contacteditor.h" |
24 | #include "ablabel.h" | 24 | #include "ablabel.h" |
25 | #include "abtable.h" | 25 | #include "abtable.h" |
26 | #include "addresssettings.h" | 26 | #include "addresssettings.h" |
27 | #include "addressbook.h" | 27 | #include "addressbook.h" |
28 | 28 | ||
29 | 29 | ||
30 | #include <opie/ofileselector.h> | 30 | #include <opie/ofileselector.h> |
31 | #include <opie/ofiledialog.h> | 31 | #include <opie/ofiledialog.h> |
32 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
33 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
34 | #include <opie/ocontact.h> | 34 | #include <opie/ocontact.h> |
35 | 35 | ||
36 | #ifndef MAKE_FOR_SHARP_ROM | ||
37 | #include <qpe/finddialog.h> | ||
38 | #endif | ||
39 | |||
40 | #include <qpe/global.h> | 36 | #include <qpe/global.h> |
41 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
42 | #include <qpe/ir.h> | 38 | #include <qpe/ir.h> |
43 | #include <qpe/qpemessagebox.h> | 39 | #include <qpe/qpemessagebox.h> |
44 | #include <qpe/qcopenvelope_qws.h> | 40 | #include <qpe/qcopenvelope_qws.h> |
45 | 41 | ||
46 | #include <qaction.h> | 42 | #include <qaction.h> |
47 | #include <qdialog.h> | 43 | #include <qdialog.h> |
48 | #include <qdir.h> | 44 | #include <qdir.h> |
49 | #include <qfile.h> | 45 | #include <qfile.h> |
50 | #include <qimage.h> | 46 | #include <qimage.h> |
51 | #include <qlayout.h> | 47 | #include <qlayout.h> |
52 | #include <qpe/qpemenubar.h> | 48 | #include <qpe/qpemenubar.h> |
53 | #include <qmessagebox.h> | 49 | #include <qmessagebox.h> |
54 | #include <qpixmap.h> | 50 | #include <qpixmap.h> |
55 | #include <qpopupmenu.h> | 51 | #include <qpopupmenu.h> |
56 | #include <qpe/qpetoolbar.h> | 52 | #include <qpe/qpetoolbar.h> |
57 | #include <qstringlist.h> | 53 | #include <qstringlist.h> |
58 | #include <qtoolbutton.h> | 54 | #include <qtoolbutton.h> |
59 | #include <qwhatsthis.h> | 55 | #include <qwhatsthis.h> |
60 | 56 | ||
61 | #include <stdlib.h> | 57 | #include <stdlib.h> |
62 | #include <sys/stat.h> | 58 | #include <sys/stat.h> |
63 | #include <sys/types.h> | 59 | #include <sys/types.h> |
64 | #include <fcntl.h> | 60 | #include <fcntl.h> |
65 | #include <unistd.h> | 61 | #include <unistd.h> |
66 | 62 | ||
67 | #include <qdatetime.h> | 63 | #include <qdatetime.h> |
68 | 64 | ||
69 | #include "picker.h" | 65 | #include "picker.h" |
66 | #include "configdlg.h" | ||
70 | 67 | ||
71 | static QString addressbookPersonalVCardName() | 68 | static QString addressbookPersonalVCardName() |
72 | { | 69 | { |
73 | QString filename = Global::applicationFileName("addressbook", | 70 | QString filename = Global::applicationFileName("addressbook", |
74 | "businesscard.vcf"); | 71 | "businesscard.vcf"); |
75 | return filename; | 72 | return filename; |
76 | } | 73 | } |
77 | 74 | ||
78 | 75 | ||
79 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 76 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, |
80 | WFlags f ) | 77 | WFlags f ) |
81 | : QMainWindow( parent, name, f ), | 78 | : QMainWindow( parent, name, f ), |
82 | abEditor(0), | 79 | abEditor(0), |
80 | useRegExp(false), | ||
81 | DoSignalWrapAround(false), | ||
82 | caseSensitive(false), | ||
83 | bAbEditFirstTime(TRUE), | 83 | bAbEditFirstTime(TRUE), |
84 | syncing(FALSE) | 84 | syncing(FALSE) |
85 | { | 85 | { |
86 | isLoading = true; | 86 | isLoading = true; |
87 | 87 | ||
88 | initFields(); | 88 | initFields(); |
89 | 89 | ||
90 | setCaption( tr("Contacts") ); | 90 | setCaption( tr("Contacts") ); |
91 | setIcon( Resource::loadPixmap( "AddressBook" ) ); | 91 | setIcon( Resource::loadPixmap( "AddressBook" ) ); |
92 | 92 | ||
93 | setToolBarsMovable( FALSE ); | 93 | setToolBarsMovable( FALSE ); |
94 | 94 | ||
95 | // Create Toolbars | 95 | // Create Toolbars |
96 | 96 | ||
97 | QPEToolBar *bar = new QPEToolBar( this ); | 97 | QPEToolBar *bar = new QPEToolBar( this ); |
98 | bar->setHorizontalStretchable( TRUE ); | 98 | bar->setHorizontalStretchable( TRUE ); |
99 | 99 | ||
100 | QPEMenuBar *mbList = new QPEMenuBar( bar ); | 100 | QPEMenuBar *mbList = new QPEMenuBar( bar ); |
101 | mbList->setMargin( 0 ); | 101 | mbList->setMargin( 0 ); |
102 | 102 | ||
103 | QPopupMenu *edit = new QPopupMenu( this ); | 103 | QPopupMenu *edit = new QPopupMenu( this ); |
104 | mbList->insertItem( tr( "Contact" ), edit ); | 104 | mbList->insertItem( tr( "Contact" ), edit ); |
105 | 105 | ||
106 | listTools = new QPEToolBar( this, "list operations" ); | 106 | listTools = new QPEToolBar( this, "list operations" ); |
107 | 107 | ||
108 | 108 | ||
109 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, | 109 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, |
110 | 0, this, 0 ); | 110 | 0, this, 0 ); |
111 | actionNew = a; | 111 | actionNew = a; |
112 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); | 112 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); |
113 | a->addTo( edit ); | 113 | a->addTo( edit ); |
114 | a->addTo( listTools ); | 114 | a->addTo( listTools ); |
115 | 115 | ||
116 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 116 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
117 | 0, this, 0 ); | 117 | 0, this, 0 ); |
118 | actionEdit = a; | 118 | actionEdit = a; |
119 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); | 119 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); |
120 | a->addTo( edit ); | 120 | a->addTo( edit ); |
121 | a->addTo( listTools ); | 121 | a->addTo( listTools ); |
122 | 122 | ||
123 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 123 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
124 | 0, this, 0 ); | 124 | 0, this, 0 ); |
125 | actionTrash = a; | 125 | actionTrash = a; |
126 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); | 126 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); |
127 | a->addTo( edit ); | 127 | a->addTo( edit ); |
128 | a->addTo( listTools ); | 128 | a->addTo( listTools ); |
129 | 129 | ||
130 | 130 | ||
131 | // make it possible to go directly to businesscard via qcop call | 131 | // make it possible to go directly to businesscard via qcop call |
132 | #if defined(Q_WS_QWS) | 132 | #if defined(Q_WS_QWS) |
133 | #if !defined(QT_NO_COP) | 133 | #if !defined(QT_NO_COP) |
134 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); | 134 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); |
135 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 135 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), |
136 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); | 136 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); |
137 | #endif | 137 | #endif |
138 | #endif | 138 | #endif |
139 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), | 139 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), |
140 | QString::null, 0, this, 0 ); | 140 | QString::null, 0, this, 0 ); |
141 | actionFind = a; | 141 | actionFind = a; |
142 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); | 142 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); |
143 | a->addTo( edit ); | 143 | a->addTo( edit ); |
144 | a->addTo( listTools ); | 144 | a->addTo( listTools ); |
145 | 145 | ||
146 | // Much better search widget, taken from QTReader.. (se) | 146 | // Much better search widget, taken from QTReader.. (se) |
147 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); | 147 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
148 | searchBar->setHorizontalStretchable( TRUE ); | 148 | searchBar->setHorizontalStretchable( TRUE ); |
149 | searchBar->hide(); | 149 | searchBar->hide(); |
150 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 150 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
151 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 151 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
152 | // searchEdit->setFont( f ); | 152 | // searchEdit->setFont( f ); |
153 | searchBar->setStretchableWidget( searchEdit ); | 153 | searchBar->setStretchableWidget( searchEdit ); |
154 | connect( searchEdit, SIGNAL( returnPressed( ) ), | 154 | connect( searchEdit, SIGNAL( returnPressed( ) ), |
155 | this, SLOT( slotFind( ) ) ); | 155 | this, SLOT( slotFind( ) ) ); |
156 | 156 | ||
157 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 157 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
158 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindNext() ) ); | 158 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindNext() ) ); |
159 | a->addTo( searchBar ); | 159 | a->addTo( searchBar ); |
160 | 160 | ||
161 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 161 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
162 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); | 162 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); |
163 | a->addTo( searchBar ); | 163 | a->addTo( searchBar ); |
164 | 164 | ||
165 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ), | 165 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ), |
166 | QString::null, 0, this, 0 ); | 166 | QString::null, 0, this, 0 ); |
167 | //a->setEnabled( FALSE ); we got support for it now :) zecke | 167 | //a->setEnabled( FALSE ); we got support for it now :) zecke |
168 | actionMail = a; | 168 | actionMail = a; |
169 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); | 169 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); |
170 | a->addTo( edit ); | 170 | a->addTo( edit ); |
171 | a->addTo( listTools ); | 171 | a->addTo( listTools ); |
172 | 172 | ||
173 | 173 | ||
174 | 174 | ||
175 | if ( Ir::supported() ) { | 175 | if ( Ir::supported() ) { |
176 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, | 176 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, |
177 | 0, this, 0 ); | 177 | 0, this, 0 ); |
178 | actionBeam = a; | 178 | actionBeam = a; |
179 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | 179 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); |
180 | a->addTo( edit ); | 180 | a->addTo( edit ); |
181 | a->addTo( listTools ); | 181 | a->addTo( listTools ); |
182 | } | 182 | } |
183 | 183 | ||
184 | edit->insertSeparator(); | 184 | edit->insertSeparator(); |
185 | 185 | ||
186 | a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE ); | 186 | a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE ); |
187 | actionPersonal = a; | 187 | actionPersonal = a; |
188 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); | 188 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); |
189 | a->addTo( edit ); | 189 | a->addTo( edit ); |
190 | 190 | ||
191 | edit->insertSeparator(); | 191 | edit->insertSeparator(); |
192 | 192 | ||
193 | a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); | 193 | a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); |
194 | actionPersonal = a; | 194 | actionPersonal = a; |
195 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); | 195 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); |
196 | a->addTo( edit ); | 196 | a->addTo( edit ); |
197 | 197 | ||
198 | // Do we need this function ? (se) | 198 | // Do we need this function ? (se) |
199 | // a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); | 199 | // a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); |
200 | // connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 200 | // connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
201 | // a->addTo( edit ); | 201 | // a->addTo( edit ); |
202 | 202 | ||
203 | 203 | ||
204 | #ifdef __DEBUG_RELEASE | 204 | #ifdef __DEBUG_RELEASE |
205 | // Remove this function for public Release ! This is only | 205 | // Remove this function for public Release ! This is only |
206 | // for debug purposes .. | 206 | // for debug purposes .. |
207 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); | 207 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); |
208 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); | 208 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); |
209 | a->addTo( edit ); | 209 | a->addTo( edit ); |
210 | #endif | 210 | #endif |
211 | 211 | a = new QAction( tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, | |
212 | 0, this, 0 ); | ||
213 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); | ||
214 | a->addTo( edit ); | ||
215 | |||
212 | // Create Views | 216 | // Create Views |
213 | listContainer = new QWidget( this ); | 217 | listContainer = new QWidget( this ); |
214 | 218 | ||
215 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); | 219 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); |
216 | 220 | ||
217 | abList = new AbTable( &orderedFields, listContainer, "table" ); | 221 | abList = new AbTable( &orderedFields, listContainer, "table" ); |
218 | vb->addWidget(abList); | 222 | vb->addWidget(abList); |
219 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); | 223 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); |
220 | connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); | 224 | connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); |
221 | connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); | 225 | connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); |
222 | connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) ); | 226 | connect( abList, SIGNAL(currentChanged(int,int)), this, SLOT(slotUpdateToolbar()) ); |
223 | 227 | ||
224 | mView = 0; | 228 | mView = 0; |
225 | 229 | ||
226 | abList->load(); | 230 | abList->load(); |
227 | 231 | ||
228 | pLabel = new LetterPicker( listContainer ); | 232 | pLabel = new LetterPicker( listContainer ); |
229 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); | 233 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); |
230 | vb->addWidget(pLabel); | 234 | vb->addWidget(pLabel); |
231 | catMenu = new QPopupMenu( this ); | 235 | catMenu = new QPopupMenu( this ); |
232 | catMenu->setCheckable( TRUE ); | 236 | catMenu->setCheckable( TRUE ); |
233 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); | 237 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); |
234 | populateCategories(); | 238 | populateCategories(); |
235 | 239 | ||
236 | mbList->insertItem( tr("View"), catMenu ); | 240 | mbList->insertItem( tr("View"), catMenu ); |
237 | // setCentralWidget( listContainer ); | 241 | // setCentralWidget( listContainer ); |
238 | 242 | ||
239 | fontMenu = new QPopupMenu(this); | 243 | fontMenu = new QPopupMenu(this); |
240 | fontMenu->setCheckable( true ); | 244 | fontMenu->setCheckable( true ); |
241 | connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); | 245 | connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); |
242 | 246 | ||
243 | fontMenu->insertItem(tr( "Small" ), 0); | 247 | fontMenu->insertItem(tr( "Small" ), 0); |
244 | fontMenu->insertItem(tr( "Normal" ), 1); | 248 | fontMenu->insertItem(tr( "Normal" ), 1); |
245 | fontMenu->insertItem(tr( "Large" ), 2); | 249 | fontMenu->insertItem(tr( "Large" ), 2); |
246 | 250 | ||
247 | defaultFont = new QFont( abList->font() ); | 251 | defaultFont = new QFont( abList->font() ); |
248 | 252 | ||
249 | slotSetFont(startFontSize); | 253 | slotSetFont(startFontSize); |
250 | 254 | ||
251 | mbList->insertItem( tr("Font"), fontMenu); | 255 | mbList->insertItem( tr("Font"), fontMenu); |
252 | setCentralWidget(listContainer); | 256 | setCentralWidget(listContainer); |
253 | 257 | ||
254 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); | 258 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); |
255 | 259 | ||
256 | abList->setCurrentCell( 0, 0 ); | 260 | abList->setCurrentCell( 0, 0 ); |
261 | |||
262 | // Read Config settings | ||
263 | Config cfg("AddressBook"); | ||
264 | cfg.setGroup("Search"); | ||
265 | useRegExp = cfg.readBoolEntry( "useRegExp" ); | ||
266 | caseSensitive = cfg.readBoolEntry( "caseSensitive" ); | ||
267 | DoSignalWrapAround = cfg.readBoolEntry( "signalWrapAround" ); | ||
257 | 268 | ||
258 | isLoading = false; | 269 | isLoading = false; |
259 | } | 270 | } |
260 | 271 | ||
261 | 272 | ||
273 | void AddressbookWindow::slotConfig() | ||
274 | { | ||
275 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); | ||
276 | dlg -> setUseRegExp ( useRegExp ); | ||
277 | dlg -> setBeCaseSensitive( caseSensitive ); | ||
278 | dlg -> setSignalWrapAround( DoSignalWrapAround ); | ||
279 | dlg -> showMaximized(); | ||
280 | if ( dlg -> exec() ) { | ||
281 | qWarning ("Config Dialog accepted !"); | ||
282 | useRegExp = dlg -> useRegExp(); | ||
283 | caseSensitive = dlg -> beCaseSensitive(); | ||
284 | DoSignalWrapAround = dlg -> signalWrapAround(); | ||
285 | } | ||
286 | |||
287 | delete dlg; | ||
288 | } | ||
289 | |||
290 | |||
262 | void AddressbookWindow::slotSetFont( int size ) { | 291 | void AddressbookWindow::slotSetFont( int size ) { |
263 | 292 | ||
264 | if (size > 2 || size < 0) | 293 | if (size > 2 || size < 0) |
265 | size = 1; | 294 | size = 1; |
266 | 295 | ||
267 | startFontSize = size; | 296 | startFontSize = size; |
268 | 297 | ||
269 | QFont *currentFont; | 298 | QFont *currentFont; |
270 | 299 | ||
271 | switch (size) { | 300 | switch (size) { |
272 | case 0: | 301 | case 0: |
273 | fontMenu->setItemChecked(0, true); | 302 | fontMenu->setItemChecked(0, true); |
274 | fontMenu->setItemChecked(1, false); | 303 | fontMenu->setItemChecked(1, false); |
275 | fontMenu->setItemChecked(2, false); | 304 | fontMenu->setItemChecked(2, false); |
276 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); | 305 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); |
277 | currentFont = new QFont (abList->font()); | 306 | currentFont = new QFont (abList->font()); |
278 | // abList->resizeRows(currentFont->pixelSize() + 7); | 307 | // abList->resizeRows(currentFont->pixelSize() + 7); |
279 | abList->resizeRows(); | 308 | abList->resizeRows(); |
280 | break; | 309 | break; |
281 | case 1: | 310 | case 1: |
282 | fontMenu->setItemChecked(0, false); | 311 | fontMenu->setItemChecked(0, false); |
283 | fontMenu->setItemChecked(1, true); | 312 | fontMenu->setItemChecked(1, true); |
284 | fontMenu->setItemChecked(2, false); | 313 | fontMenu->setItemChecked(2, false); |
285 | abList->setFont( *defaultFont ); | 314 | abList->setFont( *defaultFont ); |
286 | currentFont = new QFont (abList->font()); | 315 | currentFont = new QFont (abList->font()); |
287 | // abList->resizeRows(currentFont->pixelSize() + 7); | 316 | // abList->resizeRows(currentFont->pixelSize() + 7); |
288 | abList->resizeRows(); | 317 | abList->resizeRows(); |
289 | break; | 318 | break; |
290 | case 2: | 319 | case 2: |
291 | fontMenu->setItemChecked(0, false); | 320 | fontMenu->setItemChecked(0, false); |
292 | fontMenu->setItemChecked(1, false); | 321 | fontMenu->setItemChecked(1, false); |
293 | fontMenu->setItemChecked(2, true); | 322 | fontMenu->setItemChecked(2, true); |
294 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); | 323 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); |
295 | currentFont = new QFont (abList->font()); | 324 | currentFont = new QFont (abList->font()); |
296 | //abList->resizeRows(currentFont->pixelSize() + 7); | 325 | //abList->resizeRows(currentFont->pixelSize() + 7); |
297 | abList->resizeRows(); | 326 | abList->resizeRows(); |
298 | break; | 327 | break; |
299 | } | 328 | } |
300 | } | 329 | } |
301 | 330 | ||
302 | 331 | ||
303 | 332 | ||
304 | void AddressbookWindow::importvCard() { | 333 | void AddressbookWindow::importvCard() { |
305 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); | 334 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); |
306 | if(!str.isEmpty() ) | 335 | if(!str.isEmpty() ) |
307 | setDocument((const QString&) str ); | 336 | setDocument((const QString&) str ); |
308 | 337 | ||
309 | } | 338 | } |
310 | 339 | ||
311 | void AddressbookWindow::setDocument( const QString &filename ) | 340 | void AddressbookWindow::setDocument( const QString &filename ) |
312 | { | 341 | { |
313 | if ( filename.find(".vcf") != int(filename.length()) - 4 ) | 342 | if ( filename.find(".vcf") != int(filename.length()) - 4 ) |
314 | return; | 343 | return; |
315 | 344 | ||
316 | QValueList<OContact> cl = OContact::readVCard( filename ); | 345 | QValueList<OContact> cl = OContact::readVCard( filename ); |
317 | for( QValueList<OContact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { | 346 | for( QValueList<OContact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { |
318 | // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") | 347 | // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") |
319 | // .arg( (*it).fullName() ); | 348 | // .arg( (*it).fullName() ); |
320 | // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == | 349 | // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == |
321 | // QMessageBox::Ok ) { | 350 | // QMessageBox::Ok ) { |
322 | abList->addEntry( *it ); | 351 | abList->addEntry( *it ); |
323 | // } | 352 | // } |
324 | } | 353 | } |
325 | 354 | ||
326 | } | 355 | } |
327 | 356 | ||
328 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) | 357 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) |
329 | { | 358 | { |
330 | QMainWindow::resizeEvent( e ); | 359 | QMainWindow::resizeEvent( e ); |
331 | 360 | ||
332 | if ( centralWidget() == listContainer ) | 361 | if ( centralWidget() == listContainer ) |
333 | showList(); | 362 | showList(); |
334 | else if ( centralWidget() == mView ) | 363 | else if ( centralWidget() == mView ) |
335 | showView(); | 364 | showView(); |
336 | } | 365 | } |
337 | 366 | ||
338 | AddressbookWindow::~AddressbookWindow() | 367 | AddressbookWindow::~AddressbookWindow() |
339 | { | 368 | { |
340 | Config cfg("AddressBook"); | 369 | Config cfg("AddressBook"); |
341 | cfg.setGroup("Font"); | 370 | cfg.setGroup("Font"); |
342 | cfg.writeEntry("fontSize", startFontSize); | 371 | cfg.writeEntry("fontSize", startFontSize); |
372 | |||
373 | cfg.setGroup("Search"); | ||
374 | cfg.writeEntry("useRegExp", useRegExp); | ||
375 | cfg.writeEntry("caseSensitive", caseSensitive); | ||
376 | cfg.writeEntry("signalWrapAround", DoSignalWrapAround); | ||
343 | } | 377 | } |
344 | 378 | ||
345 | void AddressbookWindow::slotUpdateToolbar() | 379 | void AddressbookWindow::slotUpdateToolbar() |
346 | { | 380 | { |
347 | OContact ce = abList->currentEntry(); | 381 | OContact ce = abList->currentEntry(); |
348 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); | 382 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); |
349 | } | 383 | } |
350 | 384 | ||
351 | void AddressbookWindow::showList() | 385 | void AddressbookWindow::showList() |
352 | { | 386 | { |
353 | bool visiblemView; | 387 | bool visiblemView; |
354 | 388 | ||
355 | visiblemView = false; | 389 | visiblemView = false; |
356 | if ( mView ) { | 390 | if ( mView ) { |
357 | mView->hide(); | 391 | mView->hide(); |
358 | visiblemView = true; | 392 | visiblemView = true; |
359 | } | 393 | } |
360 | setCentralWidget( listContainer ); | 394 | setCentralWidget( listContainer ); |
361 | listContainer->show(); | 395 | listContainer->show(); |
362 | // update our focues... (or use a stack widget!); | 396 | // update our focues... (or use a stack widget!); |
363 | abList->setFocus(); | 397 | abList->setFocus(); |
364 | 398 | ||
365 | // This makes sure we are scrolled all the way to the left | 399 | // This makes sure we are scrolled all the way to the left |
366 | abList->setContentsPos( 0, abList->contentsY() ); | 400 | abList->setContentsPos( 0, abList->contentsY() ); |
367 | 401 | ||
368 | //if ( visiblemView && abList->showBook() == "Cards" ) | 402 | //if ( visiblemView && abList->showBook() == "Cards" ) |
369 | //abList->setShowCategory( abList->showBook(), abList->showCategory() ); | 403 | //abList->setShowCategory( abList->showBook(), abList->showCategory() ); |
370 | 404 | ||
371 | } | 405 | } |
372 | 406 | ||
373 | void AddressbookWindow::showView() | 407 | void AddressbookWindow::showView() |
374 | { | 408 | { |
375 | if ( abList->numRows() > 0 ) { | 409 | if ( abList->numRows() > 0 ) { |
376 | listContainer->hide(); | 410 | listContainer->hide(); |
377 | setCentralWidget( abView() ); | 411 | setCentralWidget( abView() ); |
378 | mView->show(); | 412 | mView->show(); |
379 | mView->setFocus(); | 413 | mView->setFocus(); |
380 | } | 414 | } |
381 | } | 415 | } |
382 | 416 | ||
383 | void AddressbookWindow::slotListNew() | 417 | void AddressbookWindow::slotListNew() |
384 | { | 418 | { |
385 | OContact cnt; | 419 | OContact cnt; |
386 | if( !syncing ) { | 420 | if( !syncing ) { |
387 | if ( abEditor ) | 421 | if ( abEditor ) |
388 | abEditor->setEntry( cnt ); | 422 | abEditor->setEntry( cnt ); |
389 | abView()->init( cnt ); | 423 | abView()->init( cnt ); |
390 | editEntry( NewEntry ); | 424 | editEntry( NewEntry ); |
391 | } else { | 425 | } else { |
392 | QMessageBox::warning(this, tr("OContacts"), | 426 | QMessageBox::warning(this, tr("OContacts"), |
393 | tr("Can not edit data, currently syncing")); | 427 | tr("Can not edit data, currently syncing")); |
394 | } | 428 | } |
395 | } | 429 | } |
396 | 430 | ||
397 | void AddressbookWindow::slotListView() | 431 | void AddressbookWindow::slotListView() |
398 | { | 432 | { |
399 | abView()->init( abList->currentEntry() ); | 433 | abView()->init( abList->currentEntry() ); |
400 | mView->sync(); | 434 | mView->sync(); |
401 | showView(); | 435 | showView(); |
402 | } | 436 | } |
403 | 437 | ||
404 | void AddressbookWindow::slotListDelete() | 438 | void AddressbookWindow::slotListDelete() |
405 | { | 439 | { |
406 | if(!syncing) { | 440 | if(!syncing) { |
407 | OContact tmpEntry = abList->currentEntry(); | 441 | OContact tmpEntry = abList->currentEntry(); |
408 | 442 | ||
409 | // get a name, do the best we can... | 443 | // get a name, do the best we can... |
410 | QString strName = tmpEntry.fullName(); | 444 | QString strName = tmpEntry.fullName(); |
411 | if ( strName.isEmpty() ) { | 445 | if ( strName.isEmpty() ) { |
412 | strName = tmpEntry.company(); | 446 | strName = tmpEntry.company(); |
413 | if ( strName.isEmpty() ) | 447 | if ( strName.isEmpty() ) |
414 | strName = "No Name"; | 448 | strName = "No Name"; |
415 | } | 449 | } |
416 | 450 | ||
417 | 451 | ||
418 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), | 452 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), |
419 | strName ) ) { | 453 | strName ) ) { |
420 | abList->deleteCurrentEntry(); | 454 | abList->deleteCurrentEntry(); |
421 | showList(); | 455 | showList(); |
422 | } | 456 | } |
423 | } else { | 457 | } else { |
424 | QMessageBox::warning( this, tr("Contacts"), | 458 | QMessageBox::warning( this, tr("Contacts"), |
425 | tr("Can not edit data, currently syncing") ); | 459 | tr("Can not edit data, currently syncing") ); |
426 | } | 460 | } |
427 | } | 461 | } |
428 | 462 | ||
429 | void AddressbookWindow::slotViewBack() | 463 | void AddressbookWindow::slotViewBack() |
430 | { | 464 | { |
431 | showList(); | 465 | showList(); |
432 | } | 466 | } |
433 | 467 | ||
434 | void AddressbookWindow::slotViewEdit() | 468 | void AddressbookWindow::slotViewEdit() |
435 | { | 469 | { |
436 | if(!syncing) { | 470 | if(!syncing) { |
437 | if (actionPersonal->isOn()) { | 471 | if (actionPersonal->isOn()) { |
438 | editPersonal(); | 472 | editPersonal(); |
439 | } else { | 473 | } else { |
440 | if ( !bAbEditFirstTime ) | 474 | if ( !bAbEditFirstTime ) |
441 | abEditor->setEntry( abList->currentEntry() ); | 475 | abEditor->setEntry( abList->currentEntry() ); |
442 | editEntry( EditEntry ); | 476 | editEntry( EditEntry ); |
443 | } | 477 | } |
444 | } else { | 478 | } else { |
445 | QMessageBox::warning( this, tr("Contacts"), | 479 | QMessageBox::warning( this, tr("Contacts"), |
446 | tr("Can not edit data, currently syncing") ); | 480 | tr("Can not edit data, currently syncing") ); |
447 | } | 481 | } |
448 | } | 482 | } |
449 | 483 | ||
450 | 484 | ||
451 | 485 | ||
452 | void AddressbookWindow::writeMail() | 486 | void AddressbookWindow::writeMail() |
453 | { | 487 | { |
454 | OContact c = abList->currentEntry(); | 488 | OContact c = abList->currentEntry(); |
455 | QString name = c.fileAs(); | 489 | QString name = c.fileAs(); |
456 | QString email = c.defaultEmail(); | 490 | QString email = c.defaultEmail(); |
457 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); | 491 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); |
458 | e << name << email; | 492 | e << name << email; |
459 | } | 493 | } |
460 | 494 | ||
461 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 495 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
462 | 496 | ||
463 | void AddressbookWindow::slotBeam() | 497 | void AddressbookWindow::slotBeam() |
464 | { | 498 | { |
465 | QString filename; | 499 | QString filename; |
466 | OContact c; | 500 | OContact c; |
467 | if ( actionPersonal->isOn() ) { | 501 | if ( actionPersonal->isOn() ) { |
468 | filename = addressbookPersonalVCardName(); | 502 | filename = addressbookPersonalVCardName(); |
469 | if (!QFile::exists(filename)) | 503 | if (!QFile::exists(filename)) |
470 | return; // can't beam a non-existent file | 504 | return; // can't beam a non-existent file |
471 | c = OContact::readVCard( filename )[0]; | 505 | c = OContact::readVCard( filename )[0]; |
472 | } else { | 506 | } else { |
473 | unlink( beamfile ); // delete if exists | 507 | unlink( beamfile ); // delete if exists |
474 | c = abList->currentEntry(); | 508 | c = abList->currentEntry(); |
475 | mkdir("/tmp/obex/", 0755); | 509 | mkdir("/tmp/obex/", 0755); |
476 | OContact::writeVCard( beamfile, c ); | 510 | OContact::writeVCard( beamfile, c ); |
477 | filename = beamfile; | 511 | filename = beamfile; |
478 | } | 512 | } |
479 | Ir *ir = new Ir( this ); | 513 | Ir *ir = new Ir( this ); |
480 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 514 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
481 | QString description = c.fullName(); | 515 | QString description = c.fullName(); |
482 | ir->send( filename, description, "text/x-vCard" ); | 516 | ir->send( filename, description, "text/x-vCard" ); |
483 | } | 517 | } |
484 | 518 | ||
485 | void AddressbookWindow::beamDone( Ir *ir ) | 519 | void AddressbookWindow::beamDone( Ir *ir ) |
486 | { | 520 | { |
487 | delete ir; | 521 | delete ir; |
488 | unlink( beamfile ); | 522 | unlink( beamfile ); |
489 | } | 523 | } |
490 | 524 | ||
491 | 525 | ||
492 | static void parseName( const QString& name, QString *first, QString *middle, | 526 | static void parseName( const QString& name, QString *first, QString *middle, |
493 | QString * last ) | 527 | QString * last ) |
494 | { | 528 | { |
495 | 529 | ||
496 | int comma = name.find ( "," ); | 530 | int comma = name.find ( "," ); |
497 | QString rest; | 531 | QString rest; |
498 | if ( comma > 0 ) { | 532 | if ( comma > 0 ) { |
499 | *last = name.left( comma ); | 533 | *last = name.left( comma ); |
500 | comma++; | 534 | comma++; |
501 | while ( comma < int(name.length()) && name[comma] == ' ' ) | 535 | while ( comma < int(name.length()) && name[comma] == ' ' ) |
502 | comma++; | 536 | comma++; |
503 | rest = name.mid( comma ); | 537 | rest = name.mid( comma ); |
504 | } else { | 538 | } else { |
505 | int space = name.findRev( ' ' ); | 539 | int space = name.findRev( ' ' ); |
506 | *last = name.mid( space+1 ); | 540 | *last = name.mid( space+1 ); |
507 | rest = name.left( space ); | 541 | rest = name.left( space ); |
508 | } | 542 | } |
509 | int space = rest.find( ' ' ); | 543 | int space = rest.find( ' ' ); |
510 | if ( space <= 0 ) { | 544 | if ( space <= 0 ) { |
511 | *first = rest; | 545 | *first = rest; |
512 | } else { | 546 | } else { |
513 | *first = rest.left( space ); | 547 | *first = rest.left( space ); |
514 | *middle = rest.mid( space+1 ); | 548 | *middle = rest.mid( space+1 ); |
515 | } | 549 | } |
516 | 550 | ||
517 | } | 551 | } |
518 | 552 | ||
519 | 553 | ||
520 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | 554 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) |
521 | { | 555 | { |
522 | if (msg == "editPersonal()") { | 556 | if (msg == "editPersonal()") { |
523 | editPersonal(); | 557 | editPersonal(); |
524 | } else if (msg == "editPersonalAndClose()") { | 558 | } else if (msg == "editPersonalAndClose()") { |
525 | editPersonal(); | 559 | editPersonal(); |
526 | close(); | 560 | close(); |
527 | } else if ( msg == "addContact(QString,QString)" ) { | 561 | } else if ( msg == "addContact(QString,QString)" ) { |
528 | QDataStream stream(data,IO_ReadOnly); | 562 | QDataStream stream(data,IO_ReadOnly); |
529 | QString name, email; | 563 | QString name, email; |
530 | stream >> name >> email; | 564 | stream >> name >> email; |
531 | 565 | ||
532 | OContact cnt; | 566 | OContact cnt; |
533 | QString fn, mn, ln; | 567 | QString fn, mn, ln; |
534 | parseName( name, &fn, &mn, &ln ); | 568 | parseName( name, &fn, &mn, &ln ); |
@@ -705,323 +739,318 @@ void AddressbookWindow::flush() | |||
705 | { | 739 | { |
706 | syncing = TRUE; | 740 | syncing = TRUE; |
707 | abList->save(); | 741 | abList->save(); |
708 | } | 742 | } |
709 | 743 | ||
710 | 744 | ||
711 | void AddressbookWindow::closeEvent( QCloseEvent *e ) | 745 | void AddressbookWindow::closeEvent( QCloseEvent *e ) |
712 | { | 746 | { |
713 | if ( centralWidget() == mView ) { | 747 | if ( centralWidget() == mView ) { |
714 | if (actionPersonal->isOn()) { | 748 | if (actionPersonal->isOn()) { |
715 | // pretend we clicked it off | 749 | // pretend we clicked it off |
716 | actionPersonal->setOn(FALSE); | 750 | actionPersonal->setOn(FALSE); |
717 | slotPersonalView(); | 751 | slotPersonalView(); |
718 | } else { | 752 | } else { |
719 | showList(); | 753 | showList(); |
720 | } | 754 | } |
721 | e->ignore(); | 755 | e->ignore(); |
722 | return; | 756 | return; |
723 | } | 757 | } |
724 | 758 | ||
725 | if(syncing) { | 759 | if(syncing) { |
726 | /* shouldn't we save, I hear you say? well its already been set | 760 | /* shouldn't we save, I hear you say? well its already been set |
727 | so that an edit can not occur during a sync, and we flushed | 761 | so that an edit can not occur during a sync, and we flushed |
728 | at the start of the sync, so there is no need to save | 762 | at the start of the sync, so there is no need to save |
729 | Saving however itself would cause problems. */ | 763 | Saving however itself would cause problems. */ |
730 | e->accept(); | 764 | e->accept(); |
731 | return; | 765 | return; |
732 | } | 766 | } |
733 | //################## shouldn't always save | 767 | //################## shouldn't always save |
734 | // True, but the database handles this automatically ! (se) | 768 | // True, but the database handles this automatically ! (se) |
735 | if ( save() ) | 769 | if ( save() ) |
736 | e->accept(); | 770 | e->accept(); |
737 | else | 771 | else |
738 | e->ignore(); | 772 | e->ignore(); |
739 | } | 773 | } |
740 | 774 | ||
741 | /* | 775 | /* |
742 | Returns TRUE if it is OK to exit | 776 | Returns TRUE if it is OK to exit |
743 | */ | 777 | */ |
744 | 778 | ||
745 | bool AddressbookWindow::save() | 779 | bool AddressbookWindow::save() |
746 | { | 780 | { |
747 | if ( !abList->save() ) { | 781 | if ( !abList->save() ) { |
748 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | 782 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
749 | tr("Unable to save information.\n" | 783 | tr("Unable to save information.\n" |
750 | "Free up some space\n" | 784 | "Free up some space\n" |
751 | "and try again.\n" | 785 | "and try again.\n" |
752 | "\nQuit anyway?"), | 786 | "\nQuit anyway?"), |
753 | QMessageBox::Yes|QMessageBox::Escape, | 787 | QMessageBox::Yes|QMessageBox::Escape, |
754 | QMessageBox::No|QMessageBox::Default ) | 788 | QMessageBox::No|QMessageBox::Default ) |
755 | != QMessageBox::No ) | 789 | != QMessageBox::No ) |
756 | return TRUE; | 790 | return TRUE; |
757 | else | 791 | else |
758 | return FALSE; | 792 | return FALSE; |
759 | } | 793 | } |
760 | return TRUE; | 794 | return TRUE; |
761 | } | 795 | } |
762 | 796 | ||
763 | #ifdef __DEBUG_RELEASE | 797 | #ifdef __DEBUG_RELEASE |
764 | void AddressbookWindow::slotSave() | 798 | void AddressbookWindow::slotSave() |
765 | { | 799 | { |
766 | save(); | 800 | save(); |
767 | } | 801 | } |
768 | #endif | 802 | #endif |
769 | 803 | ||
770 | void AddressbookWindow::slotSettings() | 804 | void AddressbookWindow::slotSettings() |
771 | { | 805 | { |
772 | AddressSettings frmSettings( this ); | 806 | AddressSettings frmSettings( this ); |
773 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 807 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
774 | frmSettings.showMaximized(); | 808 | frmSettings.showMaximized(); |
775 | #endif | 809 | #endif |
776 | 810 | ||
777 | if ( frmSettings.exec() ) { | 811 | if ( frmSettings.exec() ) { |
778 | allFields.clear(); | 812 | allFields.clear(); |
779 | orderedFields.clear(); | 813 | orderedFields.clear(); |
780 | slOrderedFields.clear(); | 814 | slOrderedFields.clear(); |
781 | initFields(); | 815 | initFields(); |
782 | if ( abEditor ) | 816 | if ( abEditor ) |
783 | abEditor->loadFields(); | 817 | abEditor->loadFields(); |
784 | abList->refresh(); | 818 | abList->refresh(); |
785 | } | 819 | } |
786 | } | 820 | } |
787 | 821 | ||
788 | 822 | ||
789 | void AddressbookWindow::initFields() | 823 | void AddressbookWindow::initFields() |
790 | { | 824 | { |
791 | // we really don't need the things from the configuration, anymore | 825 | // we really don't need the things from the configuration, anymore |
792 | // only thing that is important are the important categories. So, | 826 | // only thing that is important are the important categories. So, |
793 | // Call the contact functions that correspond to these old functions... | 827 | // Call the contact functions that correspond to these old functions... |
794 | 828 | ||
795 | QStringList xmlFields = OContact::fields(); | 829 | QStringList xmlFields = OContact::fields(); |
796 | QStringList visibleFields = OContact::untrfields(); | 830 | QStringList visibleFields = OContact::untrfields(); |
797 | // QStringList trFields = OContact::trfields(); | 831 | // QStringList trFields = OContact::trfields(); |
798 | 832 | ||
799 | xmlFields.remove( "Title" ); | 833 | xmlFields.remove( "Title" ); |
800 | visibleFields.remove( "Name Title" ); | 834 | visibleFields.remove( "Name Title" ); |
801 | visibleFields.remove( "Notes" ); | 835 | visibleFields.remove( "Notes" ); |
802 | 836 | ||
803 | int i, version; | 837 | int i, version; |
804 | Config cfg( "AddressBook" ); | 838 | Config cfg( "AddressBook" ); |
805 | QString zn; | 839 | QString zn; |
806 | 840 | ||
807 | // ### Write a function to keep this from happening again... | 841 | // ### Write a function to keep this from happening again... |
808 | QStringList::ConstIterator it; | 842 | QStringList::ConstIterator it; |
809 | for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) { | 843 | for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) { |
810 | allFields.append( i + 3 ); | 844 | allFields.append( i + 3 ); |
811 | } | 845 | } |
812 | 846 | ||
813 | cfg.setGroup( "Version" ); | 847 | cfg.setGroup( "Version" ); |
814 | version = cfg.readNumEntry( "version" ); | 848 | version = cfg.readNumEntry( "version" ); |
815 | i = 0; | 849 | i = 0; |
816 | startFontSize = 1; | 850 | startFontSize = 1; |
817 | 851 | ||
818 | if ( version >= ADDRESSVERSION ) { | 852 | if ( version >= ADDRESSVERSION ) { |
819 | 853 | ||
820 | cfg.setGroup( "ImportantCategory" ); | 854 | cfg.setGroup( "ImportantCategory" ); |
821 | 855 | ||
822 | zn = cfg.readEntry( "Category" + QString::number(i), QString::null ); | 856 | zn = cfg.readEntry( "Category" + QString::number(i), QString::null ); |
823 | while ( !zn.isNull() ) { | 857 | while ( !zn.isNull() ) { |
824 | if ( zn.contains( "Work" ) || zn.contains( "Mb" ) ) { | 858 | if ( zn.contains( "Work" ) || zn.contains( "Mb" ) ) { |
825 | slOrderedFields.clear(); | 859 | slOrderedFields.clear(); |
826 | break; | 860 | break; |
827 | } | 861 | } |
828 | slOrderedFields.append( zn ); | 862 | slOrderedFields.append( zn ); |
829 | zn = cfg.readEntry( "Category" + QString::number(++i), QString::null ); | 863 | zn = cfg.readEntry( "Category" + QString::number(++i), QString::null ); |
830 | } | 864 | } |
831 | cfg.setGroup( "Font" ); | 865 | cfg.setGroup( "Font" ); |
832 | startFontSize = cfg.readNumEntry( "fontSize", 1 ); | 866 | startFontSize = cfg.readNumEntry( "fontSize", 1 ); |
833 | 867 | ||
834 | 868 | ||
835 | } else { | 869 | } else { |
836 | QString str; | 870 | QString str; |
837 | str = getenv("HOME"); | 871 | str = getenv("HOME"); |
838 | str += "/Settings/AddressBook.conf"; | 872 | str += "/Settings/AddressBook.conf"; |
839 | QFile::remove( str ); | 873 | QFile::remove( str ); |
840 | } | 874 | } |
841 | 875 | ||
842 | if ( slOrderedFields.count() > 0 ) { | 876 | if ( slOrderedFields.count() > 0 ) { |
843 | for( QStringList::ConstIterator it = slOrderedFields.begin(); | 877 | for( QStringList::ConstIterator it = slOrderedFields.begin(); |
844 | it != slOrderedFields.end(); ++it ) { | 878 | it != slOrderedFields.end(); ++it ) { |
845 | QValueList<int>::ConstIterator itVl; | 879 | QValueList<int>::ConstIterator itVl; |
846 | QStringList::ConstIterator itVis; | 880 | QStringList::ConstIterator itVis; |
847 | itVl = allFields.begin(); | 881 | itVl = allFields.begin(); |
848 | for ( itVis = visibleFields.begin(); | 882 | for ( itVis = visibleFields.begin(); |
849 | itVis != visibleFields.end() && itVl != allFields.end(); | 883 | itVis != visibleFields.end() && itVl != allFields.end(); |
850 | ++itVis, ++itVl ) { | 884 | ++itVis, ++itVl ) { |
851 | if ( *it == *itVis && itVl != allFields.end() ) { | 885 | if ( *it == *itVis && itVl != allFields.end() ) { |
852 | orderedFields.append( *itVl ); | 886 | orderedFields.append( *itVl ); |
853 | } | 887 | } |
854 | } | 888 | } |
855 | } | 889 | } |
856 | } else { | 890 | } else { |
857 | QValueList<int>::ConstIterator it; | 891 | QValueList<int>::ConstIterator it; |
858 | for ( it = allFields.begin(); it != allFields.end(); ++it ) | 892 | for ( it = allFields.begin(); it != allFields.end(); ++it ) |
859 | orderedFields.append( *it ); | 893 | orderedFields.append( *it ); |
860 | 894 | ||
861 | slOrderedFields = visibleFields; | 895 | slOrderedFields = visibleFields; |
862 | orderedFields.remove( Qtopia::AddressUid ); | 896 | orderedFields.remove( Qtopia::AddressUid ); |
863 | orderedFields.remove( Qtopia::Title ); | 897 | orderedFields.remove( Qtopia::Title ); |
864 | orderedFields.remove( Qtopia::Groups ); | 898 | orderedFields.remove( Qtopia::Groups ); |
865 | orderedFields.remove( Qtopia::AddressCategory ); | 899 | orderedFields.remove( Qtopia::AddressCategory ); |
866 | orderedFields.remove( Qtopia::FirstName ); | 900 | orderedFields.remove( Qtopia::FirstName ); |
867 | orderedFields.remove( Qtopia::LastName ); | 901 | orderedFields.remove( Qtopia::LastName ); |
868 | orderedFields.remove( Qtopia::DefaultEmail ); | 902 | orderedFields.remove( Qtopia::DefaultEmail ); |
869 | orderedFields.remove( Qtopia::FileAs ); | 903 | orderedFields.remove( Qtopia::FileAs ); |
870 | orderedFields.remove( Qtopia::Notes ); | 904 | orderedFields.remove( Qtopia::Notes ); |
871 | orderedFields.remove( Qtopia::Gender ); | 905 | orderedFields.remove( Qtopia::Gender ); |
872 | slOrderedFields.remove( "Name Title" ); | 906 | slOrderedFields.remove( "Name Title" ); |
873 | slOrderedFields.remove( "First Name" ); | 907 | slOrderedFields.remove( "First Name" ); |
874 | slOrderedFields.remove( "Last Name" ); | 908 | slOrderedFields.remove( "Last Name" ); |
875 | slOrderedFields.remove( "File As" ); | 909 | slOrderedFields.remove( "File As" ); |
876 | slOrderedFields.remove( "Default Email" ); | 910 | slOrderedFields.remove( "Default Email" ); |
877 | slOrderedFields.remove( "Notes" ); | 911 | slOrderedFields.remove( "Notes" ); |
878 | slOrderedFields.remove( "Gender" ); | 912 | slOrderedFields.remove( "Gender" ); |
879 | 913 | ||
880 | } | 914 | } |
881 | } | 915 | } |
882 | 916 | ||
883 | 917 | ||
884 | AbLabel *AddressbookWindow::abView() | 918 | AbLabel *AddressbookWindow::abView() |
885 | { | 919 | { |
886 | if ( !mView ) { | 920 | if ( !mView ) { |
887 | mView = new AbLabel( this, "viewer" ); | 921 | mView = new AbLabel( this, "viewer" ); |
888 | mView->init( OContact() ); | 922 | mView->init( OContact() ); |
889 | connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); | 923 | connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); |
890 | } | 924 | } |
891 | return mView; | 925 | return mView; |
892 | } | 926 | } |
893 | 927 | ||
894 | void AddressbookWindow::slotFindOpen() | 928 | void AddressbookWindow::slotFindOpen() |
895 | { | 929 | { |
896 | searchBar->show(); | 930 | searchBar->show(); |
931 | searchEdit->setFocus(); | ||
897 | } | 932 | } |
898 | void AddressbookWindow::slotFindClose() | 933 | void AddressbookWindow::slotFindClose() |
899 | { | 934 | { |
900 | searchBar->hide(); | 935 | searchBar->hide(); |
936 | abList->setFocus(); | ||
901 | } | 937 | } |
902 | void AddressbookWindow::slotFindNext() | 938 | void AddressbookWindow::slotFindNext() |
903 | { | 939 | { |
904 | } | ||
905 | |||
906 | void AddressbookWindow::slotFind() | ||
907 | { | ||
908 | if ( centralWidget() == abView() ) | 940 | if ( centralWidget() == abView() ) |
909 | showList(); | 941 | showList(); |
910 | 942 | ||
911 | // FindDialog frmFind( "Contacts", this ); | 943 | // Maybe we should react on Wraparound and notfound ? |
912 | // QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) ); | 944 | // QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) ); |
913 | // QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) ); | 945 | // QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) ); |
914 | // frmFind.exec(); | ||
915 | 946 | ||
916 | // QStringList categories = abList->categories(); | ||
917 | // abList->setShowCategory( book, cat ); | ||
918 | abList->slotDoFind( searchEdit->text(), false, false); | 947 | abList->slotDoFind( searchEdit->text(), false, false); |
919 | 948 | ||
920 | 949 | ||
921 | if ( abList->numSelections() ) | 950 | if ( abList->numSelections() ) |
922 | abList->clearSelection(); | 951 | abList->clearSelection(); |
952 | |||
953 | } | ||
954 | |||
955 | void AddressbookWindow::slotFind() | ||
956 | { | ||
923 | 957 | ||
924 | abList->clearFindRow(); | 958 | abList->clearFindRow(); |
959 | slotFindNext(); | ||
925 | } | 960 | } |
926 | 961 | ||
927 | void AddressbookWindow::slotSetCategory( int c ) | 962 | void AddressbookWindow::slotSetCategory( int c ) |
928 | { | 963 | { |
929 | 964 | ||
930 | QString cat, book; | 965 | QString cat, book; |
931 | 966 | ||
932 | if ( c <= 0 ) | 967 | if ( c <= 0 ) |
933 | return; | 968 | return; |
934 | 969 | ||
935 | // Checkmark Book Menu Item Selected | 970 | // Set checkItem for selected one |
936 | if ( c < 6 ) | 971 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) |
937 | for ( unsigned int i = 1; i < 6; i++ ) | 972 | catMenu->setItemChecked( i, c == (int)i ); |
938 | catMenu->setItemChecked( i, c == (int)i ); | ||
939 | |||
940 | // Checkmark Category Menu Item Selected | ||
941 | else | ||
942 | for ( unsigned int i = 6; i < catMenu->count(); i++ ) | ||
943 | catMenu->setItemChecked( i, c == (int)i ); | ||
944 | 973 | ||
945 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { | 974 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { |
946 | if (catMenu->isItemChecked( i )) { | 975 | if (catMenu->isItemChecked( i )) { |
947 | if ( i == 1 ) // default List view | 976 | if ( i == 1 ) // default List view |
948 | book = QString::null; | 977 | book = QString::null; |
949 | else if ( i == 2 ) | 978 | else if ( i == 2 ) |
950 | book = "Phone"; | 979 | book = "Phone"; |
951 | else if ( i == 3 ) | 980 | else if ( i == 3 ) |
952 | book = "Company"; | 981 | book = "Company"; |
953 | else if ( i == 4 ) | 982 | else if ( i == 4 ) |
954 | book = "Email"; | 983 | book = "Email"; |
955 | else if ( i == 5 ) | 984 | else if ( i == 5 ) |
956 | book = "Cards"; | 985 | book = "Cards"; |
957 | else if ( i == 6 ) // default All Categories | 986 | else if ( i == 6 ) // default All Categories |
958 | cat = QString::null; | 987 | cat = QString::null; |
959 | else if ( i == (unsigned int)catMenu->count() ) // last menu option will be Unfiled | 988 | else if ( i == (unsigned int)catMenu->count() ) // last menu option will be Unfiled |
960 | cat = "Unfiled"; | 989 | cat = "Unfiled"; |
961 | else | 990 | else |
962 | cat = abList->categories()[i - 7]; | 991 | cat = abList->categories()[i - 7]; |
963 | } | 992 | } |
964 | } | 993 | } |
965 | 994 | ||
966 | abList->setShowCategory( book, cat ); | 995 | abList->setShowCategory( book, cat ); |
967 | 996 | ||
968 | if ( book.isEmpty() ) | 997 | if ( book.isEmpty() ) |
969 | book = "List"; | 998 | book = "List"; |
970 | if ( cat.isEmpty() ) | 999 | if ( cat.isEmpty() ) |
971 | cat = "All"; | 1000 | cat = "All"; |
972 | 1001 | ||
973 | setCaption( tr( "Contacts" ) + " - " + tr( book ) + " - " + tr( cat ) ); | 1002 | setCaption( tr( "Contacts" ) + " - " + tr( book ) + " - " + tr( cat ) ); |
974 | } | 1003 | } |
975 | 1004 | ||
976 | void AddressbookWindow::slotSetLetter( char c ) { | 1005 | void AddressbookWindow::slotSetLetter( char c ) { |
977 | 1006 | ||
978 | abList->setShowByLetter( c ); | 1007 | abList->setShowByLetter( c ); |
979 | 1008 | ||
980 | } | 1009 | } |
981 | 1010 | ||
982 | void AddressbookWindow::populateCategories() | 1011 | void AddressbookWindow::populateCategories() |
983 | { | 1012 | { |
984 | catMenu->clear(); | 1013 | catMenu->clear(); |
985 | 1014 | ||
986 | int id, rememberId; | 1015 | int id, rememberId; |
987 | id = 1; | 1016 | id = 1; |
988 | rememberId = 0; | 1017 | rememberId = 0; |
989 | 1018 | ||
990 | catMenu->insertItem( tr( "List" ), id++ ); | 1019 | catMenu->insertItem( tr( "List" ), id++ ); |
991 | catMenu->insertItem( tr( "Phone Book" ), id++ ); | 1020 | catMenu->insertItem( tr( "Phone Book" ), id++ ); |
992 | catMenu->insertItem( tr( "Company Book" ), id++ ); | 1021 | catMenu->insertItem( tr( "Company Book" ), id++ ); |
993 | catMenu->insertItem( tr( "Email Book" ), id++ ); | 1022 | catMenu->insertItem( tr( "Email Book" ), id++ ); |
994 | catMenu->insertItem( tr( "Cards" ), id++ ); | 1023 | catMenu->insertItem( tr( "Cards" ), id++ ); |
995 | catMenu->insertSeparator(); | 1024 | catMenu->insertSeparator(); |
996 | 1025 | ||
997 | catMenu->insertItem( tr( "All" ), id++ ); | 1026 | catMenu->insertItem( tr( "All" ), id++ ); |
998 | QStringList categories = abList->categories(); | 1027 | QStringList categories = abList->categories(); |
999 | categories.append( tr( "Unfiled" ) ); | 1028 | categories.append( tr( "Unfiled" ) ); |
1000 | for ( QStringList::Iterator it = categories.begin(); | 1029 | for ( QStringList::Iterator it = categories.begin(); |
1001 | it != categories.end(); ++it ) { | 1030 | it != categories.end(); ++it ) { |
1002 | catMenu->insertItem( *it, id ); | 1031 | catMenu->insertItem( *it, id ); |
1003 | if ( *it == abList->showCategory() ) | 1032 | if ( *it == abList->showCategory() ) |
1004 | rememberId = id; | 1033 | rememberId = id; |
1005 | ++id; | 1034 | ++id; |
1006 | } | 1035 | } |
1007 | 1036 | ||
1008 | if ( abList->showBook().isEmpty() ) { | 1037 | if ( abList->showBook().isEmpty() ) { |
1009 | catMenu->setItemChecked( 1, true ); | 1038 | catMenu->setItemChecked( 1, true ); |
1010 | } else if ( abList->showBook() == "Phone" ) { | 1039 | } else if ( abList->showBook() == "Phone" ) { |
1011 | catMenu->setItemChecked( 2, true ); | 1040 | catMenu->setItemChecked( 2, true ); |
1012 | } else if ( abList->showBook() == "Company" ) { | 1041 | } else if ( abList->showBook() == "Company" ) { |
1013 | catMenu->setItemChecked( 3, true ); | 1042 | catMenu->setItemChecked( 3, true ); |
1014 | } else if ( abList->showBook() == "Email" ) { | 1043 | } else if ( abList->showBook() == "Email" ) { |
1015 | catMenu->setItemChecked( 4, true ); | 1044 | catMenu->setItemChecked( 4, true ); |
1016 | } else if ( abList->showBook() == "Cards" ) { | 1045 | } else if ( abList->showBook() == "Cards" ) { |
1017 | catMenu->setItemChecked( 5, true ); | 1046 | catMenu->setItemChecked( 5, true ); |
1018 | } | 1047 | } |
1019 | 1048 | ||
1020 | if ( abList->showCategory().isEmpty() ) { | 1049 | if ( abList->showCategory().isEmpty() ) { |
1021 | slotSetCategory( 6 ); | 1050 | slotSetCategory( 6 ); |
1022 | } | 1051 | } |
1023 | else { | 1052 | else { |
1024 | slotSetCategory( rememberId ); | 1053 | slotSetCategory( rememberId ); |
1025 | } | 1054 | } |
1026 | } | 1055 | } |
1027 | 1056 | ||
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h index b7cf355..18b083f 100644 --- a/core/pim/addressbook/addressbook.h +++ b/core/pim/addressbook/addressbook.h | |||
@@ -1,124 +1,130 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
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 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef Addressbook_H | 20 | #ifndef Addressbook_H |
21 | #define Addressbook_H | 21 | #define Addressbook_H |
22 | 22 | ||
23 | // Remove this for OPIE releae 1.0 ! | 23 | // Remove this for OPIE releae 1.0 ! |
24 | #define __DEBUG_RELEASE | 24 | #define __DEBUG_RELEASE |
25 | 25 | ||
26 | #include <qmainwindow.h> | 26 | #include <qmainwindow.h> |
27 | #include <qvaluelist.h> | 27 | #include <qvaluelist.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <qlineedit.h> | 29 | #include <qlineedit.h> |
30 | #include "ofloatbar.h" | 30 | #include "ofloatbar.h" |
31 | 31 | ||
32 | class ContactEditor; | 32 | class ContactEditor; |
33 | class AbLabel; | 33 | class AbLabel; |
34 | class AbTable; | 34 | class AbTable; |
35 | class QPEToolBar; | 35 | class QPEToolBar; |
36 | class QPopupMenu; | 36 | class QPopupMenu; |
37 | class QToolButton; | 37 | class QToolButton; |
38 | class QDialog; | 38 | class QDialog; |
39 | class Ir; | 39 | class Ir; |
40 | class QAction; | 40 | class QAction; |
41 | class LetterPicker; | 41 | class LetterPicker; |
42 | 42 | ||
43 | class AddressbookWindow: public QMainWindow | 43 | class AddressbookWindow: public QMainWindow |
44 | { | 44 | { |
45 | Q_OBJECT | 45 | Q_OBJECT |
46 | public: | 46 | public: |
47 | AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 47 | AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
48 | ~AddressbookWindow(); | 48 | ~AddressbookWindow(); |
49 | 49 | ||
50 | protected: | 50 | protected: |
51 | void resizeEvent( QResizeEvent * e ); | 51 | void resizeEvent( QResizeEvent * e ); |
52 | void showList(); | 52 | void showList(); |
53 | void showView(); | 53 | void showView(); |
54 | enum EntryMode { NewEntry=0, EditEntry }; | 54 | enum EntryMode { NewEntry=0, EditEntry }; |
55 | void editPersonal(); | 55 | void editPersonal(); |
56 | void editEntry( EntryMode ); | 56 | void editEntry( EntryMode ); |
57 | void closeEvent( QCloseEvent *e ); | 57 | void closeEvent( QCloseEvent *e ); |
58 | bool save(); | 58 | bool save(); |
59 | 59 | ||
60 | public slots: | 60 | public slots: |
61 | void flush(); | 61 | void flush(); |
62 | void reload(); | 62 | void reload(); |
63 | void appMessage(const QCString &, const QByteArray &); | 63 | void appMessage(const QCString &, const QByteArray &); |
64 | void setDocument( const QString & ); | 64 | void setDocument( const QString & ); |
65 | #ifdef __DEBUG_RELEASE | 65 | #ifdef __DEBUG_RELEASE |
66 | void slotSave(); | 66 | void slotSave(); |
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | private slots: | 69 | private slots: |
70 | void importvCard(); | 70 | void importvCard(); |
71 | void slotListNew(); | 71 | void slotListNew(); |
72 | void slotListView(); | 72 | void slotListView(); |
73 | void slotListDelete(); | 73 | void slotListDelete(); |
74 | void slotViewBack(); | 74 | void slotViewBack(); |
75 | void slotViewEdit(); | 75 | void slotViewEdit(); |
76 | void slotPersonalView(); | 76 | void slotPersonalView(); |
77 | void listIsEmpty( bool ); | 77 | void listIsEmpty( bool ); |
78 | void slotSettings(); | 78 | void slotSettings(); |
79 | void writeMail(); | 79 | void writeMail(); |
80 | void slotBeam(); | 80 | void slotBeam(); |
81 | void beamDone( Ir * ); | 81 | void beamDone( Ir * ); |
82 | void slotSetCategory( int ); | 82 | void slotSetCategory( int ); |
83 | void slotSetLetter( char ); | 83 | void slotSetLetter( char ); |
84 | void slotUpdateToolbar(); | 84 | void slotUpdateToolbar(); |
85 | void slotSetFont(int); | 85 | void slotSetFont(int); |
86 | 86 | ||
87 | void slotFindOpen(); | 87 | void slotFindOpen(); |
88 | void slotFindClose(); | 88 | void slotFindClose(); |
89 | void slotFind(); | 89 | void slotFind(); |
90 | void slotFindNext(); | 90 | void slotFindNext(); |
91 | 91 | ||
92 | void slotConfig(); | ||
93 | |||
92 | private: | 94 | private: |
93 | void initFields(); // inititialize our fields... | 95 | void initFields(); // inititialize our fields... |
94 | AbLabel *abView(); | 96 | AbLabel *abView(); |
95 | void populateCategories(); | 97 | void populateCategories(); |
96 | 98 | ||
97 | QPopupMenu *catMenu, *fontMenu; | 99 | QPopupMenu *catMenu, *fontMenu; |
98 | QPEToolBar *listTools; | 100 | QPEToolBar *listTools; |
99 | QToolButton *deleteButton; | 101 | QToolButton *deleteButton; |
100 | QValueList<int> allFields, orderedFields; | 102 | QValueList<int> allFields, orderedFields; |
101 | QStringList slOrderedFields; | 103 | QStringList slOrderedFields; |
102 | enum Panes { paneList=0, paneView, paneEdit }; | 104 | enum Panes { paneList=0, paneView, paneEdit }; |
103 | ContactEditor *abEditor; | 105 | ContactEditor *abEditor; |
104 | AbLabel *mView; | 106 | AbLabel *mView; |
105 | LetterPicker *pLabel; | 107 | LetterPicker *pLabel; |
106 | AbTable *abList; | 108 | AbTable *abList; |
107 | QWidget *listContainer; | 109 | QWidget *listContainer; |
108 | 110 | ||
111 | // Searching stuff | ||
109 | OFloatBar* searchBar; | 112 | OFloatBar* searchBar; |
110 | QLineEdit* searchEdit; | 113 | QLineEdit* searchEdit; |
114 | bool useRegExp; | ||
115 | bool DoSignalWrapAround; | ||
116 | bool caseSensitive; | ||
111 | 117 | ||
112 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; | 118 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; |
113 | 119 | ||
114 | bool bAbEditFirstTime; | 120 | bool bAbEditFirstTime; |
115 | int viewMargin; | 121 | int viewMargin; |
116 | 122 | ||
117 | bool syncing; | 123 | bool syncing; |
118 | QFont *defaultFont; | 124 | QFont *defaultFont; |
119 | int startFontSize; | 125 | int startFontSize; |
120 | 126 | ||
121 | bool isLoading; | 127 | bool isLoading; |
122 | }; | 128 | }; |
123 | 129 | ||
124 | #endif | 130 | #endif |
diff --git a/core/pim/addressbook/addressbook.pro b/core/pim/addressbook/addressbook.pro index 05aa5ec..9ed2f68 100644 --- a/core/pim/addressbook/addressbook.pro +++ b/core/pim/addressbook/addressbook.pro | |||
@@ -1,38 +1,41 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS= addressbook.h \ | 4 | HEADERS= addressbook.h \ |
5 | contacteditor.h \ | 5 | contacteditor.h \ |
6 | ablabel.h \ | 6 | ablabel.h \ |
7 | abtable.h \ | 7 | abtable.h \ |
8 | addresssettings.h \ | 8 | addresssettings.h \ |
9 | picker.h \ | 9 | picker.h \ |
10 | ofloatbar.h | 10 | ofloatbar.h \ |
11 | configdlg.h | ||
11 | SOURCES= main.cpp \ | 12 | SOURCES= main.cpp \ |
12 | addressbook.cpp \ | 13 | addressbook.cpp \ |
13 | contacteditor.cpp \ | 14 | contacteditor.cpp \ |
14 | ablabel.cpp \ | 15 | ablabel.cpp \ |
15 | abtable.cpp \ | 16 | abtable.cpp \ |
16 | addresssettings.cpp \ | 17 | addresssettings.cpp \ |
17 | picker.cpp | 18 | picker.cpp \ |
18 | INTERFACES= addresssettingsbase.ui | 19 | configdlg.cpp |
20 | |||
21 | INTERFACES= addresssettingsbase.ui configdlg_base.ui | ||
19 | TARGET = addressbook | 22 | TARGET = addressbook |
20 | INCLUDEPATH += $(OPIEDIR)/include | 23 | INCLUDEPATH += $(OPIEDIR)/include |
21 | DEPENDPATH+= $(OPIEDIR)/include | 24 | DEPENDPATH+= $(OPIEDIR)/include |
22 | LIBS += -lqpe -lopie | 25 | LIBS += -lqpe -lopie |
23 | 26 | ||
24 | TRANSLATIONS = ../../../i18n/de/addressbook.ts \ | 27 | TRANSLATIONS = ../../../i18n/de/addressbook.ts \ |
25 | ../../../i18n/en/addressbook.ts \ | 28 | ../../../i18n/en/addressbook.ts \ |
26 | ../../../i18n/es/addressbook.ts \ | 29 | ../../../i18n/es/addressbook.ts \ |
27 | ../../../i18n/fr/addressbook.ts \ | 30 | ../../../i18n/fr/addressbook.ts \ |
28 | ../../../i18n/hu/addressbook.ts \ | 31 | ../../../i18n/hu/addressbook.ts \ |
29 | ../../../i18n/ja/addressbook.ts \ | 32 | ../../../i18n/ja/addressbook.ts \ |
30 | ../../../i18n/ko/addressbook.ts \ | 33 | ../../../i18n/ko/addressbook.ts \ |
31 | ../../../i18n/no/addressbook.ts \ | 34 | ../../../i18n/no/addressbook.ts \ |
32 | ../../../i18n/pl/addressbook.ts \ | 35 | ../../../i18n/pl/addressbook.ts \ |
33 | ../../../i18n/pt/addressbook.ts \ | 36 | ../../../i18n/pt/addressbook.ts \ |
34 | ../../../i18n/pt_BR/addressbook.ts \ | 37 | ../../../i18n/pt_BR/addressbook.ts \ |
35 | ../../../i18n/sl/addressbook.ts \ | 38 | ../../../i18n/sl/addressbook.ts \ |
36 | ../../../i18n/zh_CN/addressbook.ts \ | 39 | ../../../i18n/zh_CN/addressbook.ts \ |
37 | ../../../i18n/it/addressbook.ts \ | 40 | ../../../i18n/it/addressbook.ts \ |
38 | ../../../i18n/zh_TW/addressbook.ts | 41 | ../../../i18n/zh_TW/addressbook.ts |
diff --git a/core/pim/addressbook/configdlg.cpp b/core/pim/addressbook/configdlg.cpp new file mode 100644 index 0000000..b7c3b77 --- a/dev/null +++ b/core/pim/addressbook/configdlg.cpp | |||
@@ -0,0 +1,45 @@ | |||
1 | #include "configdlg.h" | ||
2 | #include <qcheckbox.h> | ||
3 | #include <qradiobutton.h> | ||
4 | |||
5 | ConfigDlg::ConfigDlg( QWidget *parent = 0, const char *name = 0 ): | ||
6 | ConfigDlg_Base(parent, name, true ) | ||
7 | {} | ||
8 | |||
9 | |||
10 | bool ConfigDlg::useRegExp() const | ||
11 | { | ||
12 | return m_useRegExp->isOn(); | ||
13 | } | ||
14 | bool ConfigDlg::useWildCards() const | ||
15 | { | ||
16 | return m_useWildCard->isOn(); | ||
17 | } | ||
18 | bool ConfigDlg::beCaseSensitive() const | ||
19 | { | ||
20 | return m_useCaseSensitive->isChecked(); | ||
21 | } | ||
22 | bool ConfigDlg::signalWrapAround() const | ||
23 | { | ||
24 | return m_signalWrapAround->isChecked(); | ||
25 | } | ||
26 | void ConfigDlg::setUseRegExp( bool v ) | ||
27 | { | ||
28 | m_useRegExp->setChecked( v ); | ||
29 | } | ||
30 | void ConfigDlg::setUseWildCards( bool v ) | ||
31 | { | ||
32 | m_useWildCard->setChecked( v ); | ||
33 | } | ||
34 | void ConfigDlg::setBeCaseSensitive( bool v ) | ||
35 | { | ||
36 | m_useCaseSensitive->setChecked( v ); | ||
37 | } | ||
38 | void ConfigDlg::setSignalWrapAround( bool v ) | ||
39 | { | ||
40 | m_signalWrapAround->setChecked( v ); | ||
41 | } | ||
42 | |||
43 | |||
44 | |||
45 | |||
diff --git a/core/pim/addressbook/configdlg.h b/core/pim/addressbook/configdlg.h new file mode 100644 index 0000000..8be469b --- a/dev/null +++ b/core/pim/addressbook/configdlg.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef _CONFIGDLG_H_ | ||
2 | #define _CONFIGDLG_H_ | ||
3 | |||
4 | #include "configdlg_base.h" | ||
5 | |||
6 | class ConfigDlg: public ConfigDlg_Base | ||
7 | { | ||
8 | Q_OBJECT | ||
9 | public: | ||
10 | ConfigDlg( QWidget *parent = 0, const char *name = 0 ); | ||
11 | |||
12 | // Search Settings | ||
13 | bool useRegExp() const; | ||
14 | bool useWildCards() const; | ||
15 | bool beCaseSensitive() const; | ||
16 | bool signalWrapAround() const; | ||
17 | |||
18 | void setUseRegExp( bool v ); | ||
19 | void setUseWildCards( bool v ); | ||
20 | void setBeCaseSensitive( bool v ); | ||
21 | void setSignalWrapAround( bool v ); | ||
22 | }; | ||
23 | |||
24 | |||
25 | #endif | ||
diff --git a/core/pim/addressbook/configdlg_base.ui b/core/pim/addressbook/configdlg_base.ui new file mode 100644 index 0000000..e082702 --- a/dev/null +++ b/core/pim/addressbook/configdlg_base.ui | |||
@@ -0,0 +1,232 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>ConfigDlg_Base</class> | ||
3 | <author>Stefan Eilers</author> | ||
4 | <widget> | ||
5 | <class>QDialog</class> | ||
6 | <property stdset="1"> | ||
7 | <name>name</name> | ||
8 | <cstring>Configuration</cstring> | ||
9 | </property> | ||
10 | <property stdset="1"> | ||
11 | <name>geometry</name> | ||
12 | <rect> | ||
13 | <x>0</x> | ||
14 | <y>0</y> | ||
15 | <width>227</width> | ||
16 | <height>287</height> | ||
17 | </rect> | ||
18 | </property> | ||
19 | <property stdset="1"> | ||
20 | <name>caption</name> | ||
21 | <string>MyDialog1</string> | ||
22 | </property> | ||
23 | <property stdset="1"> | ||
24 | <name>sizeGripEnabled</name> | ||
25 | <bool>true</bool> | ||
26 | </property> | ||
27 | <vbox> | ||
28 | <property stdset="1"> | ||
29 | <name>margin</name> | ||
30 | <number>11</number> | ||
31 | </property> | ||
32 | <property stdset="1"> | ||
33 | <name>spacing</name> | ||
34 | <number>6</number> | ||
35 | </property> | ||
36 | <widget> | ||
37 | <class>QTabWidget</class> | ||
38 | <property stdset="1"> | ||
39 | <name>name</name> | ||
40 | <cstring>configDlg_base</cstring> | ||
41 | </property> | ||
42 | <property> | ||
43 | <name>layoutMargin</name> | ||
44 | </property> | ||
45 | <widget> | ||
46 | <class>QWidget</class> | ||
47 | <property stdset="1"> | ||
48 | <name>name</name> | ||
49 | <cstring>Widget5</cstring> | ||
50 | </property> | ||
51 | <attribute> | ||
52 | <name>title</name> | ||
53 | <string>Search</string> | ||
54 | </attribute> | ||
55 | <vbox> | ||
56 | <property stdset="1"> | ||
57 | <name>margin</name> | ||
58 | <number>5</number> | ||
59 | </property> | ||
60 | <property stdset="1"> | ||
61 | <name>spacing</name> | ||
62 | <number>6</number> | ||
63 | </property> | ||
64 | <widget> | ||
65 | <class>QButtonGroup</class> | ||
66 | <property stdset="1"> | ||
67 | <name>name</name> | ||
68 | <cstring>ButtonGroup1</cstring> | ||
69 | </property> | ||
70 | <property stdset="1"> | ||
71 | <name>title</name> | ||
72 | <string>Query Style</string> | ||
73 | </property> | ||
74 | <vbox> | ||
75 | <property stdset="1"> | ||
76 | <name>margin</name> | ||
77 | <number>11</number> | ||
78 | </property> | ||
79 | <property stdset="1"> | ||
80 | <name>spacing</name> | ||
81 | <number>6</number> | ||
82 | </property> | ||
83 | <widget> | ||
84 | <class>QRadioButton</class> | ||
85 | <property stdset="1"> | ||
86 | <name>name</name> | ||
87 | <cstring>m_useRegExp</cstring> | ||
88 | </property> | ||
89 | <property stdset="1"> | ||
90 | <name>text</name> | ||
91 | <string>Use Regular Expressions</string> | ||
92 | </property> | ||
93 | </widget> | ||
94 | <widget> | ||
95 | <class>QRadioButton</class> | ||
96 | <property stdset="1"> | ||
97 | <name>name</name> | ||
98 | <cstring>m_useWildCard</cstring> | ||
99 | </property> | ||
100 | <property stdset="1"> | ||
101 | <name>text</name> | ||
102 | <string>Use Wildcards (*,?)</string> | ||
103 | </property> | ||
104 | <property stdset="1"> | ||
105 | <name>checked</name> | ||
106 | <bool>true</bool> | ||
107 | </property> | ||
108 | </widget> | ||
109 | </vbox> | ||
110 | </widget> | ||
111 | <widget> | ||
112 | <class>QCheckBox</class> | ||
113 | <property stdset="1"> | ||
114 | <name>name</name> | ||
115 | <cstring>m_useCaseSensitive</cstring> | ||
116 | </property> | ||
117 | <property stdset="1"> | ||
118 | <name>text</name> | ||
119 | <string>Case Sensitive</string> | ||
120 | </property> | ||
121 | </widget> | ||
122 | <widget> | ||
123 | <class>QCheckBox</class> | ||
124 | <property stdset="1"> | ||
125 | <name>name</name> | ||
126 | <cstring>m_signalWrapAround</cstring> | ||
127 | </property> | ||
128 | <property stdset="1"> | ||
129 | <name>text</name> | ||
130 | <string>Signal Wrap Around</string> | ||
131 | </property> | ||
132 | </widget> | ||
133 | <spacer> | ||
134 | <property> | ||
135 | <name>name</name> | ||
136 | <cstring>Spacer3</cstring> | ||
137 | </property> | ||
138 | <property stdset="1"> | ||
139 | <name>orientation</name> | ||
140 | <enum>Vertical</enum> | ||
141 | </property> | ||
142 | <property stdset="1"> | ||
143 | <name>sizeType</name> | ||
144 | <enum>Expanding</enum> | ||
145 | </property> | ||
146 | <property> | ||
147 | <name>sizeHint</name> | ||
148 | <size> | ||
149 | <width>20</width> | ||
150 | <height>20</height> | ||
151 | </size> | ||
152 | </property> | ||
153 | </spacer> | ||
154 | </vbox> | ||
155 | </widget> | ||
156 | </widget> | ||
157 | <widget> | ||
158 | <class>QLayoutWidget</class> | ||
159 | <property stdset="1"> | ||
160 | <name>name</name> | ||
161 | <cstring>Layout1</cstring> | ||
162 | </property> | ||
163 | <hbox> | ||
164 | <property stdset="1"> | ||
165 | <name>margin</name> | ||
166 | <number>0</number> | ||
167 | </property> | ||
168 | <property stdset="1"> | ||
169 | <name>spacing</name> | ||
170 | <number>6</number> | ||
171 | </property> | ||
172 | <widget> | ||
173 | <class>QPushButton</class> | ||
174 | <property stdset="1"> | ||
175 | <name>name</name> | ||
176 | <cstring>buttonOk</cstring> | ||
177 | </property> | ||
178 | <property stdset="1"> | ||
179 | <name>text</name> | ||
180 | <string>&OK</string> | ||
181 | </property> | ||
182 | <property stdset="1"> | ||
183 | <name>autoDefault</name> | ||
184 | <bool>true</bool> | ||
185 | </property> | ||
186 | <property stdset="1"> | ||
187 | <name>default</name> | ||
188 | <bool>true</bool> | ||
189 | </property> | ||
190 | </widget> | ||
191 | <widget> | ||
192 | <class>QPushButton</class> | ||
193 | <property stdset="1"> | ||
194 | <name>name</name> | ||
195 | <cstring>buttonCancel</cstring> | ||
196 | </property> | ||
197 | <property stdset="1"> | ||
198 | <name>text</name> | ||
199 | <string>&Cancel</string> | ||
200 | </property> | ||
201 | <property stdset="1"> | ||
202 | <name>autoDefault</name> | ||
203 | <bool>true</bool> | ||
204 | </property> | ||
205 | </widget> | ||
206 | </hbox> | ||
207 | </widget> | ||
208 | </vbox> | ||
209 | </widget> | ||
210 | <connections> | ||
211 | <connection> | ||
212 | <sender>buttonOk</sender> | ||
213 | <signal>clicked()</signal> | ||
214 | <receiver>Configuration</receiver> | ||
215 | <slot>accept()</slot> | ||
216 | </connection> | ||
217 | <connection> | ||
218 | <sender>buttonCancel</sender> | ||
219 | <signal>clicked()</signal> | ||
220 | <receiver>Configuration</receiver> | ||
221 | <slot>reject()</slot> | ||
222 | </connection> | ||
223 | </connections> | ||
224 | <tabstops> | ||
225 | <tabstop>configDlg_base</tabstop> | ||
226 | <tabstop>m_useWildCard</tabstop> | ||
227 | <tabstop>m_useCaseSensitive</tabstop> | ||
228 | <tabstop>m_signalWrapAround</tabstop> | ||
229 | <tabstop>buttonOk</tabstop> | ||
230 | <tabstop>buttonCancel</tabstop> | ||
231 | </tabstops> | ||
232 | </UI> | ||
diff --git a/core/pim/addressbook/ofloatbar.h b/core/pim/addressbook/ofloatbar.h index 85a0c4f..f9c49d6 100644 --- a/core/pim/addressbook/ofloatbar.h +++ b/core/pim/addressbook/ofloatbar.h | |||
@@ -1,20 +1,20 @@ | |||
1 | #ifndef __OFLOATBAR_H | 1 | #ifndef __OFLOATBAR_H |
2 | #define __OFLOATBAR_H | 2 | #define __OFLOATBAR_H |
3 | 3 | ||
4 | #include <qtoolbar.h> | 4 | #include <qtoolbar.h> |
5 | #include <qevent.h> | 5 | #include <qevent.h> |
6 | 6 | ||
7 | class OFloatBar : public QToolBar | 7 | class OFloatBar : public QToolBar |
8 | { | 8 | { |
9 | Q_OBJECT | 9 | Q_OBJECT |
10 | virtual void hideEvent(QHideEvent* e) | 10 | virtual void hideEvent(QHideEvent* /* e */) |
11 | { | 11 | { |
12 | /*if (e->spontaneous())*/ emit OnHide(); | 12 | /*if (e->spontaneous())*/ emit OnHide(); |
13 | } | 13 | } |
14 | public: | 14 | public: |
15 | OFloatBar(char* t, QMainWindow* mw, QMainWindow::ToolBarDock td, bool f) : QToolBar(t, mw, td, f) {} | 15 | OFloatBar(char* t, QMainWindow* mw, QMainWindow::ToolBarDock td, bool f) : QToolBar(t, mw, td, f) {} |
16 | signals: | 16 | signals: |
17 | void OnHide(); | 17 | void OnHide(); |
18 | }; | 18 | }; |
19 | 19 | ||
20 | #endif | 20 | #endif |