author | eilers <eilers> | 2002-10-22 12:34:54 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-10-22 12:34:54 (UTC) |
commit | 78152b3adbe3ae4626c8f53e3edd0babcaf6fb72 (patch) (unidiff) | |
tree | 89b0b4ffea2fa1efd4eb7dc50545661d3ceeb65d | |
parent | 486280adc2ab5dc383a56d8516c36727eb382812 (diff) | |
download | opie-78152b3adbe3ae4626c8f53e3edd0babcaf6fb72.zip opie-78152b3adbe3ae4626c8f53e3edd0babcaf6fb72.tar.gz opie-78152b3adbe3ae4626c8f53e3edd0babcaf6fb72.tar.bz2 |
Find bugfix. Tried to make the letterpicker more visible due to
undelign does not work on my Z.. :(
Added use of alternative mail-application (opie-mail instead of QT-Mail)
-rw-r--r-- | core/pim/addressbook/TODO | 7 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 76 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 47 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.h | 3 | ||||
-rw-r--r-- | core/pim/addressbook/configdlg.cpp | 16 | ||||
-rw-r--r-- | core/pim/addressbook/configdlg.h | 4 | ||||
-rw-r--r-- | core/pim/addressbook/configdlg_base.ui | 105 | ||||
-rw-r--r-- | core/pim/addressbook/opie-addressbook.control | 2 | ||||
-rw-r--r-- | core/pim/addressbook/picker.cpp | 12 |
9 files changed, 227 insertions, 45 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO index 796dc49..80ec2d9 100644 --- a/core/pim/addressbook/TODO +++ b/core/pim/addressbook/TODO | |||
@@ -1,36 +1,39 @@ | |||
1 | Stuff todo until OPIE 1.0 : | 1 | Stuff todo until OPIE 1.0 : |
2 | 2 | ||
3 | Pending bugfixes from previous work: | ||
4 | |||
3 | Urgent: | 5 | Urgent: |
4 | 6 | ||
5 | - Font menu is invisible using german translation | 7 | - Font menu is invisible using german translation |
6 | 8 | ||
7 | Important: | 9 | Important: |
8 | 10 | ||
11 | - Overview window cleanup needed.. | ||
9 | - Cursor keys should work in detail-view (ablabel) | 12 | - Cursor keys should work in detail-view (ablabel) |
10 | - "What's this" should be added | 13 | - "What's this" should be added |
11 | - Store last settings of combo-boxes | 14 | - Store last settings of combo-boxes |
12 | - Mail-Icon is missing | ||
13 | - Overview window cleanup needed.. | ||
14 | - Finishing of new View functions (List, Phonebook...) | 15 | - Finishing of new View functions (List, Phonebook...) |
15 | - The names of the countries are sorted by there english names, only.. | 16 | - The names of the countries are sorted by there english names, only.. |
16 | Even if they are translated.. :S | 17 | Even if they are translated.. :S |
17 | - Reload if contacts were changed externally | 18 | - Reload if contacts were changed externally |
18 | 19 | ||
19 | Less important: | 20 | Less important: |
20 | 21 | ||
21 | - The picker (alphabetical sort widget) should be | 22 | - The picker (alphabetical sort widget) should be |
22 | placed verticaly or horizontally (configurable) | 23 | placed verticaly or horizontally (configurable) |
23 | - Use advanced database functions in abtable to decrease | 24 | - Use advanced database functions in abtable to decrease |
24 | memory footprint and to make everything more easy ! | 25 | memory footprint and to make everything more easy ! |
25 | (abtable should store Iterator for selected Category) | 26 | (abtable should store Iterator for selected Category) |
26 | 27 | ||
27 | Should be Fixed (not absolute sure, need further validation): | 28 | Should be Fixed (not absolute sure, need further validation): |
28 | - "Nonenglish" translation bug has to be fixed. | 29 | - "Nonenglish" translation bug has to be fixed. |
29 | 30 | ||
30 | Fixed: | 31 | Fixed: |
31 | - Syncing: abtable not reloaded after sync. | 32 | - Syncing: abtable not reloaded after sync. |
32 | - Find widget should be replaced by something like | 33 | - Find widget should be replaced by something like |
33 | qpdf has. | 34 | qpdf has. |
34 | - Adding a configuration dialog | 35 | - Adding a configuration dialog |
35 | - Picker: Activated letter schould be more visible | 36 | - Picker: Activated letter schould be more visible |
36 | - Advanced handling of cursor keys (search..) | 37 | - Advanced handling of cursor keys (search..) |
38 | - Mail-Icon is missing | ||
39 | - Use opie-mail insted of qt-mail if possible. | ||
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 97b26db..4feadeb 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -1,1043 +1,1055 @@ | |||
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( -1 ), | 131 | currFindRow( -1 ), |
132 | mCat( 0 ), | 132 | mCat( 0 ), |
133 | m_inSearch (false), | 133 | m_inSearch (false), |
134 | m_contactdb ("addressbook", 0l, 0l, false) // Handle syncing myself.. ! | 134 | m_contactdb ("addressbook", 0l, 0l, false) // Handle syncing myself.. ! |
135 | { | 135 | { |
136 | mCat.load( categoryFileName() ); | 136 | mCat.load( categoryFileName() ); |
137 | setSelectionMode( NoSelection ); | 137 | setSelectionMode( NoSelection ); |
138 | init(); | 138 | init(); |
139 | setSorting( TRUE ); | 139 | setSorting( TRUE ); |
140 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), | 140 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), |
141 | this, SLOT(itemClicked(int,int)) ); | 141 | this, SLOT(itemClicked(int,int)) ); |
142 | } | 142 | } |
143 | 143 | ||
144 | AbTable::~AbTable() | 144 | AbTable::~AbTable() |
145 | { | 145 | { |
146 | } | 146 | } |
147 | 147 | ||
148 | void AbTable::init() | 148 | void AbTable::init() |
149 | { | 149 | { |
150 | showChar = '\0'; | 150 | showChar = '\0'; |
151 | setNumRows( 0 ); | 151 | setNumRows( 0 ); |
152 | setNumCols( 2 ); | 152 | setNumCols( 2 ); |
153 | 153 | ||
154 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); | 154 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); |
155 | horizontalHeader()->setLabel( 1, tr( "Contact" )); | 155 | horizontalHeader()->setLabel( 1, tr( "Contact" )); |
156 | setLeftMargin( 0 ); | 156 | setLeftMargin( 0 ); |
157 | verticalHeader()->hide(); | 157 | verticalHeader()->hide(); |
158 | columnVisible = true; | 158 | columnVisible = true; |
159 | } | 159 | } |
160 | 160 | ||
161 | void AbTable::columnClicked( int col ) | 161 | void AbTable::columnClicked( int col ) |
162 | { | 162 | { |
163 | if ( !sorting() ) | 163 | if ( !sorting() ) |
164 | return; | 164 | return; |
165 | 165 | ||
166 | if ( lastSortCol == -1 ) | 166 | if ( lastSortCol == -1 ) |
167 | lastSortCol = col; | 167 | lastSortCol = col; |
168 | 168 | ||
169 | if ( col == lastSortCol ) { | 169 | if ( col == lastSortCol ) { |
170 | asc = !asc; | 170 | asc = !asc; |
171 | } else { | 171 | } else { |
172 | lastSortCol = col; | 172 | lastSortCol = col; |
173 | asc = TRUE; | 173 | asc = TRUE; |
174 | } | 174 | } |
175 | //QMessageBox::information( this, "resort", "columnClicked" ); | 175 | //QMessageBox::information( this, "resort", "columnClicked" ); |
176 | resort(); | 176 | resort(); |
177 | } | 177 | } |
178 | 178 | ||
179 | void AbTable::resort() | 179 | void AbTable::resort() |
180 | { | 180 | { |
181 | if ( sorting() ) { | 181 | if ( sorting() ) { |
182 | if ( lastSortCol == -1 ) | 182 | if ( lastSortCol == -1 ) |
183 | lastSortCol = 0; | 183 | lastSortCol = 0; |
184 | sortColumn( lastSortCol, asc, TRUE ); | 184 | sortColumn( lastSortCol, asc, TRUE ); |
185 | //QMessageBox::information( this, "resort", "resort" ); | 185 | //QMessageBox::information( this, "resort", "resort" ); |
186 | updateVisible(); | 186 | updateVisible(); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | OContact AbTable::currentEntry() | 190 | OContact AbTable::currentEntry() |
191 | { | 191 | { |
192 | OContact cnt; | 192 | OContact cnt; |
193 | AbTableItem *abItem; | 193 | AbTableItem *abItem; |
194 | abItem = static_cast<AbTableItem*>(item( currentRow(), 0 )); | 194 | abItem = static_cast<AbTableItem*>(item( currentRow(), 0 )); |
195 | if ( abItem ) { | 195 | if ( abItem ) { |
196 | cnt = contactList[abItem]; | 196 | cnt = contactList[abItem]; |
197 | //cnt = contactList[currentRow()]; | 197 | //cnt = contactList[currentRow()]; |
198 | } | 198 | } |
199 | return cnt; | 199 | return cnt; |
200 | } | 200 | } |
201 | 201 | ||
202 | void AbTable::replaceCurrentEntry( const OContact &newContact ) | 202 | void AbTable::replaceCurrentEntry( const OContact &newContact ) |
203 | { | 203 | { |
204 | int row = currentRow(); | 204 | int row = currentRow(); |
205 | updateVisible(); | 205 | updateVisible(); |
206 | 206 | ||
207 | journalFreeReplace( newContact, row ); | 207 | journalFreeReplace( newContact, row ); |
208 | 208 | ||
209 | } | 209 | } |
210 | 210 | ||
211 | void AbTable::deleteCurrentEntry() | 211 | void AbTable::deleteCurrentEntry() |
212 | { | 212 | { |
213 | int row = currentRow(); | 213 | int row = currentRow(); |
214 | 214 | ||
215 | // a little wasteful, but it ensure's there is only one place | 215 | // a little wasteful, but it ensure's there is only one place |
216 | // where we delete. | 216 | // where we delete. |
217 | journalFreeRemove( row ); | 217 | journalFreeRemove( row ); |
218 | updateVisible(); | 218 | updateVisible(); |
219 | 219 | ||
220 | if ( numRows() == 0 ) | 220 | if ( numRows() == 0 ) |
221 | emit empty( TRUE ); | 221 | emit empty( TRUE ); |
222 | 222 | ||
223 | } | 223 | } |
224 | 224 | ||
225 | void AbTable::clear() | 225 | void AbTable::clear() |
226 | { | 226 | { |
227 | contactList.clear(); | 227 | contactList.clear(); |
228 | for ( int r = 0; r < numRows(); ++r ) { | 228 | for ( int r = 0; r < numRows(); ++r ) { |
229 | for ( int c = 0; c < numCols(); ++c ) { | 229 | for ( int c = 0; c < numCols(); ++c ) { |
230 | if ( cellWidget( r, c ) ) | 230 | if ( cellWidget( r, c ) ) |
231 | clearCellWidget( r, c ); | 231 | clearCellWidget( r, c ); |
232 | clearCell( r, c ); | 232 | clearCell( r, c ); |
233 | } | 233 | } |
234 | } | 234 | } |
235 | setNumRows( 0 ); | 235 | setNumRows( 0 ); |
236 | } | 236 | } |
237 | 237 | ||
238 | void AbTable::refresh() | 238 | void AbTable::refresh() |
239 | { | 239 | { |
240 | int rows = numRows(); | 240 | int rows = numRows(); |
241 | QString value; | 241 | QString value; |
242 | AbTableItem *abi; | 242 | AbTableItem *abi; |
243 | 243 | ||
244 | // hide columns so no flashing ? | 244 | // hide columns so no flashing ? |
245 | if ( showBk == "Cards" ) { | 245 | if ( showBk == "Cards" ) { |
246 | hideColumn(0); | 246 | hideColumn(0); |
247 | hideColumn(1); | 247 | hideColumn(1); |
248 | } | 248 | } |
249 | for ( int r = 0; r < rows; ++r ) { | 249 | for ( int r = 0; r < rows; ++r ) { |
250 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 250 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
251 | value = findContactContact( contactList[abi], r ); | 251 | value = findContactContact( contactList[abi], r ); |
252 | static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); | 252 | static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); |
253 | } | 253 | } |
254 | resort(); | 254 | resort(); |
255 | } | 255 | } |
256 | 256 | ||
257 | void AbTable::keyPressEvent( QKeyEvent *e ) | 257 | void AbTable::keyPressEvent( QKeyEvent *e ) |
258 | { | 258 | { |
259 | char key = toupper( e->ascii() ); | 259 | char key = toupper( e->ascii() ); |
260 | 260 | ||
261 | if ( key >= 'A' && key <= 'Z' ) | 261 | if ( key >= 'A' && key <= 'Z' ) |
262 | moveTo( key ); | 262 | moveTo( key ); |
263 | 263 | ||
264 | if ( m_inSearch ) { | 264 | if ( m_inSearch ) { |
265 | // Running in seach-mode, therefore we will interprete | 265 | // Running in seach-mode, therefore we will interprete |
266 | // some key differently | 266 | // some key differently |
267 | qWarning("Received key in search mode"); | 267 | qWarning("Received key in search mode"); |
268 | switch( e->key() ) { | 268 | switch( e->key() ) { |
269 | case Qt::Key_Space: | 269 | case Qt::Key_Space: |
270 | case Qt::Key_Return: | 270 | case Qt::Key_Return: |
271 | case Qt::Key_Enter: | 271 | case Qt::Key_Enter: |
272 | emit details(); | 272 | emit details(); |
273 | break; | 273 | break; |
274 | case Qt::Key_Up: | 274 | case Qt::Key_Up: |
275 | qWarning("a"); | 275 | qWarning("a"); |
276 | emit signalSearchBackward(); | 276 | emit signalSearchBackward(); |
277 | break; | 277 | break; |
278 | case Qt::Key_Down: | 278 | case Qt::Key_Down: |
279 | qWarning("b"); | 279 | qWarning("b"); |
280 | emit signalSearchNext(); | 280 | emit signalSearchNext(); |
281 | break; | 281 | break; |
282 | default: | 282 | default: |
283 | QTable::keyPressEvent( e ); | 283 | QTable::keyPressEvent( e ); |
284 | } | 284 | } |
285 | 285 | ||
286 | } else { | 286 | } else { |
287 | qWarning("Received key in NON search mode"); | 287 | qWarning("Received key in NON search mode"); |
288 | 288 | ||
289 | switch( e->key() ) { | 289 | switch( e->key() ) { |
290 | case Qt::Key_Space: | 290 | case Qt::Key_Space: |
291 | case Qt::Key_Return: | 291 | case Qt::Key_Return: |
292 | case Qt::Key_Enter: | 292 | case Qt::Key_Enter: |
293 | emit details(); | 293 | emit details(); |
294 | break; | 294 | break; |
295 | default: | 295 | default: |
296 | QTable::keyPressEvent( e ); | 296 | QTable::keyPressEvent( e ); |
297 | } | 297 | } |
298 | } | 298 | } |
299 | } | 299 | } |
300 | 300 | ||
301 | void AbTable::moveTo( char c ) | 301 | void AbTable::moveTo( char c ) |
302 | { | 302 | { |
303 | 303 | ||
304 | int rows = numRows(); | 304 | int rows = numRows(); |
305 | QString value; | 305 | QString value; |
306 | AbTableItem *abi; | 306 | AbTableItem *abi; |
307 | int r; | 307 | int r; |
308 | if ( asc ) { | 308 | if ( asc ) { |
309 | r = 0; | 309 | r = 0; |
310 | while ( r < rows-1) { | 310 | while ( r < rows-1) { |
311 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 311 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
312 | QChar first = abi->key()[0]; | 312 | QChar first = abi->key()[0]; |
313 | //### is there a bug in QChar to char comparison??? | 313 | //### is there a bug in QChar to char comparison??? |
314 | if ( first.row() || first.cell() >= c ) | 314 | if ( first.row() || first.cell() >= c ) |
315 | break; | 315 | break; |
316 | r++; | 316 | r++; |
317 | } | 317 | } |
318 | } else { | 318 | } else { |
319 | //### should probably disable reverse sorting instead | 319 | //### should probably disable reverse sorting instead |
320 | r = rows - 1; | 320 | r = rows - 1; |
321 | while ( r > 0 ) { | 321 | while ( r > 0 ) { |
322 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 322 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
323 | QChar first = abi->key()[0]; | 323 | QChar first = abi->key()[0]; |
324 | //### is there a bug in QChar to char comparison??? | 324 | //### is there a bug in QChar to char comparison??? |
325 | if ( first.row() || first.cell() >= c ) | 325 | if ( first.row() || first.cell() >= c ) |
326 | break; | 326 | break; |
327 | r--; | 327 | r--; |
328 | } | 328 | } |
329 | } | 329 | } |
330 | setCurrentCell( r, currentColumn() ); | 330 | setCurrentCell( r, currentColumn() ); |
331 | } | 331 | } |
332 | 332 | ||
333 | 333 | ||
334 | QString AbTable::findContactName( const OContact &entry ) | 334 | QString AbTable::findContactName( const OContact &entry ) |
335 | { | 335 | { |
336 | // We use the fileAs, then company, defaultEmail | 336 | // We use the fileAs, then company, defaultEmail |
337 | QString str; | 337 | QString str; |
338 | str = entry.fileAs(); | 338 | str = entry.fileAs(); |
339 | if ( str.isEmpty() ) { | 339 | if ( str.isEmpty() ) { |
340 | str = entry.company(); | 340 | str = entry.company(); |
341 | if ( str.isEmpty() ) { | 341 | if ( str.isEmpty() ) { |
342 | str = entry.defaultEmail(); | 342 | str = entry.defaultEmail(); |
343 | } | 343 | } |
344 | } | 344 | } |
345 | return str; | 345 | return str; |
346 | } | 346 | } |
347 | 347 | ||
348 | QString AbTable::findContactContact( const OContact &entry, int /* row */ ) | 348 | QString AbTable::findContactContact( const OContact &entry, int /* row */ ) |
349 | { | 349 | { |
350 | QString value; | 350 | QString value; |
351 | value = ""; | 351 | value = ""; |
352 | for ( QValueList<int>::ConstIterator it = intFields->begin(); | 352 | for ( QValueList<int>::ConstIterator it = intFields->begin(); |
353 | it != intFields->end(); ++it ) { | 353 | it != intFields->end(); ++it ) { |
354 | switch ( *it ) { | 354 | switch ( *it ) { |
355 | default: | 355 | default: |
356 | break; | 356 | break; |
357 | case Qtopia::Title: | 357 | case Qtopia::Title: |
358 | value = entry.title(); | 358 | value = entry.title(); |
359 | break; | 359 | break; |
360 | case Qtopia::Suffix: | 360 | case Qtopia::Suffix: |
361 | value = entry.suffix(); | 361 | value = entry.suffix(); |
362 | break; | 362 | break; |
363 | case Qtopia::FileAs: | 363 | case Qtopia::FileAs: |
364 | value = entry.fileAs(); | 364 | value = entry.fileAs(); |
365 | break; | 365 | break; |
366 | case Qtopia::DefaultEmail: | 366 | case Qtopia::DefaultEmail: |
367 | value = entry.defaultEmail(); | 367 | value = entry.defaultEmail(); |
368 | case Qtopia::Emails: | 368 | case Qtopia::Emails: |
369 | value = entry.emails(); | 369 | value = entry.emails(); |
370 | break; | 370 | break; |
371 | case Qtopia::HomeStreet: | 371 | case Qtopia::HomeStreet: |
372 | value = entry.homeStreet(); | 372 | value = entry.homeStreet(); |
373 | break; | 373 | break; |
374 | case Qtopia::HomeCity: | 374 | case Qtopia::HomeCity: |
375 | value = entry.homeCity(); | 375 | value = entry.homeCity(); |
376 | break; | 376 | break; |
377 | case Qtopia::HomeState: | 377 | case Qtopia::HomeState: |
378 | value = entry.homeState(); | 378 | value = entry.homeState(); |
379 | break; | 379 | break; |
380 | case Qtopia::HomeZip: | 380 | case Qtopia::HomeZip: |
381 | value = entry.homeZip(); | 381 | value = entry.homeZip(); |
382 | break; | 382 | break; |
383 | case Qtopia::HomeCountry: | 383 | case Qtopia::HomeCountry: |
384 | value = entry.homeCountry(); | 384 | value = entry.homeCountry(); |
385 | break; | 385 | break; |
386 | case Qtopia::HomePhone: | 386 | case Qtopia::HomePhone: |
387 | value = entry.homePhone(); | 387 | value = entry.homePhone(); |
388 | break; | 388 | break; |
389 | case Qtopia::HomeFax: | 389 | case Qtopia::HomeFax: |
390 | value = entry.homeFax(); | 390 | value = entry.homeFax(); |
391 | break; | 391 | break; |
392 | case Qtopia::HomeMobile: | 392 | case Qtopia::HomeMobile: |
393 | value = entry.homeMobile(); | 393 | value = entry.homeMobile(); |
394 | break; | 394 | break; |
395 | case Qtopia::HomeWebPage: | 395 | case Qtopia::HomeWebPage: |
396 | value = entry.homeWebpage(); | 396 | value = entry.homeWebpage(); |
397 | break; | 397 | break; |
398 | case Qtopia::Company: | 398 | case Qtopia::Company: |
399 | value = entry.company(); | 399 | value = entry.company(); |
400 | break; | 400 | break; |
401 | case Qtopia::BusinessCity: | 401 | case Qtopia::BusinessCity: |
402 | value = entry.businessCity(); | 402 | value = entry.businessCity(); |
403 | break; | 403 | break; |
404 | case Qtopia::BusinessStreet: | 404 | case Qtopia::BusinessStreet: |
405 | value = entry.businessStreet(); | 405 | value = entry.businessStreet(); |
406 | break; | 406 | break; |
407 | case Qtopia::BusinessZip: | 407 | case Qtopia::BusinessZip: |
408 | value = entry.businessZip(); | 408 | value = entry.businessZip(); |
409 | break; | 409 | break; |
410 | case Qtopia::BusinessCountry: | 410 | case Qtopia::BusinessCountry: |
411 | value = entry.businessCountry(); | 411 | value = entry.businessCountry(); |
412 | break; | 412 | break; |
413 | case Qtopia::BusinessWebPage: | 413 | case Qtopia::BusinessWebPage: |
414 | value = entry.businessWebpage(); | 414 | value = entry.businessWebpage(); |
415 | break; | 415 | break; |
416 | case Qtopia::JobTitle: | 416 | case Qtopia::JobTitle: |
417 | value = entry.jobTitle(); | 417 | value = entry.jobTitle(); |
418 | break; | 418 | break; |
419 | case Qtopia::Department: | 419 | case Qtopia::Department: |
420 | value = entry.department(); | 420 | value = entry.department(); |
421 | break; | 421 | break; |
422 | case Qtopia::Office: | 422 | case Qtopia::Office: |
423 | value = entry.office(); | 423 | value = entry.office(); |
424 | break; | 424 | break; |
425 | case Qtopia::BusinessPhone: | 425 | case Qtopia::BusinessPhone: |
426 | value = entry.businessPhone(); | 426 | value = entry.businessPhone(); |
427 | break; | 427 | break; |
428 | case Qtopia::BusinessFax: | 428 | case Qtopia::BusinessFax: |
429 | value = entry.businessFax(); | 429 | value = entry.businessFax(); |
430 | break; | 430 | break; |
431 | case Qtopia::BusinessMobile: | 431 | case Qtopia::BusinessMobile: |
432 | value = entry.businessMobile(); | 432 | value = entry.businessMobile(); |
433 | break; | 433 | break; |
434 | case Qtopia::BusinessPager: | 434 | case Qtopia::BusinessPager: |
435 | value = entry.businessPager(); | 435 | value = entry.businessPager(); |
436 | break; | 436 | break; |
437 | case Qtopia::Profession: | 437 | case Qtopia::Profession: |
438 | value = entry.profession(); | 438 | value = entry.profession(); |
439 | break; | 439 | break; |
440 | case Qtopia::Assistant: | 440 | case Qtopia::Assistant: |
441 | value = entry.assistant(); | 441 | value = entry.assistant(); |
442 | break; | 442 | break; |
443 | case Qtopia::Manager: | 443 | case Qtopia::Manager: |
444 | value = entry.manager(); | 444 | value = entry.manager(); |
445 | break; | 445 | break; |
446 | case Qtopia::Spouse: | 446 | case Qtopia::Spouse: |
447 | value = entry.spouse(); | 447 | value = entry.spouse(); |
448 | break; | 448 | break; |
449 | case Qtopia::Gender: | 449 | case Qtopia::Gender: |
450 | value = entry.gender(); | 450 | value = entry.gender(); |
451 | break; | 451 | break; |
452 | case Qtopia::Birthday: | 452 | case Qtopia::Birthday: |
453 | value = entry.birthday(); | 453 | value = entry.birthday(); |
454 | break; | 454 | break; |
455 | case Qtopia::Anniversary: | 455 | case Qtopia::Anniversary: |
456 | value = entry.anniversary(); | 456 | value = entry.anniversary(); |
457 | break; | 457 | break; |
458 | case Qtopia::Nickname: | 458 | case Qtopia::Nickname: |
459 | value = entry.nickname(); | 459 | value = entry.nickname(); |
460 | break; | 460 | break; |
461 | case Qtopia::Children: | 461 | case Qtopia::Children: |
462 | value = entry.children(); | 462 | value = entry.children(); |
463 | break; | 463 | break; |
464 | case Qtopia::Notes: | 464 | case Qtopia::Notes: |
465 | value = entry.notes(); | 465 | value = entry.notes(); |
466 | break; | 466 | break; |
467 | } | 467 | } |
468 | if ( !value.isEmpty() ) | 468 | if ( !value.isEmpty() ) |
469 | break; | 469 | break; |
470 | } | 470 | } |
471 | return value; | 471 | return value; |
472 | } | 472 | } |
473 | 473 | ||
474 | void AbTable::addEntry( const OContact &newCnt ) | 474 | void AbTable::addEntry( const OContact &newCnt ) |
475 | { | 475 | { |
476 | int row = numRows(); | 476 | int row = numRows(); |
477 | 477 | ||
478 | setNumRows( row + 1 ); | 478 | setNumRows( row + 1 ); |
479 | insertIntoTable( newCnt, row ); | 479 | insertIntoTable( newCnt, row ); |
480 | 480 | ||
481 | qWarning("abtable:AddContact"); | 481 | qWarning("abtable:AddContact"); |
482 | m_contactdb.add ( newCnt ); | 482 | m_contactdb.add ( newCnt ); |
483 | 483 | ||
484 | setCurrentCell( row, 0 ); | 484 | setCurrentCell( row, 0 ); |
485 | // updateVisible(); | 485 | // updateVisible(); |
486 | } | 486 | } |
487 | 487 | ||
488 | void AbTable::resizeRows() { | 488 | void AbTable::resizeRows() { |
489 | /* | 489 | /* |
490 | if (numRows()) { | 490 | if (numRows()) { |
491 | for (int i = 0; i < numRows(); i++) { | 491 | for (int i = 0; i < numRows(); i++) { |
492 | setRowHeight( i, size ); | 492 | setRowHeight( i, size ); |
493 | } | 493 | } |
494 | } | 494 | } |
495 | updateVisible(); | 495 | updateVisible(); |
496 | */ | 496 | */ |
497 | } | 497 | } |
498 | 498 | ||
499 | 499 | ||
500 | bool AbTable::save() | 500 | bool AbTable::save() |
501 | { | 501 | { |
502 | // QTime t; | 502 | // QTime t; |
503 | // t.start(); | 503 | // t.start(); |
504 | qWarning("abtable:Save data"); | 504 | qWarning("abtable:Save data"); |
505 | 505 | ||
506 | return m_contactdb.save(); | 506 | return m_contactdb.save(); |
507 | } | 507 | } |
508 | 508 | ||
509 | void AbTable::load() | 509 | void AbTable::load() |
510 | { | 510 | { |
511 | setSorting( false ); | 511 | setSorting( false ); |
512 | setUpdatesEnabled( FALSE ); | 512 | setUpdatesEnabled( FALSE ); |
513 | 513 | ||
514 | qWarning("abtable:Load data"); | 514 | qWarning("abtable:Load data"); |
515 | 515 | ||
516 | OContactAccess::List list = m_contactdb.allRecords(); | 516 | OContactAccess::List list = m_contactdb.allRecords(); |
517 | OContactAccess::List::Iterator it; | 517 | OContactAccess::List::Iterator it; |
518 | setNumRows( list.count() ); | 518 | setNumRows( list.count() ); |
519 | int row = 0; | 519 | int row = 0; |
520 | for ( it = list.begin(); it != list.end(); ++it ) | 520 | for ( it = list.begin(); it != list.end(); ++it ) |
521 | insertIntoTable( *it, row++ ); | 521 | insertIntoTable( *it, row++ ); |
522 | 522 | ||
523 | setUpdatesEnabled( TRUE ); | 523 | setUpdatesEnabled( TRUE ); |
524 | 524 | ||
525 | setSorting( true ); | 525 | setSorting( true ); |
526 | resort(); | 526 | resort(); |
527 | } | 527 | } |
528 | 528 | ||
529 | 529 | ||
530 | void AbTable::reload() | 530 | void AbTable::reload() |
531 | { | 531 | { |
532 | m_contactdb.reload(); | 532 | m_contactdb.reload(); |
533 | load(); | 533 | load(); |
534 | } | 534 | } |
535 | 535 | ||
536 | void AbTable::realignTable( int row ) | 536 | void AbTable::realignTable( int row ) |
537 | { | 537 | { |
538 | QTableItem *ti1, | 538 | QTableItem *ti1, |
539 | *ti2; | 539 | *ti2; |
540 | int totalRows = numRows(); | 540 | int totalRows = numRows(); |
541 | for ( int curr = row; curr < totalRows - 1; curr++ ) { | 541 | for ( int curr = row; curr < totalRows - 1; curr++ ) { |
542 | // the same info from the todo list still applies, but I | 542 | // the same info from the todo list still applies, but I |
543 | // don't think it is _too_ bad. | 543 | // don't think it is _too_ bad. |
544 | ti1 = item( curr + 1, 0 ); | 544 | ti1 = item( curr + 1, 0 ); |
545 | ti2 = item( curr + 1, 1 ); | 545 | ti2 = item( curr + 1, 1 ); |
546 | takeItem( ti1 ); | 546 | takeItem( ti1 ); |
547 | takeItem( ti2 ); | 547 | takeItem( ti2 ); |
548 | setItem( curr, 0, ti1 ); | 548 | setItem( curr, 0, ti1 ); |
549 | setItem( curr, 1, ti2 ); | 549 | setItem( curr, 1, ti2 ); |
550 | } | 550 | } |
551 | setNumRows( totalRows - 1 ); | 551 | setNumRows( totalRows - 1 ); |
552 | resort(); | 552 | resort(); |
553 | } | 553 | } |
554 | 554 | ||
555 | // Add contact into table. | 555 | // Add contact into table. |
556 | void AbTable::insertIntoTable( const OContact &cnt, int row ) | 556 | void AbTable::insertIntoTable( const OContact &cnt, int row ) |
557 | { | 557 | { |
558 | QString strName, | 558 | QString strName, |
559 | strContact; | 559 | strContact; |
560 | 560 | ||
561 | strName = findContactName( cnt ); | 561 | strName = findContactName( cnt ); |
562 | strContact = findContactContact( cnt, row ); | 562 | strContact = findContactContact( cnt, row ); |
563 | 563 | ||
564 | AbTableItem *ati; | 564 | AbTableItem *ati; |
565 | ati = new AbTableItem( this, QTableItem::Never, strName, strContact); | 565 | ati = new AbTableItem( this, QTableItem::Never, strName, strContact); |
566 | contactList.insert( ati, cnt ); | 566 | contactList.insert( ati, cnt ); |
567 | setItem( row, 0, ati ); | 567 | setItem( row, 0, ati ); |
568 | ati = new AbTableItem( this, QTableItem::Never, strContact, strName); | 568 | ati = new AbTableItem( this, QTableItem::Never, strContact, strName); |
569 | setItem( row, 1, ati ); | 569 | setItem( row, 1, ati ); |
570 | 570 | ||
571 | //### cannot do this; table only has two columns at this point | 571 | //### cannot do this; table only has two columns at this point |
572 | // setItem( row, 2, new AbPickItem( this ) ); | 572 | // setItem( row, 2, new AbPickItem( this ) ); |
573 | 573 | ||
574 | // resort at some point? | 574 | // resort at some point? |
575 | } | 575 | } |
576 | 576 | ||
577 | 577 | ||
578 | // Replace or add an entry | 578 | // Replace or add an entry |
579 | void AbTable::journalFreeReplace( const OContact &cnt, int row ) | 579 | void AbTable::journalFreeReplace( const OContact &cnt, int row ) |
580 | { | 580 | { |
581 | QString strName, | 581 | QString strName, |
582 | strContact; | 582 | strContact; |
583 | AbTableItem *ati = 0l; | 583 | AbTableItem *ati = 0l; |
584 | 584 | ||
585 | strName = findContactName( cnt ); | 585 | strName = findContactName( cnt ); |
586 | strContact = findContactContact( cnt, row ); | 586 | strContact = findContactContact( cnt, row ); |
587 | ati = static_cast<AbTableItem*>(item(row, 0)); | 587 | ati = static_cast<AbTableItem*>(item(row, 0)); |
588 | 588 | ||
589 | // Replace element if found in row "row" | 589 | // Replace element if found in row "row" |
590 | // or add this element if not. | 590 | // or add this element if not. |
591 | if ( ati != 0 ) { // replace | 591 | if ( ati != 0 ) { // replace |
592 | // :SX db access -> replace | 592 | // :SX db access -> replace |
593 | qWarning ("Replace Contact in DB ! UID: %d", contactList[ati].uid() ); | 593 | qWarning ("Replace Contact in DB ! UID: %d", contactList[ati].uid() ); |
594 | m_contactdb.replace ( cnt ); | 594 | m_contactdb.replace ( cnt ); |
595 | 595 | ||
596 | contactList.remove( ati ); | 596 | contactList.remove( ati ); |
597 | ati->setItem( strName, strContact ); | 597 | ati->setItem( strName, strContact ); |
598 | contactList.insert( ati, cnt ); | 598 | contactList.insert( ati, cnt ); |
599 | 599 | ||
600 | ati = static_cast<AbTableItem*>(item(row, 1)); | 600 | ati = static_cast<AbTableItem*>(item(row, 1)); |
601 | ati->setItem( strContact, strName ); | 601 | ati->setItem( strContact, strName ); |
602 | 602 | ||
603 | }else{ // add | 603 | }else{ // add |
604 | int myrows = numRows(); | 604 | int myrows = numRows(); |
605 | setNumRows( myrows + 1 ); | 605 | setNumRows( myrows + 1 ); |
606 | insertIntoTable( cnt, myrows ); | 606 | insertIntoTable( cnt, myrows ); |
607 | // gets deleted when returning -- Why ? (se) | 607 | // gets deleted when returning -- Why ? (se) |
608 | // :SX db access -> add | 608 | // :SX db access -> add |
609 | qWarning ("Are you sure to add to database ? -> Currently disabled !!"); | 609 | qWarning ("Are you sure to add to database ? -> Currently disabled !!"); |
610 | // m_contactdb.add( cnt ); | 610 | // m_contactdb.add( cnt ); |
611 | } | 611 | } |
612 | } | 612 | } |
613 | 613 | ||
614 | // Remove entry | 614 | // Remove entry |
615 | void AbTable::journalFreeRemove( int row ) | 615 | void AbTable::journalFreeRemove( int row ) |
616 | { | 616 | { |
617 | AbTableItem *ati; | 617 | AbTableItem *ati; |
618 | ati = static_cast<AbTableItem*>(item(row, 0)); | 618 | ati = static_cast<AbTableItem*>(item(row, 0)); |
619 | if ( !ati ) | 619 | if ( !ati ) |
620 | return; | 620 | return; |
621 | 621 | ||
622 | // :SX db access -> remove | 622 | // :SX db access -> remove |
623 | qWarning ("Remove Contact from DB ! UID: %d",contactList[ati].uid() ); | 623 | qWarning ("Remove Contact from DB ! UID: %d",contactList[ati].uid() ); |
624 | m_contactdb.remove( contactList[ati].uid() ); | 624 | m_contactdb.remove( contactList[ati].uid() ); |
625 | 625 | ||
626 | contactList.remove( ati ); | 626 | contactList.remove( ati ); |
627 | 627 | ||
628 | realignTable( row ); | 628 | realignTable( row ); |
629 | 629 | ||
630 | } | 630 | } |
631 | 631 | ||
632 | #if QT_VERSION <= 230 | 632 | #if QT_VERSION <= 230 |
633 | #ifndef SINGLE_APP | 633 | #ifndef SINGLE_APP |
634 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) | 634 | void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) |
635 | { | 635 | { |
636 | // Region of the rect we should draw | 636 | // Region of the rect we should draw |
637 | QRegion reg( QRect( cx, cy, cw, ch ) ); | 637 | QRegion reg( QRect( cx, cy, cw, ch ) ); |
638 | // Subtract the table from it | 638 | // Subtract the table from it |
639 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); | 639 | reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) ); |
640 | // And draw the rectangles (transformed as needed) | 640 | // And draw the rectangles (transformed as needed) |
641 | QArray<QRect> r = reg.rects(); | 641 | QArray<QRect> r = reg.rects(); |
642 | for (unsigned int i=0; i<r.count(); i++) | 642 | for (unsigned int i=0; i<r.count(); i++) |
643 | p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); | 643 | p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) ); |
644 | } | 644 | } |
645 | #endif | 645 | #endif |
646 | #endif | 646 | #endif |
647 | 647 | ||
648 | 648 | ||
649 | // int AbTable::rowHeight( int ) const | 649 | // int AbTable::rowHeight( int ) const |
650 | // { | 650 | // { |
651 | // return 18; | 651 | // return 18; |
652 | // } | 652 | // } |
653 | 653 | ||
654 | // int AbTable::rowPos( int row ) const | 654 | // int AbTable::rowPos( int row ) const |
655 | // { | 655 | // { |
656 | // return 18*row; | 656 | // return 18*row; |
657 | // } | 657 | // } |
658 | 658 | ||
659 | // int AbTable::rowAt( int pos ) const | 659 | // int AbTable::rowAt( int pos ) const |
660 | // { | 660 | // { |
661 | // return QMIN( pos/18, numRows()-1 ); | 661 | // return QMIN( pos/18, numRows()-1 ); |
662 | // } | 662 | // } |
663 | 663 | ||
664 | void AbTable::slotDoFind( const QString &findString, bool caseSensitive, bool useRegExp, | 664 | void AbTable::slotDoFind( const QString &findString, bool caseSensitive, bool useRegExp, |
665 | bool backwards, QString cat /* int category */ ) | 665 | bool backwards, QString cat /* int category */ ) |
666 | { | 666 | { |
667 | int category = 0; | 667 | int category = 0; |
668 | 668 | ||
669 | // Use the current Category if nothing else selected | 669 | // Use the current Category if nothing else selected |
670 | if ( cat.isEmpty() ) | 670 | if ( cat.isEmpty() ) |
671 | category = mCat.id( "Contacts", showCat ); | 671 | category = mCat.id( "Contacts", showCat ); |
672 | else{ | 672 | else{ |
673 | category = mCat.id("Contacts", cat ); | 673 | category = mCat.id("Contacts", cat ); |
674 | } | 674 | } |
675 | 675 | ||
676 | qWarning ("Found in Category %d", category); | 676 | qWarning ("Found in Category %d", category); |
677 | 677 | ||
678 | if ( currFindRow < -1 ) | 678 | if ( currFindRow < -1 ) |
679 | currFindRow = - 1; | 679 | currFindRow = - 1; |
680 | 680 | ||
681 | clearSelection( TRUE ); | 681 | clearSelection( TRUE ); |
682 | int rows, row; | 682 | int rows, row; |
683 | AbTableItem *ati; | 683 | AbTableItem *ati; |
684 | QRegExp r( findString ); | 684 | QRegExp r( findString ); |
685 | r.setCaseSensitive( caseSensitive ); | 685 | r.setCaseSensitive( caseSensitive ); |
686 | r.setWildcard( !useRegExp ); | 686 | r.setWildcard( !useRegExp ); |
687 | rows = numRows(); | 687 | rows = numRows(); |
688 | static bool wrapAround = true; | 688 | static bool wrapAround = true; |
689 | bool try_again = false; | ||
689 | 690 | ||
690 | if ( !backwards ) { | 691 | // We will loop until we found an entry or found nothing. |
691 | for ( row = currFindRow + 1; row < rows; row++ ) { | 692 | do { |
692 | ati = static_cast<AbTableItem*>( item(row, 0) ); | 693 | if ( !backwards ) { |
693 | if ( contactCompare( contactList[ati], r, category ) ) | 694 | for ( row = currFindRow + 1; row < rows; row++ ) { |
694 | break; | 695 | ati = static_cast<AbTableItem*>( item(row, 0) ); |
696 | if ( contactCompare( contactList[ati], r, category ) ){ | ||
697 | try_again = false; | ||
698 | break; | ||
699 | } | ||
700 | } | ||
701 | } else { | ||
702 | for ( row = currFindRow - 1; row > -1; row-- ) { | ||
703 | ati = static_cast<AbTableItem*>( item(row, 0) ); | ||
704 | if ( contactCompare( contactList[ati], r, category ) ){ | ||
705 | try_again = false; | ||
706 | break; | ||
707 | } | ||
708 | } | ||
695 | } | 709 | } |
696 | } else { | 710 | if ( row >= rows || row < 0 ) { |
697 | for ( row = currFindRow - 1; row > -1; row-- ) { | 711 | if ( row < 0 ) |
698 | ati = static_cast<AbTableItem*>( item(row, 0) ); | 712 | currFindRow = rows; |
699 | if ( contactCompare( contactList[ati], r, category ) ) | 713 | else |
700 | break; | 714 | currFindRow = -1; |
715 | |||
716 | if ( wrapAround ){ | ||
717 | emit signalWrapAround(); | ||
718 | try_again = true; | ||
719 | }else{ | ||
720 | emit signalNotFound(); | ||
721 | try_again = false; | ||
722 | } | ||
723 | |||
724 | wrapAround = !wrapAround; | ||
725 | } else { | ||
726 | currFindRow = row; | ||
727 | QTableSelection foundSelection; | ||
728 | foundSelection.init( currFindRow, 0 ); | ||
729 | foundSelection.expandTo( currFindRow, numCols() - 1 ); | ||
730 | addSelection( foundSelection ); | ||
731 | setCurrentCell( currFindRow, 0 /* numCols() - 1 */ ); | ||
732 | wrapAround = true; | ||
733 | try_again = false; | ||
701 | } | 734 | } |
702 | } | 735 | } while ( try_again ); |
703 | if ( row >= rows || row < 0 ) { | ||
704 | if ( row < 0 ) | ||
705 | currFindRow = rows; | ||
706 | else | ||
707 | currFindRow = -1; | ||
708 | |||
709 | if ( wrapAround ) | ||
710 | emit signalWrapAround(); | ||
711 | else | ||
712 | emit signalNotFound(); | ||
713 | |||
714 | wrapAround = !wrapAround; | ||
715 | } else { | ||
716 | currFindRow = row; | ||
717 | QTableSelection foundSelection; | ||
718 | foundSelection.init( currFindRow, 0 ); | ||
719 | foundSelection.expandTo( currFindRow, numCols() - 1 ); | ||
720 | addSelection( foundSelection ); | ||
721 | setCurrentCell( currFindRow, 0 /* numCols() - 1 */ ); | ||
722 | wrapAround = true; | ||
723 | } | ||
724 | } | 736 | } |
725 | 737 | ||
726 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) | 738 | static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) |
727 | { | 739 | { |
728 | bool returnMe; | 740 | bool returnMe; |
729 | QArray<int> cats; | 741 | QArray<int> cats; |
730 | cats = cnt.categories(); | 742 | cats = cnt.categories(); |
731 | 743 | ||
732 | returnMe = false; | 744 | returnMe = false; |
733 | if ( (cats.count() == 0) || (category == 0) ) | 745 | if ( (cats.count() == 0) || (category == 0) ) |
734 | returnMe = cnt.match( r ); | 746 | returnMe = cnt.match( r ); |
735 | else { | 747 | else { |
736 | int i; | 748 | int i; |
737 | for ( i = 0; i < int(cats.count()); i++ ) { | 749 | for ( i = 0; i < int(cats.count()); i++ ) { |
738 | if ( cats[i] == category ) { | 750 | if ( cats[i] == category ) { |
739 | returnMe = cnt.match( r ); | 751 | returnMe = cnt.match( r ); |
740 | break; | 752 | break; |
741 | } | 753 | } |
742 | } | 754 | } |
743 | } | 755 | } |
744 | 756 | ||
745 | return returnMe; | 757 | return returnMe; |
746 | } | 758 | } |
747 | 759 | ||
748 | void AbTable::fitColumns() | 760 | void AbTable::fitColumns() |
749 | { | 761 | { |
750 | int contentsWidth = visibleWidth() / 2; | 762 | int contentsWidth = visibleWidth() / 2; |
751 | 763 | ||
752 | if ( showBk == "Cards" ) { | 764 | if ( showBk == "Cards" ) { |
753 | showColumn(1); | 765 | showColumn(1); |
754 | //adjustColumn(1); | 766 | //adjustColumn(1); |
755 | setColumnWidth( 1, visibleWidth() ); | 767 | setColumnWidth( 1, visibleWidth() ); |
756 | columnVisible = false; | 768 | columnVisible = false; |
757 | } else { | 769 | } else { |
758 | if ( columnVisible == false ){ | 770 | if ( columnVisible == false ){ |
759 | showColumn(0); | 771 | showColumn(0); |
760 | columnVisible = true; | 772 | columnVisible = true; |
761 | } | 773 | } |
762 | setColumnWidth( 0, contentsWidth ); | 774 | setColumnWidth( 0, contentsWidth ); |
763 | adjustColumn(1); | 775 | adjustColumn(1); |
764 | if ( columnWidth(1) < contentsWidth ) | 776 | if ( columnWidth(1) < contentsWidth ) |
765 | setColumnWidth( 1, contentsWidth ); | 777 | setColumnWidth( 1, contentsWidth ); |
766 | } | 778 | } |
767 | } | 779 | } |
768 | 780 | ||
769 | void AbTable::show() | 781 | void AbTable::show() |
770 | { | 782 | { |
771 | fitColumns(); | 783 | fitColumns(); |
772 | QTable::show(); | 784 | QTable::show(); |
773 | } | 785 | } |
774 | 786 | ||
775 | void AbTable::setChoiceNames( const QStringList& list) | 787 | void AbTable::setChoiceNames( const QStringList& list) |
776 | { | 788 | { |
777 | choicenames = list; | 789 | choicenames = list; |
778 | if ( choicenames.isEmpty() ) { | 790 | if ( choicenames.isEmpty() ) { |
779 | // hide pick column | 791 | // hide pick column |
780 | setNumCols( 2 ); | 792 | setNumCols( 2 ); |
781 | } else { | 793 | } else { |
782 | // show pick column | 794 | // show pick column |
783 | setNumCols( 3 ); | 795 | setNumCols( 3 ); |
784 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); | 796 | setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 ); |
785 | horizontalHeader()->setLabel( 2, tr( "Pick" )); | 797 | horizontalHeader()->setLabel( 2, tr( "Pick" )); |
786 | } | 798 | } |
787 | fitColumns(); | 799 | fitColumns(); |
788 | } | 800 | } |
789 | 801 | ||
790 | void AbTable::itemClicked(int,int col) | 802 | void AbTable::itemClicked(int,int col) |
791 | { | 803 | { |
792 | if ( col == 2 ) { | 804 | if ( col == 2 ) { |
793 | return; | 805 | return; |
794 | } else { | 806 | } else { |
795 | emit details(); | 807 | emit details(); |
796 | } | 808 | } |
797 | } | 809 | } |
798 | 810 | ||
799 | QStringList AbTable::choiceNames() const | 811 | QStringList AbTable::choiceNames() const |
800 | { | 812 | { |
801 | return choicenames; | 813 | return choicenames; |
802 | } | 814 | } |
803 | 815 | ||
804 | void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/) | 816 | void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/) |
805 | { | 817 | { |
806 | /* ###### | 818 | /* ###### |
807 | 819 | ||
808 | QString selname = choicenames.at(index); | 820 | QString selname = choicenames.at(index); |
809 | for (each row) { | 821 | for (each row) { |
810 | OContact *c = contactForRow(row); | 822 | OContact *c = contactForRow(row); |
811 | if ( list.contains(c->email) ) { | 823 | if ( list.contains(c->email) ) { |
812 | list.remove(c->email); | 824 | list.remove(c->email); |
813 | setText(row, 2, selname); | 825 | setText(row, 2, selname); |
814 | } | 826 | } |
815 | } | 827 | } |
816 | for (remaining list items) { | 828 | for (remaining list items) { |
817 | OContact *c = new contact(item); | 829 | OContact *c = new contact(item); |
818 | setText(newrow, 2, selname); | 830 | setText(newrow, 2, selname); |
819 | } | 831 | } |
820 | 832 | ||
821 | */ | 833 | */ |
822 | } | 834 | } |
823 | 835 | ||
824 | QStringList AbTable::choiceSelection(int /*index*/) const | 836 | QStringList AbTable::choiceSelection(int /*index*/) const |
825 | { | 837 | { |
826 | QStringList r; | 838 | QStringList r; |
827 | /* ###### | 839 | /* ###### |
828 | 840 | ||
829 | QString selname = choicenames.at(index); | 841 | QString selname = choicenames.at(index); |
830 | for (each row) { | 842 | for (each row) { |
831 | OContact *c = contactForRow(row); | 843 | OContact *c = contactForRow(row); |
832 | if ( text(row,2) == selname ) { | 844 | if ( text(row,2) == selname ) { |
833 | r.append(c->email); | 845 | r.append(c->email); |
834 | } | 846 | } |
835 | } | 847 | } |
836 | 848 | ||
837 | */ | 849 | */ |
838 | return r; | 850 | return r; |
839 | } | 851 | } |
840 | 852 | ||
841 | void AbTable::setShowCategory( const QString &b, const QString &c ) | 853 | void AbTable::setShowCategory( const QString &b, const QString &c ) |
842 | { | 854 | { |
843 | showBk = b; | 855 | showBk = b; |
844 | showCat = c; | 856 | showCat = c; |
845 | //QMessageBox::information( this, "setShowCategory", "setShowCategory" ); | 857 | //QMessageBox::information( this, "setShowCategory", "setShowCategory" ); |
846 | //updateVisible(); | 858 | //updateVisible(); |
847 | refresh(); | 859 | refresh(); |
848 | ensureCellVisible( currentRow(), 0 ); | 860 | ensureCellVisible( currentRow(), 0 ); |
849 | updateVisible(); // :SX | 861 | updateVisible(); // :SX |
850 | } | 862 | } |
851 | 863 | ||
852 | void AbTable::setShowByLetter( char c ) | 864 | void AbTable::setShowByLetter( char c ) |
853 | { | 865 | { |
854 | showChar = tolower(c); | 866 | showChar = tolower(c); |
855 | updateVisible(); | 867 | updateVisible(); |
856 | } | 868 | } |
857 | 869 | ||
858 | QString AbTable::showCategory() const | 870 | QString AbTable::showCategory() const |
859 | { | 871 | { |
860 | return showCat; | 872 | return showCat; |
861 | } | 873 | } |
862 | 874 | ||
863 | QString AbTable::showBook() const | 875 | QString AbTable::showBook() const |
864 | { | 876 | { |
865 | return showBk; | 877 | return showBk; |
866 | } | 878 | } |
867 | 879 | ||
868 | QStringList AbTable::categories() | 880 | QStringList AbTable::categories() |
869 | { | 881 | { |
870 | mCat.load( categoryFileName() ); | 882 | mCat.load( categoryFileName() ); |
871 | QStringList categoryList = mCat.labels( "Contacts" ); | 883 | QStringList categoryList = mCat.labels( "Contacts" ); |
872 | return categoryList; | 884 | return categoryList; |
873 | } | 885 | } |
874 | 886 | ||
875 | void AbTable::updateVisible() | 887 | void AbTable::updateVisible() |
876 | { | 888 | { |
877 | int visible, | 889 | int visible, |
878 | totalRows, | 890 | totalRows, |
879 | id, | 891 | id, |
880 | totalCats, | 892 | totalCats, |
881 | it, | 893 | it, |
882 | row; | 894 | row; |
883 | bool hide; | 895 | bool hide; |
884 | AbTableItem *ati; | 896 | AbTableItem *ati; |
885 | OContact *cnt; | 897 | OContact *cnt; |
886 | QString fileAsName; | 898 | QString fileAsName; |
887 | QString tmpStr; | 899 | QString tmpStr; |
888 | visible = 0; | 900 | visible = 0; |
889 | 901 | ||
890 | setPaintingEnabled( FALSE ); | 902 | setPaintingEnabled( FALSE ); |
891 | 903 | ||
892 | totalRows = numRows(); | 904 | totalRows = numRows(); |
893 | id = mCat.id( "Contacts", showCat ); | 905 | id = mCat.id( "Contacts", showCat ); |
894 | QArray<int> cats; | 906 | QArray<int> cats; |
895 | for ( row = 0; row < totalRows; row++ ) { | 907 | for ( row = 0; row < totalRows; row++ ) { |
896 | ati = static_cast<AbTableItem*>( item(row, 0) ); | 908 | ati = static_cast<AbTableItem*>( item(row, 0) ); |
897 | cnt = &contactList[ati]; | 909 | cnt = &contactList[ati]; |
898 | cats = cnt->categories(); | 910 | cats = cnt->categories(); |
899 | fileAsName = cnt->fileAs(); | 911 | fileAsName = cnt->fileAs(); |
900 | hide = false; | 912 | hide = false; |
901 | if ( !showCat.isEmpty() ) { | 913 | if ( !showCat.isEmpty() ) { |
902 | if ( showCat == tr( "Unfiled" ) ) { | 914 | if ( showCat == tr( "Unfiled" ) ) { |
903 | if ( cats.count() > 0 ) | 915 | if ( cats.count() > 0 ) |
904 | hide = true; | 916 | hide = true; |
905 | } else { | 917 | } else { |
906 | // do some comparing | 918 | // do some comparing |
907 | if ( !hide ) { | 919 | if ( !hide ) { |
908 | hide = true; | 920 | hide = true; |
909 | totalCats = int(cats.count()); | 921 | totalCats = int(cats.count()); |
910 | for ( it = 0; it < totalCats; it++ ) { | 922 | for ( it = 0; it < totalCats; it++ ) { |
911 | if ( cats[it] == id ) { | 923 | if ( cats[it] == id ) { |
912 | hide = false; | 924 | hide = false; |
913 | break; | 925 | break; |
914 | } | 926 | } |
915 | } | 927 | } |
916 | } | 928 | } |
917 | } | 929 | } |
918 | } | 930 | } |
919 | if ( showChar != '\0' ) { | 931 | if ( showChar != '\0' ) { |
920 | tmpStr = fileAsName.left(1); | 932 | tmpStr = fileAsName.left(1); |
921 | tmpStr = tmpStr.lower(); | 933 | tmpStr = tmpStr.lower(); |
922 | if ( tmpStr != QString(QChar(showChar)) && showChar != '#' ) { | 934 | if ( tmpStr != QString(QChar(showChar)) && showChar != '#' ) { |
923 | hide = true; | 935 | hide = true; |
924 | } | 936 | } |
925 | if ( showChar == '#' ) { | 937 | if ( showChar == '#' ) { |
926 | if (tmpStr == "a") | 938 | if (tmpStr == "a") |
927 | hide = true; | 939 | hide = true; |
928 | 940 | ||
929 | if (tmpStr == "b") | 941 | if (tmpStr == "b") |
930 | hide = true; | 942 | hide = true; |
931 | 943 | ||
932 | if (tmpStr == "c") | 944 | if (tmpStr == "c") |
933 | hide = true; | 945 | hide = true; |
934 | 946 | ||
935 | if (tmpStr == "d") | 947 | if (tmpStr == "d") |
936 | hide = true; | 948 | hide = true; |
937 | 949 | ||
938 | if (tmpStr == "e") | 950 | if (tmpStr == "e") |
939 | hide = true; | 951 | hide = true; |
940 | 952 | ||
941 | if (tmpStr == "f") | 953 | if (tmpStr == "f") |
942 | hide = true; | 954 | hide = true; |
943 | 955 | ||
944 | if (tmpStr == "g") | 956 | if (tmpStr == "g") |
945 | hide = true; | 957 | hide = true; |
946 | 958 | ||
947 | if (tmpStr == "h") | 959 | if (tmpStr == "h") |
948 | hide = true; | 960 | hide = true; |
949 | 961 | ||
950 | if (tmpStr == "i") | 962 | if (tmpStr == "i") |
951 | hide = true; | 963 | hide = true; |
952 | 964 | ||
953 | if (tmpStr == "j") | 965 | if (tmpStr == "j") |
954 | hide = true; | 966 | hide = true; |
955 | 967 | ||
956 | if (tmpStr == "k") | 968 | if (tmpStr == "k") |
957 | hide = true; | 969 | hide = true; |
958 | 970 | ||
959 | if (tmpStr == "l") | 971 | if (tmpStr == "l") |
960 | hide = true; | 972 | hide = true; |
961 | 973 | ||
962 | if (tmpStr == "m") | 974 | if (tmpStr == "m") |
963 | hide = true; | 975 | hide = true; |
964 | 976 | ||
965 | if (tmpStr == "n") | 977 | if (tmpStr == "n") |
966 | hide = true; | 978 | hide = true; |
967 | 979 | ||
968 | if (tmpStr == "o") | 980 | if (tmpStr == "o") |
969 | hide = true; | 981 | hide = true; |
970 | 982 | ||
971 | if (tmpStr == "p") | 983 | if (tmpStr == "p") |
972 | hide = true; | 984 | hide = true; |
973 | 985 | ||
974 | if (tmpStr == "q") | 986 | if (tmpStr == "q") |
975 | hide = true; | 987 | hide = true; |
976 | 988 | ||
977 | if (tmpStr == "r") | 989 | if (tmpStr == "r") |
978 | hide = true; | 990 | hide = true; |
979 | 991 | ||
980 | if (tmpStr == "s") | 992 | if (tmpStr == "s") |
981 | hide = true; | 993 | hide = true; |
982 | 994 | ||
983 | if (tmpStr == "t") | 995 | if (tmpStr == "t") |
984 | hide = true; | 996 | hide = true; |
985 | 997 | ||
986 | if (tmpStr == "u") | 998 | if (tmpStr == "u") |
987 | hide = true; | 999 | hide = true; |
988 | 1000 | ||
989 | if (tmpStr == "v") | 1001 | if (tmpStr == "v") |
990 | hide = true; | 1002 | hide = true; |
991 | 1003 | ||
992 | if (tmpStr == "w") | 1004 | if (tmpStr == "w") |
993 | hide = true; | 1005 | hide = true; |
994 | 1006 | ||
995 | if (tmpStr == "x") | 1007 | if (tmpStr == "x") |
996 | hide = true; | 1008 | hide = true; |
997 | 1009 | ||
998 | if (tmpStr == "y") | 1010 | if (tmpStr == "y") |
999 | hide = true; | 1011 | hide = true; |
1000 | 1012 | ||
1001 | if (tmpStr == "z") | 1013 | if (tmpStr == "z") |
1002 | hide = true; | 1014 | hide = true; |
1003 | } | 1015 | } |
1004 | 1016 | ||
1005 | } | 1017 | } |
1006 | if ( hide ) { | 1018 | if ( hide ) { |
1007 | if ( currentRow() == row ) | 1019 | if ( currentRow() == row ) |
1008 | setCurrentCell( -1, 0 ); | 1020 | setCurrentCell( -1, 0 ); |
1009 | if ( rowHeight(row) > 0 ) | 1021 | if ( rowHeight(row) > 0 ) |
1010 | hideRow( row ); | 1022 | hideRow( row ); |
1011 | } else { | 1023 | } else { |
1012 | if ( rowHeight(row) == 0 ) { | 1024 | if ( rowHeight(row) == 0 ) { |
1013 | showRow( row ); | 1025 | showRow( row ); |
1014 | adjustRow( row ); | 1026 | adjustRow( row ); |
1015 | } | 1027 | } |
1016 | visible++; | 1028 | visible++; |
1017 | } | 1029 | } |
1018 | } | 1030 | } |
1019 | if ( !visible ) | 1031 | if ( !visible ) |
1020 | setCurrentCell( -1, 0 ); | 1032 | setCurrentCell( -1, 0 ); |
1021 | 1033 | ||
1022 | setPaintingEnabled( TRUE ); | 1034 | setPaintingEnabled( TRUE ); |
1023 | } | 1035 | } |
1024 | 1036 | ||
1025 | 1037 | ||
1026 | void AbTable::setPaintingEnabled( bool e ) | 1038 | void AbTable::setPaintingEnabled( bool e ) |
1027 | { | 1039 | { |
1028 | if ( e != enablePainting ) { | 1040 | if ( e != enablePainting ) { |
1029 | if ( !enablePainting ) { | 1041 | if ( !enablePainting ) { |
1030 | enablePainting = true; | 1042 | enablePainting = true; |
1031 | rowHeightChanged( 0 ); | 1043 | rowHeightChanged( 0 ); |
1032 | viewport()->update(); | 1044 | viewport()->update(); |
1033 | } else { | 1045 | } else { |
1034 | enablePainting = false; | 1046 | enablePainting = false; |
1035 | } | 1047 | } |
1036 | } | 1048 | } |
1037 | } | 1049 | } |
1038 | 1050 | ||
1039 | void AbTable::rowHeightChanged( int row ) | 1051 | void AbTable::rowHeightChanged( int row ) |
1040 | { | 1052 | { |
1041 | if ( enablePainting ) | 1053 | if ( enablePainting ) |
1042 | QTable::rowHeightChanged( row ); | 1054 | QTable::rowHeightChanged( row ); |
1043 | } | 1055 | } |
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 3466801..39d8321 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -1,1088 +1,1129 @@ | |||
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 | #include <qpe/global.h> | 36 | #include <qpe/global.h> |
37 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
38 | #include <qpe/ir.h> | 38 | #include <qpe/ir.h> |
39 | #include <qpe/qpemessagebox.h> | 39 | #include <qpe/qpemessagebox.h> |
40 | #include <qpe/qcopenvelope_qws.h> | 40 | #include <qpe/qcopenvelope_qws.h> |
41 | 41 | ||
42 | #include <qaction.h> | 42 | #include <qaction.h> |
43 | #include <qdialog.h> | 43 | #include <qdialog.h> |
44 | #include <qdir.h> | 44 | #include <qdir.h> |
45 | #include <qfile.h> | 45 | #include <qfile.h> |
46 | #include <qimage.h> | 46 | #include <qimage.h> |
47 | #include <qlayout.h> | 47 | #include <qlayout.h> |
48 | #include <qpe/qpemenubar.h> | 48 | #include <qpe/qpemenubar.h> |
49 | #include <qmessagebox.h> | 49 | #include <qmessagebox.h> |
50 | #include <qpixmap.h> | 50 | #include <qpixmap.h> |
51 | #include <qpopupmenu.h> | 51 | #include <qpopupmenu.h> |
52 | #include <qpe/qpetoolbar.h> | 52 | #include <qpe/qpetoolbar.h> |
53 | #include <qstringlist.h> | 53 | #include <qstringlist.h> |
54 | #include <qtoolbutton.h> | 54 | #include <qtoolbutton.h> |
55 | #include <qwhatsthis.h> | 55 | #include <qwhatsthis.h> |
56 | 56 | ||
57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
58 | #include <sys/stat.h> | 58 | #include <sys/stat.h> |
59 | #include <sys/types.h> | 59 | #include <sys/types.h> |
60 | #include <fcntl.h> | 60 | #include <fcntl.h> |
61 | #include <unistd.h> | 61 | #include <unistd.h> |
62 | 62 | ||
63 | #include <qdatetime.h> | 63 | #include <qdatetime.h> |
64 | 64 | ||
65 | #include "picker.h" | 65 | #include "picker.h" |
66 | #include "configdlg.h" | 66 | #include "configdlg.h" |
67 | 67 | ||
68 | static QString addressbookPersonalVCardName() | 68 | static QString addressbookPersonalVCardName() |
69 | { | 69 | { |
70 | QString filename = Global::applicationFileName("addressbook", | 70 | QString filename = Global::applicationFileName("addressbook", |
71 | "businesscard.vcf"); | 71 | "businesscard.vcf"); |
72 | return filename; | 72 | return filename; |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
76 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 76 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, |
77 | WFlags f ) | 77 | WFlags f ) |
78 | : QMainWindow( parent, name, f ), | 78 | : QMainWindow( parent, name, f ), |
79 | abEditor(0), | 79 | abEditor(0), |
80 | useRegExp(false), | 80 | useRegExp(false), |
81 | doNotifyWrapAround(true), | 81 | doNotifyWrapAround(true), |
82 | caseSensitive(false), | 82 | caseSensitive(false), |
83 | m_useQtMail(true), | ||
84 | m_useOpieMail(false), | ||
83 | bAbEditFirstTime(TRUE), | 85 | bAbEditFirstTime(TRUE), |
84 | syncing(FALSE) | 86 | syncing(FALSE) |
85 | { | 87 | { |
86 | isLoading = true; | 88 | isLoading = true; |
87 | 89 | ||
88 | // Read Config settings | 90 | // Read Config settings |
89 | Config cfg("AddressBook"); | 91 | Config cfg("AddressBook"); |
90 | cfg.setGroup("Search"); | 92 | cfg.setGroup("Search"); |
91 | useRegExp = cfg.readBoolEntry( "useRegExp" ); | 93 | useRegExp = cfg.readBoolEntry( "useRegExp" ); |
92 | caseSensitive = cfg.readBoolEntry( "caseSensitive" ); | 94 | caseSensitive = cfg.readBoolEntry( "caseSensitive" ); |
93 | doNotifyWrapAround = cfg.readBoolEntry( "doNotifyWrapAround" ); | 95 | doNotifyWrapAround = cfg.readBoolEntry( "doNotifyWrapAround" ); |
96 | cfg.setGroup("Mail"); | ||
97 | m_useQtMail = cfg.readBoolEntry( "useQtMail" ); | ||
98 | m_useOpieMail=cfg.readBoolEntry( "useOpieMail" ); | ||
99 | |||
94 | 100 | ||
95 | initFields(); | 101 | initFields(); |
96 | 102 | ||
97 | setCaption( tr("Contacts") ); | 103 | setCaption( tr("Contacts") ); |
98 | setIcon( Resource::loadPixmap( "AddressBook" ) ); | 104 | setIcon( Resource::loadPixmap( "AddressBook" ) ); |
99 | 105 | ||
100 | setToolBarsMovable( FALSE ); | 106 | setToolBarsMovable( FALSE ); |
101 | 107 | ||
102 | // Create Toolbars | 108 | // Create Toolbars |
103 | 109 | ||
104 | QPEToolBar *bar = new QPEToolBar( this ); | 110 | QPEToolBar *bar = new QPEToolBar( this ); |
105 | bar->setHorizontalStretchable( TRUE ); | 111 | bar->setHorizontalStretchable( TRUE ); |
106 | 112 | ||
107 | QPEMenuBar *mbList = new QPEMenuBar( bar ); | 113 | QPEMenuBar *mbList = new QPEMenuBar( bar ); |
108 | mbList->setMargin( 0 ); | 114 | mbList->setMargin( 0 ); |
109 | 115 | ||
110 | QPopupMenu *edit = new QPopupMenu( this ); | 116 | QPopupMenu *edit = new QPopupMenu( this ); |
111 | mbList->insertItem( tr( "Contact" ), edit ); | 117 | mbList->insertItem( tr( "Contact" ), edit ); |
112 | 118 | ||
113 | listTools = new QPEToolBar( this, "list operations" ); | 119 | listTools = new QPEToolBar( this, "list operations" ); |
114 | 120 | ||
115 | 121 | ||
116 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, | 122 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, |
117 | 0, this, 0 ); | 123 | 0, this, 0 ); |
118 | actionNew = a; | 124 | actionNew = a; |
119 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); | 125 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); |
120 | a->addTo( edit ); | 126 | a->addTo( edit ); |
121 | a->addTo( listTools ); | 127 | a->addTo( listTools ); |
122 | 128 | ||
123 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 129 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
124 | 0, this, 0 ); | 130 | 0, this, 0 ); |
125 | actionEdit = a; | 131 | actionEdit = a; |
126 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); | 132 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); |
127 | a->addTo( edit ); | 133 | a->addTo( edit ); |
128 | a->addTo( listTools ); | 134 | a->addTo( listTools ); |
129 | 135 | ||
130 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 136 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
131 | 0, this, 0 ); | 137 | 0, this, 0 ); |
132 | actionTrash = a; | 138 | actionTrash = a; |
133 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); | 139 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); |
134 | a->addTo( edit ); | 140 | a->addTo( edit ); |
135 | a->addTo( listTools ); | 141 | a->addTo( listTools ); |
136 | 142 | ||
137 | 143 | ||
138 | // make it possible to go directly to businesscard via qcop call | 144 | // make it possible to go directly to businesscard via qcop call |
139 | #if defined(Q_WS_QWS) | 145 | #if defined(Q_WS_QWS) |
140 | #if !defined(QT_NO_COP) | 146 | #if !defined(QT_NO_COP) |
141 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); | 147 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); |
142 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 148 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), |
143 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); | 149 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); |
144 | #endif | 150 | #endif |
145 | #endif | 151 | #endif |
146 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), | 152 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), |
147 | QString::null, 0, this, 0 ); | 153 | QString::null, 0, this, 0 ); |
148 | actionFind = a; | 154 | actionFind = a; |
149 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); | 155 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); |
150 | a->addTo( edit ); | 156 | a->addTo( edit ); |
151 | a->addTo( listTools ); | 157 | a->addTo( listTools ); |
152 | 158 | ||
153 | // Much better search widget, taken from QTReader.. (se) | 159 | // Much better search widget, taken from QTReader.. (se) |
154 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); | 160 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
155 | searchBar->setHorizontalStretchable( TRUE ); | 161 | searchBar->setHorizontalStretchable( TRUE ); |
156 | searchBar->hide(); | 162 | searchBar->hide(); |
157 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 163 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
158 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 164 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
159 | // searchEdit->setFont( f ); | 165 | // searchEdit->setFont( f ); |
160 | searchBar->setStretchableWidget( searchEdit ); | 166 | searchBar->setStretchableWidget( searchEdit ); |
161 | connect( searchEdit, SIGNAL( returnPressed( ) ), | 167 | connect( searchEdit, SIGNAL( returnPressed( ) ), |
162 | this, SLOT( slotFind( ) ) ); | 168 | this, SLOT( slotFind( ) ) ); |
163 | 169 | ||
164 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 170 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
165 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindNext() ) ); | 171 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindNext() ) ); |
166 | a->addTo( searchBar ); | 172 | a->addTo( searchBar ); |
167 | 173 | ||
168 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 174 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
169 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); | 175 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); |
170 | a->addTo( searchBar ); | 176 | a->addTo( searchBar ); |
171 | 177 | ||
172 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ), | 178 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "mail/sendmail" ), |
173 | QString::null, 0, this, 0 ); | 179 | QString::null, 0, this, 0 ); |
174 | //a->setEnabled( FALSE ); we got support for it now :) zecke | 180 | //a->setEnabled( FALSE ); we got support for it now :) zecke |
175 | actionMail = a; | 181 | actionMail = a; |
176 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); | 182 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); |
177 | a->addTo( edit ); | 183 | a->addTo( edit ); |
178 | a->addTo( listTools ); | 184 | a->addTo( listTools ); |
179 | 185 | ||
180 | 186 | ||
181 | 187 | ||
182 | if ( Ir::supported() ) { | 188 | if ( Ir::supported() ) { |
183 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, | 189 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, |
184 | 0, this, 0 ); | 190 | 0, this, 0 ); |
185 | actionBeam = a; | 191 | actionBeam = a; |
186 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | 192 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); |
187 | a->addTo( edit ); | 193 | a->addTo( edit ); |
188 | a->addTo( listTools ); | 194 | a->addTo( listTools ); |
189 | } | 195 | } |
190 | 196 | ||
191 | edit->insertSeparator(); | 197 | edit->insertSeparator(); |
192 | 198 | ||
193 | a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE ); | 199 | a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE ); |
194 | actionPersonal = a; | 200 | actionPersonal = a; |
195 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); | 201 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); |
196 | a->addTo( edit ); | 202 | a->addTo( edit ); |
197 | 203 | ||
198 | edit->insertSeparator(); | 204 | edit->insertSeparator(); |
199 | 205 | ||
200 | a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); | 206 | a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); |
201 | actionPersonal = a; | 207 | actionPersonal = a; |
202 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); | 208 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); |
203 | a->addTo( edit ); | 209 | a->addTo( edit ); |
204 | 210 | ||
205 | // Do we need this function ? (se) | 211 | // Do we need this function ? (se) |
206 | // a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); | 212 | // a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 ); |
207 | // connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 213 | // connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
208 | // a->addTo( edit ); | 214 | // a->addTo( edit ); |
209 | 215 | ||
210 | 216 | ||
211 | #ifdef __DEBUG_RELEASE | 217 | #ifdef __DEBUG_RELEASE |
212 | // Remove this function for public Release ! This is only | 218 | // Remove this function for public Release ! This is only |
213 | // for debug purposes .. | 219 | // for debug purposes .. |
214 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); | 220 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); |
215 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); | 221 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); |
216 | a->addTo( edit ); | 222 | a->addTo( edit ); |
217 | #endif | 223 | #endif |
218 | a = new QAction( tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, | 224 | a = new QAction( tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, |
219 | 0, this, 0 ); | 225 | 0, this, 0 ); |
220 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); | 226 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); |
221 | a->addTo( edit ); | 227 | a->addTo( edit ); |
222 | 228 | ||
223 | // Create Views | 229 | // Create Views |
224 | listContainer = new QWidget( this ); | 230 | listContainer = new QWidget( this ); |
225 | 231 | ||
226 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); | 232 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); |
227 | 233 | ||
228 | abList = new AbTable( &orderedFields, listContainer, "table" ); | 234 | abList = new AbTable( &orderedFields, listContainer, "table" ); |
229 | vb->addWidget(abList); | 235 | vb->addWidget(abList); |
230 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); | 236 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); |
231 | connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); | 237 | connect( abList, SIGNAL( empty( bool ) ), this, SLOT( listIsEmpty( bool ) ) ); |
232 | connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); | 238 | connect( abList, SIGNAL( details() ), this, SLOT( slotListView() ) ); |
233 | connect( abList, SIGNAL( currentChanged(int,int) ), this, SLOT( slotUpdateToolbar() ) ); | 239 | connect( abList, SIGNAL( currentChanged(int,int) ), this, SLOT( slotUpdateToolbar() ) ); |
234 | connect( abList, SIGNAL( signalSearchNext() ), this, SLOT( slotFindNext() ) ); | 240 | connect( abList, SIGNAL( signalSearchNext() ), this, SLOT( slotFindNext() ) ); |
235 | connect( abList, SIGNAL( signalSearchBackward() ), this, SLOT( slotFindPrevious() ) ); | 241 | connect( abList, SIGNAL( signalSearchBackward() ), this, SLOT( slotFindPrevious() ) ); |
236 | 242 | ||
237 | // Maybe we should react on Wraparound and notfound ? | 243 | // Maybe we should react on Wraparound and notfound ? |
238 | QObject::connect( abList, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); | 244 | QObject::connect( abList, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); |
239 | QObject::connect( abList, SIGNAL(signalWrapAround()), this, SLOT(slotWrapAround()) ); | 245 | QObject::connect( abList, SIGNAL(signalWrapAround()), this, SLOT(slotWrapAround()) ); |
240 | 246 | ||
241 | mView = 0; | 247 | mView = 0; |
242 | 248 | ||
243 | abList->load(); | 249 | abList->load(); |
244 | 250 | ||
245 | pLabel = new LetterPicker( listContainer ); | 251 | pLabel = new LetterPicker( listContainer ); |
246 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); | 252 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); |
247 | vb->addWidget(pLabel); | 253 | vb->addWidget(pLabel); |
248 | catMenu = new QPopupMenu( this ); | 254 | catMenu = new QPopupMenu( this ); |
249 | catMenu->setCheckable( TRUE ); | 255 | catMenu->setCheckable( TRUE ); |
250 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); | 256 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); |
251 | populateCategories(); | 257 | populateCategories(); |
252 | 258 | ||
253 | mbList->insertItem( tr("View"), catMenu ); | 259 | mbList->insertItem( tr("View"), catMenu ); |
254 | // setCentralWidget( listContainer ); | 260 | // setCentralWidget( listContainer ); |
255 | 261 | ||
256 | fontMenu = new QPopupMenu(this); | 262 | fontMenu = new QPopupMenu(this); |
257 | fontMenu->setCheckable( true ); | 263 | fontMenu->setCheckable( true ); |
258 | connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); | 264 | connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int))); |
259 | 265 | ||
260 | fontMenu->insertItem(tr( "Small" ), 0); | 266 | fontMenu->insertItem(tr( "Small" ), 0); |
261 | fontMenu->insertItem(tr( "Normal" ), 1); | 267 | fontMenu->insertItem(tr( "Normal" ), 1); |
262 | fontMenu->insertItem(tr( "Large" ), 2); | 268 | fontMenu->insertItem(tr( "Large" ), 2); |
263 | 269 | ||
264 | defaultFont = new QFont( abList->font() ); | 270 | defaultFont = new QFont( abList->font() ); |
265 | 271 | ||
266 | slotSetFont(startFontSize); | 272 | slotSetFont(startFontSize); |
267 | 273 | ||
268 | mbList->insertItem( tr("Font"), fontMenu); | 274 | mbList->insertItem( tr("Font"), fontMenu); |
269 | setCentralWidget(listContainer); | 275 | setCentralWidget(listContainer); |
270 | 276 | ||
271 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); | 277 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); |
272 | 278 | ||
273 | abList->setCurrentCell( 0, 0 ); | 279 | abList->setCurrentCell( 0, 0 ); |
274 | 280 | ||
275 | isLoading = false; | 281 | isLoading = false; |
276 | } | 282 | } |
277 | 283 | ||
278 | 284 | ||
279 | void AddressbookWindow::slotConfig() | 285 | void AddressbookWindow::slotConfig() |
280 | { | 286 | { |
281 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); | 287 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); |
282 | dlg -> setUseRegExp ( useRegExp ); | 288 | dlg -> setUseRegExp ( useRegExp ); |
283 | dlg -> setBeCaseSensitive( caseSensitive ); | 289 | dlg -> setBeCaseSensitive( caseSensitive ); |
284 | dlg -> setSignalWrapAround( doNotifyWrapAround ); | 290 | dlg -> setSignalWrapAround( doNotifyWrapAround ); |
291 | dlg -> setQtMail ( m_useQtMail ); | ||
292 | dlg -> setOpieMail ( m_useOpieMail ); | ||
285 | dlg -> showMaximized(); | 293 | dlg -> showMaximized(); |
286 | if ( dlg -> exec() ) { | 294 | if ( dlg -> exec() ) { |
287 | qWarning ("Config Dialog accepted !"); | 295 | qWarning ("Config Dialog accepted !"); |
288 | useRegExp = dlg -> useRegExp(); | 296 | useRegExp = dlg -> useRegExp(); |
289 | caseSensitive = dlg -> beCaseSensitive(); | 297 | caseSensitive = dlg -> beCaseSensitive(); |
290 | doNotifyWrapAround = dlg -> signalWrapAround(); | 298 | doNotifyWrapAround = dlg -> signalWrapAround(); |
299 | m_useQtMail = dlg -> useQtMail(); | ||
300 | m_useOpieMail= dlg -> useOpieMail(); | ||
291 | } | 301 | } |
292 | 302 | ||
293 | delete dlg; | 303 | delete dlg; |
294 | } | 304 | } |
295 | 305 | ||
296 | 306 | ||
297 | void AddressbookWindow::slotSetFont( int size ) { | 307 | void AddressbookWindow::slotSetFont( int size ) { |
298 | 308 | ||
299 | if (size > 2 || size < 0) | 309 | if (size > 2 || size < 0) |
300 | size = 1; | 310 | size = 1; |
301 | 311 | ||
302 | startFontSize = size; | 312 | startFontSize = size; |
303 | 313 | ||
304 | QFont *currentFont; | 314 | QFont *currentFont; |
305 | 315 | ||
306 | switch (size) { | 316 | switch (size) { |
307 | case 0: | 317 | case 0: |
308 | fontMenu->setItemChecked(0, true); | 318 | fontMenu->setItemChecked(0, true); |
309 | fontMenu->setItemChecked(1, false); | 319 | fontMenu->setItemChecked(1, false); |
310 | fontMenu->setItemChecked(2, false); | 320 | fontMenu->setItemChecked(2, false); |
311 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); | 321 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); |
312 | currentFont = new QFont (abList->font()); | 322 | currentFont = new QFont (abList->font()); |
313 | // abList->resizeRows(currentFont->pixelSize() + 7); | 323 | // abList->resizeRows(currentFont->pixelSize() + 7); |
314 | abList->resizeRows(); | 324 | abList->resizeRows(); |
315 | break; | 325 | break; |
316 | case 1: | 326 | case 1: |
317 | fontMenu->setItemChecked(0, false); | 327 | fontMenu->setItemChecked(0, false); |
318 | fontMenu->setItemChecked(1, true); | 328 | fontMenu->setItemChecked(1, true); |
319 | fontMenu->setItemChecked(2, false); | 329 | fontMenu->setItemChecked(2, false); |
320 | abList->setFont( *defaultFont ); | 330 | abList->setFont( *defaultFont ); |
321 | currentFont = new QFont (abList->font()); | 331 | currentFont = new QFont (abList->font()); |
322 | // abList->resizeRows(currentFont->pixelSize() + 7); | 332 | // abList->resizeRows(currentFont->pixelSize() + 7); |
323 | abList->resizeRows(); | 333 | abList->resizeRows(); |
324 | break; | 334 | break; |
325 | case 2: | 335 | case 2: |
326 | fontMenu->setItemChecked(0, false); | 336 | fontMenu->setItemChecked(0, false); |
327 | fontMenu->setItemChecked(1, false); | 337 | fontMenu->setItemChecked(1, false); |
328 | fontMenu->setItemChecked(2, true); | 338 | fontMenu->setItemChecked(2, true); |
329 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); | 339 | abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); |
330 | currentFont = new QFont (abList->font()); | 340 | currentFont = new QFont (abList->font()); |
331 | //abList->resizeRows(currentFont->pixelSize() + 7); | 341 | //abList->resizeRows(currentFont->pixelSize() + 7); |
332 | abList->resizeRows(); | 342 | abList->resizeRows(); |
333 | break; | 343 | break; |
334 | } | 344 | } |
335 | } | 345 | } |
336 | 346 | ||
337 | 347 | ||
338 | 348 | ||
339 | void AddressbookWindow::importvCard() { | 349 | void AddressbookWindow::importvCard() { |
340 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); | 350 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); |
341 | if(!str.isEmpty() ) | 351 | if(!str.isEmpty() ) |
342 | setDocument((const QString&) str ); | 352 | setDocument((const QString&) str ); |
343 | 353 | ||
344 | } | 354 | } |
345 | 355 | ||
346 | void AddressbookWindow::setDocument( const QString &filename ) | 356 | void AddressbookWindow::setDocument( const QString &filename ) |
347 | { | 357 | { |
348 | if ( filename.find(".vcf") != int(filename.length()) - 4 ) | 358 | if ( filename.find(".vcf") != int(filename.length()) - 4 ) |
349 | return; | 359 | return; |
350 | 360 | ||
351 | QValueList<OContact> cl = OContact::readVCard( filename ); | 361 | QValueList<OContact> cl = OContact::readVCard( filename ); |
352 | for( QValueList<OContact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { | 362 | for( QValueList<OContact>::Iterator it = cl.begin(); it != cl.end(); ++it ) { |
353 | // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") | 363 | // QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?") |
354 | // .arg( (*it).fullName() ); | 364 | // .arg( (*it).fullName() ); |
355 | // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == | 365 | // if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) == |
356 | // QMessageBox::Ok ) { | 366 | // QMessageBox::Ok ) { |
357 | abList->addEntry( *it ); | 367 | abList->addEntry( *it ); |
358 | // } | 368 | // } |
359 | } | 369 | } |
360 | 370 | ||
361 | } | 371 | } |
362 | 372 | ||
363 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) | 373 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) |
364 | { | 374 | { |
365 | QMainWindow::resizeEvent( e ); | 375 | QMainWindow::resizeEvent( e ); |
366 | 376 | ||
367 | if ( centralWidget() == listContainer ) | 377 | if ( centralWidget() == listContainer ) |
368 | showList(); | 378 | showList(); |
369 | else if ( centralWidget() == mView ) | 379 | else if ( centralWidget() == mView ) |
370 | showView(); | 380 | showView(); |
371 | } | 381 | } |
372 | 382 | ||
373 | AddressbookWindow::~AddressbookWindow() | 383 | AddressbookWindow::~AddressbookWindow() |
374 | { | 384 | { |
375 | Config cfg("AddressBook"); | 385 | Config cfg("AddressBook"); |
376 | cfg.setGroup("Font"); | 386 | cfg.setGroup("Font"); |
377 | cfg.writeEntry("fontSize", startFontSize); | 387 | cfg.writeEntry("fontSize", startFontSize); |
378 | 388 | ||
379 | cfg.setGroup("Search"); | 389 | cfg.setGroup("Search"); |
380 | cfg.writeEntry("useRegExp", useRegExp); | 390 | cfg.writeEntry("useRegExp", useRegExp); |
381 | cfg.writeEntry("caseSensitive", caseSensitive); | 391 | cfg.writeEntry("caseSensitive", caseSensitive); |
382 | cfg.writeEntry("doNotifyWrapAround", doNotifyWrapAround); | 392 | cfg.writeEntry("doNotifyWrapAround", doNotifyWrapAround); |
393 | cfg.setGroup("Mail"); | ||
394 | cfg.writeEntry( "useQtMail", m_useQtMail ); | ||
395 | cfg.writeEntry( "useOpieMail", m_useOpieMail); | ||
383 | } | 396 | } |
384 | 397 | ||
385 | void AddressbookWindow::slotUpdateToolbar() | 398 | void AddressbookWindow::slotUpdateToolbar() |
386 | { | 399 | { |
387 | OContact ce = abList->currentEntry(); | 400 | OContact ce = abList->currentEntry(); |
388 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); | 401 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); |
389 | } | 402 | } |
390 | 403 | ||
391 | void AddressbookWindow::showList() | 404 | void AddressbookWindow::showList() |
392 | { | 405 | { |
393 | bool visiblemView; | 406 | bool visiblemView; |
394 | 407 | ||
395 | visiblemView = false; | 408 | visiblemView = false; |
396 | if ( mView ) { | 409 | if ( mView ) { |
397 | mView->hide(); | 410 | mView->hide(); |
398 | visiblemView = true; | 411 | visiblemView = true; |
399 | } | 412 | } |
400 | setCentralWidget( listContainer ); | 413 | setCentralWidget( listContainer ); |
401 | listContainer->show(); | 414 | listContainer->show(); |
402 | // update our focues... (or use a stack widget!); | 415 | // update our focues... (or use a stack widget!); |
403 | abList->setFocus(); | 416 | abList->setFocus(); |
404 | 417 | ||
405 | // This makes sure we are scrolled all the way to the left | 418 | // This makes sure we are scrolled all the way to the left |
406 | abList->setContentsPos( 0, abList->contentsY() ); | 419 | abList->setContentsPos( 0, abList->contentsY() ); |
407 | 420 | ||
408 | //if ( visiblemView && abList->showBook() == "Cards" ) | 421 | //if ( visiblemView && abList->showBook() == "Cards" ) |
409 | //abList->setShowCategory( abList->showBook(), abList->showCategory() ); | 422 | //abList->setShowCategory( abList->showBook(), abList->showCategory() ); |
410 | 423 | ||
411 | } | 424 | } |
412 | 425 | ||
413 | void AddressbookWindow::showView() | 426 | void AddressbookWindow::showView() |
414 | { | 427 | { |
415 | if ( abList->numRows() > 0 ) { | 428 | if ( abList->numRows() > 0 ) { |
416 | listContainer->hide(); | 429 | listContainer->hide(); |
417 | setCentralWidget( abView() ); | 430 | setCentralWidget( abView() ); |
418 | mView->show(); | 431 | mView->show(); |
419 | mView->setFocus(); | 432 | mView->setFocus(); |
420 | } | 433 | } |
421 | } | 434 | } |
422 | 435 | ||
423 | void AddressbookWindow::slotListNew() | 436 | void AddressbookWindow::slotListNew() |
424 | { | 437 | { |
425 | OContact cnt; | 438 | OContact cnt; |
426 | if( !syncing ) { | 439 | if( !syncing ) { |
427 | if ( abEditor ) | 440 | if ( abEditor ) |
428 | abEditor->setEntry( cnt ); | 441 | abEditor->setEntry( cnt ); |
429 | abView()->init( cnt ); | 442 | abView()->init( cnt ); |
430 | editEntry( NewEntry ); | 443 | editEntry( NewEntry ); |
431 | } else { | 444 | } else { |
432 | QMessageBox::warning(this, tr("OContacts"), | 445 | QMessageBox::warning(this, tr("OContacts"), |
433 | tr("Can not edit data, currently syncing")); | 446 | tr("Can not edit data, currently syncing")); |
434 | } | 447 | } |
435 | } | 448 | } |
436 | 449 | ||
437 | void AddressbookWindow::slotListView() | 450 | void AddressbookWindow::slotListView() |
438 | { | 451 | { |
439 | abView()->init( abList->currentEntry() ); | 452 | abView()->init( abList->currentEntry() ); |
440 | mView->sync(); | 453 | mView->sync(); |
441 | showView(); | 454 | showView(); |
442 | } | 455 | } |
443 | 456 | ||
444 | void AddressbookWindow::slotListDelete() | 457 | void AddressbookWindow::slotListDelete() |
445 | { | 458 | { |
446 | if(!syncing) { | 459 | if(!syncing) { |
447 | OContact tmpEntry = abList->currentEntry(); | 460 | OContact tmpEntry = abList->currentEntry(); |
448 | 461 | ||
449 | // get a name, do the best we can... | 462 | // get a name, do the best we can... |
450 | QString strName = tmpEntry.fullName(); | 463 | QString strName = tmpEntry.fullName(); |
451 | if ( strName.isEmpty() ) { | 464 | if ( strName.isEmpty() ) { |
452 | strName = tmpEntry.company(); | 465 | strName = tmpEntry.company(); |
453 | if ( strName.isEmpty() ) | 466 | if ( strName.isEmpty() ) |
454 | strName = "No Name"; | 467 | strName = "No Name"; |
455 | } | 468 | } |
456 | 469 | ||
457 | 470 | ||
458 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), | 471 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), |
459 | strName ) ) { | 472 | strName ) ) { |
460 | abList->deleteCurrentEntry(); | 473 | abList->deleteCurrentEntry(); |
461 | showList(); | 474 | showList(); |
462 | } | 475 | } |
463 | } else { | 476 | } else { |
464 | QMessageBox::warning( this, tr("Contacts"), | 477 | QMessageBox::warning( this, tr("Contacts"), |
465 | tr("Can not edit data, currently syncing") ); | 478 | tr("Can not edit data, currently syncing") ); |
466 | } | 479 | } |
467 | } | 480 | } |
468 | 481 | ||
469 | void AddressbookWindow::slotViewBack() | 482 | void AddressbookWindow::slotViewBack() |
470 | { | 483 | { |
471 | showList(); | 484 | showList(); |
472 | } | 485 | } |
473 | 486 | ||
474 | void AddressbookWindow::slotViewEdit() | 487 | void AddressbookWindow::slotViewEdit() |
475 | { | 488 | { |
476 | if(!syncing) { | 489 | if(!syncing) { |
477 | if (actionPersonal->isOn()) { | 490 | if (actionPersonal->isOn()) { |
478 | editPersonal(); | 491 | editPersonal(); |
479 | } else { | 492 | } else { |
480 | if ( !bAbEditFirstTime ) | 493 | if ( !bAbEditFirstTime ) |
481 | abEditor->setEntry( abList->currentEntry() ); | 494 | abEditor->setEntry( abList->currentEntry() ); |
482 | editEntry( EditEntry ); | 495 | editEntry( EditEntry ); |
483 | } | 496 | } |
484 | } else { | 497 | } else { |
485 | QMessageBox::warning( this, tr("Contacts"), | 498 | QMessageBox::warning( this, tr("Contacts"), |
486 | tr("Can not edit data, currently syncing") ); | 499 | tr("Can not edit data, currently syncing") ); |
487 | } | 500 | } |
488 | } | 501 | } |
489 | 502 | ||
490 | 503 | ||
491 | 504 | ||
492 | void AddressbookWindow::writeMail() | 505 | void AddressbookWindow::writeMail() |
493 | { | 506 | { |
494 | OContact c = abList->currentEntry(); | 507 | OContact c = abList->currentEntry(); |
495 | QString name = c.fileAs(); | 508 | QString name = c.fileAs(); |
496 | QString email = c.defaultEmail(); | 509 | QString email = c.defaultEmail(); |
497 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); | 510 | |
498 | e << name << email; | 511 | // I prefer the OPIE-Environment variable before the |
512 | // QPE-one.. | ||
513 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); | ||
514 | if ( basepath.isEmpty() ) | ||
515 | basepath = QString::fromLatin1( getenv("QPEDIR") ); | ||
516 | |||
517 | // Try to access the preferred. If not possible, try to | ||
518 | // switch to the other one.. | ||
519 | if ( m_useQtMail ){ | ||
520 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); | ||
521 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ | ||
522 | qWarning ("QCop"); | ||
523 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); | ||
524 | e << name << email; | ||
525 | return; | ||
526 | } else | ||
527 | m_useOpieMail = true; | ||
528 | } | ||
529 | if ( m_useOpieMail ){ | ||
530 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); | ||
531 | if ( QFile::exists( basepath + "/bin/mail" ) ){ | ||
532 | qWarning ("QCop"); | ||
533 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); | ||
534 | e << name << email; | ||
535 | return; | ||
536 | } else | ||
537 | m_useQtMail = true; | ||
538 | } | ||
539 | |||
499 | } | 540 | } |
500 | 541 | ||
501 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 542 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
502 | 543 | ||
503 | void AddressbookWindow::slotBeam() | 544 | void AddressbookWindow::slotBeam() |
504 | { | 545 | { |
505 | QString filename; | 546 | QString filename; |
506 | OContact c; | 547 | OContact c; |
507 | if ( actionPersonal->isOn() ) { | 548 | if ( actionPersonal->isOn() ) { |
508 | filename = addressbookPersonalVCardName(); | 549 | filename = addressbookPersonalVCardName(); |
509 | if (!QFile::exists(filename)) | 550 | if (!QFile::exists(filename)) |
510 | return; // can't beam a non-existent file | 551 | return; // can't beam a non-existent file |
511 | c = OContact::readVCard( filename )[0]; | 552 | c = OContact::readVCard( filename )[0]; |
512 | } else { | 553 | } else { |
513 | unlink( beamfile ); // delete if exists | 554 | unlink( beamfile ); // delete if exists |
514 | c = abList->currentEntry(); | 555 | c = abList->currentEntry(); |
515 | mkdir("/tmp/obex/", 0755); | 556 | mkdir("/tmp/obex/", 0755); |
516 | OContact::writeVCard( beamfile, c ); | 557 | OContact::writeVCard( beamfile, c ); |
517 | filename = beamfile; | 558 | filename = beamfile; |
518 | } | 559 | } |
519 | Ir *ir = new Ir( this ); | 560 | Ir *ir = new Ir( this ); |
520 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 561 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
521 | QString description = c.fullName(); | 562 | QString description = c.fullName(); |
522 | ir->send( filename, description, "text/x-vCard" ); | 563 | ir->send( filename, description, "text/x-vCard" ); |
523 | } | 564 | } |
524 | 565 | ||
525 | void AddressbookWindow::beamDone( Ir *ir ) | 566 | void AddressbookWindow::beamDone( Ir *ir ) |
526 | { | 567 | { |
527 | delete ir; | 568 | delete ir; |
528 | unlink( beamfile ); | 569 | unlink( beamfile ); |
529 | } | 570 | } |
530 | 571 | ||
531 | 572 | ||
532 | static void parseName( const QString& name, QString *first, QString *middle, | 573 | static void parseName( const QString& name, QString *first, QString *middle, |
533 | QString * last ) | 574 | QString * last ) |
534 | { | 575 | { |
535 | 576 | ||
536 | int comma = name.find ( "," ); | 577 | int comma = name.find ( "," ); |
537 | QString rest; | 578 | QString rest; |
538 | if ( comma > 0 ) { | 579 | if ( comma > 0 ) { |
539 | *last = name.left( comma ); | 580 | *last = name.left( comma ); |
540 | comma++; | 581 | comma++; |
541 | while ( comma < int(name.length()) && name[comma] == ' ' ) | 582 | while ( comma < int(name.length()) && name[comma] == ' ' ) |
542 | comma++; | 583 | comma++; |
543 | rest = name.mid( comma ); | 584 | rest = name.mid( comma ); |
544 | } else { | 585 | } else { |
545 | int space = name.findRev( ' ' ); | 586 | int space = name.findRev( ' ' ); |
546 | *last = name.mid( space+1 ); | 587 | *last = name.mid( space+1 ); |
547 | rest = name.left( space ); | 588 | rest = name.left( space ); |
548 | } | 589 | } |
549 | int space = rest.find( ' ' ); | 590 | int space = rest.find( ' ' ); |
550 | if ( space <= 0 ) { | 591 | if ( space <= 0 ) { |
551 | *first = rest; | 592 | *first = rest; |
552 | } else { | 593 | } else { |
553 | *first = rest.left( space ); | 594 | *first = rest.left( space ); |
554 | *middle = rest.mid( space+1 ); | 595 | *middle = rest.mid( space+1 ); |
555 | } | 596 | } |
556 | 597 | ||
557 | } | 598 | } |
558 | 599 | ||
559 | 600 | ||
560 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | 601 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) |
561 | { | 602 | { |
562 | if (msg == "editPersonal()") { | 603 | if (msg == "editPersonal()") { |
563 | editPersonal(); | 604 | editPersonal(); |
564 | } else if (msg == "editPersonalAndClose()") { | 605 | } else if (msg == "editPersonalAndClose()") { |
565 | editPersonal(); | 606 | editPersonal(); |
566 | close(); | 607 | close(); |
567 | } else if ( msg == "addContact(QString,QString)" ) { | 608 | } else if ( msg == "addContact(QString,QString)" ) { |
568 | QDataStream stream(data,IO_ReadOnly); | 609 | QDataStream stream(data,IO_ReadOnly); |
569 | QString name, email; | 610 | QString name, email; |
570 | stream >> name >> email; | 611 | stream >> name >> email; |
571 | 612 | ||
572 | OContact cnt; | 613 | OContact cnt; |
573 | QString fn, mn, ln; | 614 | QString fn, mn, ln; |
574 | parseName( name, &fn, &mn, &ln ); | 615 | parseName( name, &fn, &mn, &ln ); |
575 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); | 616 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); |
576 | cnt.setFirstName( fn ); | 617 | cnt.setFirstName( fn ); |
577 | cnt.setMiddleName( mn ); | 618 | cnt.setMiddleName( mn ); |
578 | cnt.setLastName( ln ); | 619 | cnt.setLastName( ln ); |
579 | cnt.insertEmails( email ); | 620 | cnt.insertEmails( email ); |
580 | cnt.setDefaultEmail( email ); | 621 | cnt.setDefaultEmail( email ); |
581 | cnt.setFileAs(); | 622 | cnt.setFileAs(); |
582 | 623 | ||
583 | if ( bAbEditFirstTime ) { | 624 | if ( bAbEditFirstTime ) { |
584 | abEditor = new ContactEditor( cnt, &orderedFields, &slOrderedFields, | 625 | abEditor = new ContactEditor( cnt, &orderedFields, &slOrderedFields, |
585 | this, "editor" ); | 626 | this, "editor" ); |
586 | bAbEditFirstTime = FALSE; | 627 | bAbEditFirstTime = FALSE; |
587 | } else { | 628 | } else { |
588 | abEditor->setEntry( cnt ); | 629 | abEditor->setEntry( cnt ); |
589 | } | 630 | } |
590 | abView()->init( cnt ); | 631 | abView()->init( cnt ); |
591 | editEntry( NewEntry ); | 632 | editEntry( NewEntry ); |
592 | 633 | ||
593 | 634 | ||
594 | 635 | ||
595 | } | 636 | } |
596 | #if 0 | 637 | #if 0 |
597 | else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { | 638 | else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { |
598 | QDataStream stream(data,IO_ReadOnly); | 639 | QDataStream stream(data,IO_ReadOnly); |
599 | QCString ch,m; | 640 | QCString ch,m; |
600 | QStringList types; | 641 | QStringList types; |
601 | stream >> ch >> m >> types; | 642 | stream >> ch >> m >> types; |
602 | AddressPicker picker(abList,this,0,TRUE); | 643 | AddressPicker picker(abList,this,0,TRUE); |
603 | picker.showMaximized(); | 644 | picker.showMaximized(); |
604 | picker.setChoiceNames(types); | 645 | picker.setChoiceNames(types); |
605 | int i=0; | 646 | int i=0; |
606 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { | 647 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { |
607 | QStringList sel; | 648 | QStringList sel; |
608 | stream >> sel; | 649 | stream >> sel; |
609 | picker.setSelection(i++,sel); | 650 | picker.setSelection(i++,sel); |
610 | } | 651 | } |
611 | picker.showMaximized(); | 652 | picker.showMaximized(); |
612 | picker.exec(); | 653 | picker.exec(); |
613 | 654 | ||
614 | // ###### note: contacts may have been added - save here! | 655 | // ###### note: contacts may have been added - save here! |
615 | 656 | ||
616 | setCentralWidget(abList); | 657 | setCentralWidget(abList); |
617 | QCopEnvelope e(ch,m); | 658 | QCopEnvelope e(ch,m); |
618 | i=0; | 659 | i=0; |
619 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { | 660 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { |
620 | QStringList sel = picker.selection(i++); | 661 | QStringList sel = picker.selection(i++); |
621 | e << sel; | 662 | e << sel; |
622 | } | 663 | } |
623 | } | 664 | } |
624 | #endif | 665 | #endif |
625 | 666 | ||
626 | } | 667 | } |
627 | 668 | ||
628 | void AddressbookWindow::editPersonal() | 669 | void AddressbookWindow::editPersonal() |
629 | { | 670 | { |
630 | QString filename = addressbookPersonalVCardName(); | 671 | QString filename = addressbookPersonalVCardName(); |
631 | OContact me; | 672 | OContact me; |
632 | if (QFile::exists(filename)) | 673 | if (QFile::exists(filename)) |
633 | me = OContact::readVCard( filename )[0]; | 674 | me = OContact::readVCard( filename )[0]; |
634 | if (bAbEditFirstTime) { | 675 | if (bAbEditFirstTime) { |
635 | abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields, | 676 | abEditor = new ContactEditor( me, &orderedFields, &slOrderedFields, |
636 | this, "editor" ); | 677 | this, "editor" ); |
637 | // don't create a new editor every time | 678 | // don't create a new editor every time |
638 | bAbEditFirstTime = FALSE; | 679 | bAbEditFirstTime = FALSE; |
639 | } else | 680 | } else |
640 | abEditor->setEntry( me ); | 681 | abEditor->setEntry( me ); |
641 | 682 | ||
642 | abEditor->setCaption(tr("Edit My Personal Details")); | 683 | abEditor->setCaption(tr("Edit My Personal Details")); |
643 | abEditor->showMaximized(); | 684 | abEditor->showMaximized(); |
644 | 685 | ||
645 | // fix the foxus... | 686 | // fix the foxus... |
646 | abEditor->setNameFocus(); | 687 | abEditor->setNameFocus(); |
647 | if ( abEditor->exec() ) { | 688 | if ( abEditor->exec() ) { |
648 | setFocus(); | 689 | setFocus(); |
649 | OContact new_personal = abEditor->entry(); | 690 | OContact new_personal = abEditor->entry(); |
650 | QString fname = addressbookPersonalVCardName(); | 691 | QString fname = addressbookPersonalVCardName(); |
651 | OContact::writeVCard( fname, new_personal ); | 692 | OContact::writeVCard( fname, new_personal ); |
652 | abView()->init(new_personal); | 693 | abView()->init(new_personal); |
653 | abView()->sync(); | 694 | abView()->sync(); |
654 | } | 695 | } |
655 | abEditor->setCaption( tr("Edit Address") ); | 696 | abEditor->setCaption( tr("Edit Address") ); |
656 | } | 697 | } |
657 | 698 | ||
658 | void AddressbookWindow::slotPersonalView() | 699 | void AddressbookWindow::slotPersonalView() |
659 | { | 700 | { |
660 | if (!actionPersonal->isOn()) { | 701 | if (!actionPersonal->isOn()) { |
661 | // we just turned it off | 702 | // we just turned it off |
662 | setCaption( tr("Contacts") ); | 703 | setCaption( tr("Contacts") ); |
663 | actionNew->setEnabled(TRUE); | 704 | actionNew->setEnabled(TRUE); |
664 | actionTrash->setEnabled(TRUE); | 705 | actionTrash->setEnabled(TRUE); |
665 | actionFind->setEnabled(TRUE); | 706 | actionFind->setEnabled(TRUE); |
666 | slotUpdateToolbar(); // maybe some of the above could be moved there | 707 | slotUpdateToolbar(); // maybe some of the above could be moved there |
667 | showList(); | 708 | showList(); |
668 | return; | 709 | return; |
669 | } | 710 | } |
670 | 711 | ||
671 | // XXX need to disable some QActions. | 712 | // XXX need to disable some QActions. |
672 | actionNew->setEnabled(FALSE); | 713 | actionNew->setEnabled(FALSE); |
673 | actionTrash->setEnabled(FALSE); | 714 | actionTrash->setEnabled(FALSE); |
674 | #ifndef MAKE_FOR_SHARP_ROM | 715 | #ifndef MAKE_FOR_SHARP_ROM |
675 | actionFind->setEnabled(FALSE); | 716 | actionFind->setEnabled(FALSE); |
676 | #endif | 717 | #endif |
677 | actionMail->setEnabled(FALSE); | 718 | actionMail->setEnabled(FALSE); |
678 | 719 | ||
679 | setCaption( tr("Contacts - My Personal Details") ); | 720 | setCaption( tr("Contacts - My Personal Details") ); |
680 | QString filename = addressbookPersonalVCardName(); | 721 | QString filename = addressbookPersonalVCardName(); |
681 | OContact me; | 722 | OContact me; |
682 | if (QFile::exists(filename)) | 723 | if (QFile::exists(filename)) |
683 | me = OContact::readVCard( filename )[0]; | 724 | me = OContact::readVCard( filename )[0]; |
684 | 725 | ||
685 | abView()->init( me ); | 726 | abView()->init( me ); |
686 | abView()->sync(); | 727 | abView()->sync(); |
687 | listContainer->hide(); | 728 | listContainer->hide(); |
688 | setCentralWidget( abView() ); | 729 | setCentralWidget( abView() ); |
689 | mView->show(); | 730 | mView->show(); |
690 | mView->setFocus(); | 731 | mView->setFocus(); |
691 | } | 732 | } |
692 | 733 | ||
693 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 734 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
694 | { | 735 | { |
695 | OContact entry; | 736 | OContact entry; |
696 | if ( bAbEditFirstTime ) { | 737 | if ( bAbEditFirstTime ) { |
697 | abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields, | 738 | abEditor = new ContactEditor( entry, &orderedFields, &slOrderedFields, |
698 | this, "editor" ); | 739 | this, "editor" ); |
699 | bAbEditFirstTime = FALSE; | 740 | bAbEditFirstTime = FALSE; |
700 | if ( entryMode == EditEntry ) | 741 | if ( entryMode == EditEntry ) |
701 | abEditor->setEntry( abList->currentEntry() ); | 742 | abEditor->setEntry( abList->currentEntry() ); |
702 | } | 743 | } |
703 | // other things may chane the caption. | 744 | // other things may chane the caption. |
704 | abEditor->setCaption( tr("Edit Address") ); | 745 | abEditor->setCaption( tr("Edit Address") ); |
705 | 746 | ||
706 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 747 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
707 | abEditor->showMaximized(); | 748 | abEditor->showMaximized(); |
708 | #endif | 749 | #endif |
709 | // fix the foxus... | 750 | // fix the foxus... |
710 | abEditor->setNameFocus(); | 751 | abEditor->setNameFocus(); |
711 | if ( abEditor->exec() ) { | 752 | if ( abEditor->exec() ) { |
712 | setFocus(); | 753 | setFocus(); |
713 | if ( entryMode == NewEntry ) { | 754 | if ( entryMode == NewEntry ) { |
714 | OContact insertEntry = abEditor->entry(); | 755 | OContact insertEntry = abEditor->entry(); |
715 | insertEntry.assignUid(); | 756 | insertEntry.assignUid(); |
716 | abList->addEntry( insertEntry ); | 757 | abList->addEntry( insertEntry ); |
717 | } else { | 758 | } else { |
718 | OContact replaceEntry = abEditor->entry(); | 759 | OContact replaceEntry = abEditor->entry(); |
719 | if ( !replaceEntry.isValidUid() ) | 760 | if ( !replaceEntry.isValidUid() ) |
720 | replaceEntry.assignUid(); | 761 | replaceEntry.assignUid(); |
721 | abList->replaceCurrentEntry( replaceEntry ); | 762 | abList->replaceCurrentEntry( replaceEntry ); |
722 | } | 763 | } |
723 | } | 764 | } |
724 | populateCategories(); | 765 | populateCategories(); |
725 | showList(); | 766 | showList(); |
726 | } | 767 | } |
727 | 768 | ||
728 | void AddressbookWindow::listIsEmpty( bool empty ) | 769 | void AddressbookWindow::listIsEmpty( bool empty ) |
729 | { | 770 | { |
730 | if ( !empty ) { | 771 | if ( !empty ) { |
731 | deleteButton->setEnabled( TRUE ); | 772 | deleteButton->setEnabled( TRUE ); |
732 | } | 773 | } |
733 | } | 774 | } |
734 | 775 | ||
735 | void AddressbookWindow::reload() | 776 | void AddressbookWindow::reload() |
736 | { | 777 | { |
737 | syncing = FALSE; | 778 | syncing = FALSE; |
738 | abList->clear(); | 779 | abList->clear(); |
739 | abList->reload(); | 780 | abList->reload(); |
740 | } | 781 | } |
741 | 782 | ||
742 | void AddressbookWindow::flush() | 783 | void AddressbookWindow::flush() |
743 | { | 784 | { |
744 | syncing = TRUE; | 785 | syncing = TRUE; |
745 | abList->save(); | 786 | abList->save(); |
746 | } | 787 | } |
747 | 788 | ||
748 | 789 | ||
749 | void AddressbookWindow::closeEvent( QCloseEvent *e ) | 790 | void AddressbookWindow::closeEvent( QCloseEvent *e ) |
750 | { | 791 | { |
751 | if ( centralWidget() == mView ) { | 792 | if ( centralWidget() == mView ) { |
752 | if (actionPersonal->isOn()) { | 793 | if (actionPersonal->isOn()) { |
753 | // pretend we clicked it off | 794 | // pretend we clicked it off |
754 | actionPersonal->setOn(FALSE); | 795 | actionPersonal->setOn(FALSE); |
755 | slotPersonalView(); | 796 | slotPersonalView(); |
756 | } else { | 797 | } else { |
757 | showList(); | 798 | showList(); |
758 | } | 799 | } |
759 | e->ignore(); | 800 | e->ignore(); |
760 | return; | 801 | return; |
761 | } | 802 | } |
762 | 803 | ||
763 | if(syncing) { | 804 | if(syncing) { |
764 | /* shouldn't we save, I hear you say? well its already been set | 805 | /* shouldn't we save, I hear you say? well its already been set |
765 | so that an edit can not occur during a sync, and we flushed | 806 | so that an edit can not occur during a sync, and we flushed |
766 | at the start of the sync, so there is no need to save | 807 | at the start of the sync, so there is no need to save |
767 | Saving however itself would cause problems. */ | 808 | Saving however itself would cause problems. */ |
768 | e->accept(); | 809 | e->accept(); |
769 | return; | 810 | return; |
770 | } | 811 | } |
771 | //################## shouldn't always save | 812 | //################## shouldn't always save |
772 | // True, but the database handles this automatically ! (se) | 813 | // True, but the database handles this automatically ! (se) |
773 | if ( save() ) | 814 | if ( save() ) |
774 | e->accept(); | 815 | e->accept(); |
775 | else | 816 | else |
776 | e->ignore(); | 817 | e->ignore(); |
777 | } | 818 | } |
778 | 819 | ||
779 | /* | 820 | /* |
780 | Returns TRUE if it is OK to exit | 821 | Returns TRUE if it is OK to exit |
781 | */ | 822 | */ |
782 | 823 | ||
783 | bool AddressbookWindow::save() | 824 | bool AddressbookWindow::save() |
784 | { | 825 | { |
785 | if ( !abList->save() ) { | 826 | if ( !abList->save() ) { |
786 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | 827 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
787 | tr("Unable to save information.\n" | 828 | tr("Unable to save information.\n" |
788 | "Free up some space\n" | 829 | "Free up some space\n" |
789 | "and try again.\n" | 830 | "and try again.\n" |
790 | "\nQuit anyway?"), | 831 | "\nQuit anyway?"), |
791 | QMessageBox::Yes|QMessageBox::Escape, | 832 | QMessageBox::Yes|QMessageBox::Escape, |
792 | QMessageBox::No|QMessageBox::Default ) | 833 | QMessageBox::No|QMessageBox::Default ) |
793 | != QMessageBox::No ) | 834 | != QMessageBox::No ) |
794 | return TRUE; | 835 | return TRUE; |
795 | else | 836 | else |
796 | return FALSE; | 837 | return FALSE; |
797 | } | 838 | } |
798 | return TRUE; | 839 | return TRUE; |
799 | } | 840 | } |
800 | 841 | ||
801 | #ifdef __DEBUG_RELEASE | 842 | #ifdef __DEBUG_RELEASE |
802 | void AddressbookWindow::slotSave() | 843 | void AddressbookWindow::slotSave() |
803 | { | 844 | { |
804 | save(); | 845 | save(); |
805 | } | 846 | } |
806 | #endif | 847 | #endif |
807 | 848 | ||
808 | void AddressbookWindow::slotSettings() | 849 | void AddressbookWindow::slotSettings() |
809 | { | 850 | { |
810 | AddressSettings frmSettings( this ); | 851 | AddressSettings frmSettings( this ); |
811 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 852 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
812 | frmSettings.showMaximized(); | 853 | frmSettings.showMaximized(); |
813 | #endif | 854 | #endif |
814 | 855 | ||
815 | if ( frmSettings.exec() ) { | 856 | if ( frmSettings.exec() ) { |
816 | allFields.clear(); | 857 | allFields.clear(); |
817 | orderedFields.clear(); | 858 | orderedFields.clear(); |
818 | slOrderedFields.clear(); | 859 | slOrderedFields.clear(); |
819 | initFields(); | 860 | initFields(); |
820 | if ( abEditor ) | 861 | if ( abEditor ) |
821 | abEditor->loadFields(); | 862 | abEditor->loadFields(); |
822 | abList->refresh(); | 863 | abList->refresh(); |
823 | } | 864 | } |
824 | } | 865 | } |
825 | 866 | ||
826 | 867 | ||
827 | void AddressbookWindow::initFields() | 868 | void AddressbookWindow::initFields() |
828 | { | 869 | { |
829 | // we really don't need the things from the configuration, anymore | 870 | // we really don't need the things from the configuration, anymore |
830 | // only thing that is important are the important categories. So, | 871 | // only thing that is important are the important categories. So, |
831 | // Call the contact functions that correspond to these old functions... | 872 | // Call the contact functions that correspond to these old functions... |
832 | 873 | ||
833 | QStringList xmlFields = OContact::fields(); | 874 | QStringList xmlFields = OContact::fields(); |
834 | QStringList visibleFields = OContact::untrfields(); | 875 | QStringList visibleFields = OContact::untrfields(); |
835 | // QStringList trFields = OContact::trfields(); | 876 | // QStringList trFields = OContact::trfields(); |
836 | 877 | ||
837 | xmlFields.remove( "Title" ); | 878 | xmlFields.remove( "Title" ); |
838 | visibleFields.remove( "Name Title" ); | 879 | visibleFields.remove( "Name Title" ); |
839 | visibleFields.remove( "Notes" ); | 880 | visibleFields.remove( "Notes" ); |
840 | 881 | ||
841 | int i, version; | 882 | int i, version; |
842 | Config cfg( "AddressBook" ); | 883 | Config cfg( "AddressBook" ); |
843 | QString zn; | 884 | QString zn; |
844 | 885 | ||
845 | // ### Write a function to keep this from happening again... | 886 | // ### Write a function to keep this from happening again... |
846 | QStringList::ConstIterator it; | 887 | QStringList::ConstIterator it; |
847 | for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) { | 888 | for ( i = 0, it = xmlFields.begin(); it != xmlFields.end(); ++it, i++ ) { |
848 | allFields.append( i + 3 ); | 889 | allFields.append( i + 3 ); |
849 | } | 890 | } |
850 | 891 | ||
851 | cfg.setGroup( "Version" ); | 892 | cfg.setGroup( "Version" ); |
852 | version = cfg.readNumEntry( "version" ); | 893 | version = cfg.readNumEntry( "version" ); |
853 | i = 0; | 894 | i = 0; |
854 | startFontSize = 1; | 895 | startFontSize = 1; |
855 | 896 | ||
856 | if ( version >= ADDRESSVERSION ) { | 897 | if ( version >= ADDRESSVERSION ) { |
857 | 898 | ||
858 | cfg.setGroup( "ImportantCategory" ); | 899 | cfg.setGroup( "ImportantCategory" ); |
859 | 900 | ||
860 | zn = cfg.readEntry( "Category" + QString::number(i), QString::null ); | 901 | zn = cfg.readEntry( "Category" + QString::number(i), QString::null ); |
861 | while ( !zn.isNull() ) { | 902 | while ( !zn.isNull() ) { |
862 | if ( zn.contains( "Work" ) || zn.contains( "Mb" ) ) { | 903 | if ( zn.contains( "Work" ) || zn.contains( "Mb" ) ) { |
863 | slOrderedFields.clear(); | 904 | slOrderedFields.clear(); |
864 | break; | 905 | break; |
865 | } | 906 | } |
866 | slOrderedFields.append( zn ); | 907 | slOrderedFields.append( zn ); |
867 | zn = cfg.readEntry( "Category" + QString::number(++i), QString::null ); | 908 | zn = cfg.readEntry( "Category" + QString::number(++i), QString::null ); |
868 | } | 909 | } |
869 | cfg.setGroup( "Font" ); | 910 | cfg.setGroup( "Font" ); |
870 | startFontSize = cfg.readNumEntry( "fontSize", 1 ); | 911 | startFontSize = cfg.readNumEntry( "fontSize", 1 ); |
871 | 912 | ||
872 | 913 | ||
873 | } else { | 914 | } else { |
874 | QString str; | 915 | QString str; |
875 | str = getenv("HOME"); | 916 | str = getenv("HOME"); |
876 | str += "/Settings/AddressBook.conf"; | 917 | str += "/Settings/AddressBook.conf"; |
877 | QFile::remove( str ); | 918 | QFile::remove( str ); |
878 | } | 919 | } |
879 | 920 | ||
880 | if ( slOrderedFields.count() > 0 ) { | 921 | if ( slOrderedFields.count() > 0 ) { |
881 | for( QStringList::ConstIterator it = slOrderedFields.begin(); | 922 | for( QStringList::ConstIterator it = slOrderedFields.begin(); |
882 | it != slOrderedFields.end(); ++it ) { | 923 | it != slOrderedFields.end(); ++it ) { |
883 | QValueList<int>::ConstIterator itVl; | 924 | QValueList<int>::ConstIterator itVl; |
884 | QStringList::ConstIterator itVis; | 925 | QStringList::ConstIterator itVis; |
885 | itVl = allFields.begin(); | 926 | itVl = allFields.begin(); |
886 | for ( itVis = visibleFields.begin(); | 927 | for ( itVis = visibleFields.begin(); |
887 | itVis != visibleFields.end() && itVl != allFields.end(); | 928 | itVis != visibleFields.end() && itVl != allFields.end(); |
888 | ++itVis, ++itVl ) { | 929 | ++itVis, ++itVl ) { |
889 | if ( *it == *itVis && itVl != allFields.end() ) { | 930 | if ( *it == *itVis && itVl != allFields.end() ) { |
890 | orderedFields.append( *itVl ); | 931 | orderedFields.append( *itVl ); |
891 | } | 932 | } |
892 | } | 933 | } |
893 | } | 934 | } |
894 | } else { | 935 | } else { |
895 | QValueList<int>::ConstIterator it; | 936 | QValueList<int>::ConstIterator it; |
896 | for ( it = allFields.begin(); it != allFields.end(); ++it ) | 937 | for ( it = allFields.begin(); it != allFields.end(); ++it ) |
897 | orderedFields.append( *it ); | 938 | orderedFields.append( *it ); |
898 | 939 | ||
899 | slOrderedFields = visibleFields; | 940 | slOrderedFields = visibleFields; |
900 | orderedFields.remove( Qtopia::AddressUid ); | 941 | orderedFields.remove( Qtopia::AddressUid ); |
901 | orderedFields.remove( Qtopia::Title ); | 942 | orderedFields.remove( Qtopia::Title ); |
902 | orderedFields.remove( Qtopia::Groups ); | 943 | orderedFields.remove( Qtopia::Groups ); |
903 | orderedFields.remove( Qtopia::AddressCategory ); | 944 | orderedFields.remove( Qtopia::AddressCategory ); |
904 | orderedFields.remove( Qtopia::FirstName ); | 945 | orderedFields.remove( Qtopia::FirstName ); |
905 | orderedFields.remove( Qtopia::LastName ); | 946 | orderedFields.remove( Qtopia::LastName ); |
906 | orderedFields.remove( Qtopia::DefaultEmail ); | 947 | orderedFields.remove( Qtopia::DefaultEmail ); |
907 | orderedFields.remove( Qtopia::FileAs ); | 948 | orderedFields.remove( Qtopia::FileAs ); |
908 | orderedFields.remove( Qtopia::Notes ); | 949 | orderedFields.remove( Qtopia::Notes ); |
909 | orderedFields.remove( Qtopia::Gender ); | 950 | orderedFields.remove( Qtopia::Gender ); |
910 | slOrderedFields.remove( "Name Title" ); | 951 | slOrderedFields.remove( "Name Title" ); |
911 | slOrderedFields.remove( "First Name" ); | 952 | slOrderedFields.remove( "First Name" ); |
912 | slOrderedFields.remove( "Last Name" ); | 953 | slOrderedFields.remove( "Last Name" ); |
913 | slOrderedFields.remove( "File As" ); | 954 | slOrderedFields.remove( "File As" ); |
914 | slOrderedFields.remove( "Default Email" ); | 955 | slOrderedFields.remove( "Default Email" ); |
915 | slOrderedFields.remove( "Notes" ); | 956 | slOrderedFields.remove( "Notes" ); |
916 | slOrderedFields.remove( "Gender" ); | 957 | slOrderedFields.remove( "Gender" ); |
917 | 958 | ||
918 | } | 959 | } |
919 | } | 960 | } |
920 | 961 | ||
921 | 962 | ||
922 | AbLabel *AddressbookWindow::abView() | 963 | AbLabel *AddressbookWindow::abView() |
923 | { | 964 | { |
924 | if ( !mView ) { | 965 | if ( !mView ) { |
925 | mView = new AbLabel( this, "viewer" ); | 966 | mView = new AbLabel( this, "viewer" ); |
926 | mView->init( OContact() ); | 967 | mView->init( OContact() ); |
927 | connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); | 968 | connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) ); |
928 | } | 969 | } |
929 | return mView; | 970 | return mView; |
930 | } | 971 | } |
931 | 972 | ||
932 | void AddressbookWindow::slotFindOpen() | 973 | void AddressbookWindow::slotFindOpen() |
933 | { | 974 | { |
934 | searchBar->show(); | 975 | searchBar->show(); |
935 | abList -> inSearch(); | 976 | abList -> inSearch(); |
936 | searchEdit->setFocus(); | 977 | searchEdit->setFocus(); |
937 | } | 978 | } |
938 | void AddressbookWindow::slotFindClose() | 979 | void AddressbookWindow::slotFindClose() |
939 | { | 980 | { |
940 | searchBar->hide(); | 981 | searchBar->hide(); |
941 | abList -> offSearch(); | 982 | abList -> offSearch(); |
942 | abList->setFocus(); | 983 | abList->setFocus(); |
943 | } | 984 | } |
944 | void AddressbookWindow::slotFindNext() | 985 | void AddressbookWindow::slotFindNext() |
945 | { | 986 | { |
946 | if ( centralWidget() == abView() ) | 987 | if ( centralWidget() == abView() ) |
947 | showList(); | 988 | showList(); |
948 | 989 | ||
949 | abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, false); | 990 | abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, false); |
950 | 991 | ||
951 | searchEdit->clearFocus(); | 992 | searchEdit->clearFocus(); |
952 | abList->setFocus(); | 993 | abList->setFocus(); |
953 | if ( abList->numSelections() ) | 994 | if ( abList->numSelections() ) |
954 | abList->clearSelection(); | 995 | abList->clearSelection(); |
955 | 996 | ||
956 | } | 997 | } |
957 | void AddressbookWindow::slotFindPrevious() | 998 | void AddressbookWindow::slotFindPrevious() |
958 | { | 999 | { |
959 | if ( centralWidget() == abView() ) | 1000 | if ( centralWidget() == abView() ) |
960 | showList(); | 1001 | showList(); |
961 | 1002 | ||
962 | abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, true); | 1003 | abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, true); |
963 | 1004 | ||
964 | if ( abList->numSelections() ) | 1005 | if ( abList->numSelections() ) |
965 | abList->clearSelection(); | 1006 | abList->clearSelection(); |
966 | 1007 | ||
967 | } | 1008 | } |
968 | 1009 | ||
969 | void AddressbookWindow::slotFind() | 1010 | void AddressbookWindow::slotFind() |
970 | { | 1011 | { |
971 | 1012 | ||
972 | abList->clearFindRow(); | 1013 | abList->clearFindRow(); |
973 | slotFindNext(); | 1014 | slotFindNext(); |
974 | } | 1015 | } |
975 | 1016 | ||
976 | void AddressbookWindow::slotNotFound() | 1017 | void AddressbookWindow::slotNotFound() |
977 | { | 1018 | { |
978 | qWarning("Got notfound signal !"); | 1019 | qWarning("Got notfound signal !"); |
979 | QMessageBox::information( this, tr( "Not Found" ), | 1020 | QMessageBox::information( this, tr( "Not Found" ), |
980 | tr( "Unable to find a contact for this" ) + "\n" | 1021 | tr( "Unable to find a contact for this" ) + "\n" |
981 | + tr( "search pattern !" ) ); | 1022 | + tr( "search pattern !" ) ); |
982 | 1023 | ||
983 | 1024 | ||
984 | } | 1025 | } |
985 | void AddressbookWindow::slotWrapAround() | 1026 | void AddressbookWindow::slotWrapAround() |
986 | { | 1027 | { |
987 | qWarning("Got wrap signal !"); | 1028 | qWarning("Got wrap signal !"); |
988 | if ( doNotifyWrapAround ) | 1029 | if ( doNotifyWrapAround ) |
989 | QMessageBox::information( this, tr( "End of list" ), | 1030 | QMessageBox::information( this, tr( "End of list" ), |
990 | tr( "End of list. Wrap around now.. !" ) + "\n" ); | 1031 | tr( "End of list. Wrap around now.. !" ) + "\n" ); |
991 | 1032 | ||
992 | } | 1033 | } |
993 | 1034 | ||
994 | void AddressbookWindow::slotSetCategory( int c ) | 1035 | void AddressbookWindow::slotSetCategory( int c ) |
995 | { | 1036 | { |
996 | 1037 | ||
997 | QString cat, book; | 1038 | QString cat, book; |
998 | 1039 | ||
999 | if ( c <= 0 ) | 1040 | if ( c <= 0 ) |
1000 | return; | 1041 | return; |
1001 | 1042 | ||
1002 | // Set checkItem for selected one | 1043 | // Set checkItem for selected one |
1003 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) | 1044 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) |
1004 | catMenu->setItemChecked( i, c == (int)i ); | 1045 | catMenu->setItemChecked( i, c == (int)i ); |
1005 | 1046 | ||
1006 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { | 1047 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { |
1007 | if (catMenu->isItemChecked( i )) { | 1048 | if (catMenu->isItemChecked( i )) { |
1008 | if ( i == 1 ) // default List view | 1049 | if ( i == 1 ) // default List view |
1009 | book = QString::null; | 1050 | book = QString::null; |
1010 | else if ( i == 2 ) | 1051 | else if ( i == 2 ) |
1011 | book = "Phone"; | 1052 | book = "Phone"; |
1012 | else if ( i == 3 ) | 1053 | else if ( i == 3 ) |
1013 | book = "Company"; | 1054 | book = "Company"; |
1014 | else if ( i == 4 ) | 1055 | else if ( i == 4 ) |
1015 | book = "Email"; | 1056 | book = "Email"; |
1016 | else if ( i == 5 ) | 1057 | else if ( i == 5 ) |
1017 | book = "Cards"; | 1058 | book = "Cards"; |
1018 | else if ( i == 6 ) // default All Categories | 1059 | else if ( i == 6 ) // default All Categories |
1019 | cat = QString::null; | 1060 | cat = QString::null; |
1020 | else if ( i == (unsigned int)catMenu->count() ) // last menu option will be Unfiled | 1061 | else if ( i == (unsigned int)catMenu->count() ) // last menu option will be Unfiled |
1021 | cat = "Unfiled"; | 1062 | cat = "Unfiled"; |
1022 | else | 1063 | else |
1023 | cat = abList->categories()[i - 7]; | 1064 | cat = abList->categories()[i - 7]; |
1024 | } | 1065 | } |
1025 | } | 1066 | } |
1026 | 1067 | ||
1027 | abList->setShowCategory( book, cat ); | 1068 | abList->setShowCategory( book, cat ); |
1028 | 1069 | ||
1029 | if ( book.isEmpty() ) | 1070 | if ( book.isEmpty() ) |
1030 | book = "List"; | 1071 | book = "List"; |
1031 | if ( cat.isEmpty() ) | 1072 | if ( cat.isEmpty() ) |
1032 | cat = "All"; | 1073 | cat = "All"; |
1033 | 1074 | ||
1034 | setCaption( tr( "Contacts" ) + " - " + tr( book ) + " - " + tr( cat ) ); | 1075 | setCaption( tr( "Contacts" ) + " - " + tr( book ) + " - " + tr( cat ) ); |
1035 | } | 1076 | } |
1036 | 1077 | ||
1037 | void AddressbookWindow::slotSetLetter( char c ) { | 1078 | void AddressbookWindow::slotSetLetter( char c ) { |
1038 | 1079 | ||
1039 | abList->setShowByLetter( c ); | 1080 | abList->setShowByLetter( c ); |
1040 | 1081 | ||
1041 | } | 1082 | } |
1042 | 1083 | ||
1043 | void AddressbookWindow::populateCategories() | 1084 | void AddressbookWindow::populateCategories() |
1044 | { | 1085 | { |
1045 | catMenu->clear(); | 1086 | catMenu->clear(); |
1046 | 1087 | ||
1047 | int id, rememberId; | 1088 | int id, rememberId; |
1048 | id = 1; | 1089 | id = 1; |
1049 | rememberId = 0; | 1090 | rememberId = 0; |
1050 | 1091 | ||
1051 | catMenu->insertItem( tr( "List" ), id++ ); | 1092 | catMenu->insertItem( tr( "List" ), id++ ); |
1052 | catMenu->insertItem( tr( "Phone Book" ), id++ ); | 1093 | catMenu->insertItem( tr( "Phone Book" ), id++ ); |
1053 | catMenu->insertItem( tr( "Company Book" ), id++ ); | 1094 | catMenu->insertItem( tr( "Company Book" ), id++ ); |
1054 | catMenu->insertItem( tr( "Email Book" ), id++ ); | 1095 | catMenu->insertItem( tr( "Email Book" ), id++ ); |
1055 | catMenu->insertItem( tr( "Cards" ), id++ ); | 1096 | catMenu->insertItem( tr( "Cards" ), id++ ); |
1056 | catMenu->insertSeparator(); | 1097 | catMenu->insertSeparator(); |
1057 | 1098 | ||
1058 | catMenu->insertItem( tr( "All" ), id++ ); | 1099 | catMenu->insertItem( tr( "All" ), id++ ); |
1059 | QStringList categories = abList->categories(); | 1100 | QStringList categories = abList->categories(); |
1060 | categories.append( tr( "Unfiled" ) ); | 1101 | categories.append( tr( "Unfiled" ) ); |
1061 | for ( QStringList::Iterator it = categories.begin(); | 1102 | for ( QStringList::Iterator it = categories.begin(); |
1062 | it != categories.end(); ++it ) { | 1103 | it != categories.end(); ++it ) { |
1063 | catMenu->insertItem( *it, id ); | 1104 | catMenu->insertItem( *it, id ); |
1064 | if ( *it == abList->showCategory() ) | 1105 | if ( *it == abList->showCategory() ) |
1065 | rememberId = id; | 1106 | rememberId = id; |
1066 | ++id; | 1107 | ++id; |
1067 | } | 1108 | } |
1068 | 1109 | ||
1069 | if ( abList->showBook().isEmpty() ) { | 1110 | if ( abList->showBook().isEmpty() ) { |
1070 | catMenu->setItemChecked( 1, true ); | 1111 | catMenu->setItemChecked( 1, true ); |
1071 | } else if ( abList->showBook() == "Phone" ) { | 1112 | } else if ( abList->showBook() == "Phone" ) { |
1072 | catMenu->setItemChecked( 2, true ); | 1113 | catMenu->setItemChecked( 2, true ); |
1073 | } else if ( abList->showBook() == "Company" ) { | 1114 | } else if ( abList->showBook() == "Company" ) { |
1074 | catMenu->setItemChecked( 3, true ); | 1115 | catMenu->setItemChecked( 3, true ); |
1075 | } else if ( abList->showBook() == "Email" ) { | 1116 | } else if ( abList->showBook() == "Email" ) { |
1076 | catMenu->setItemChecked( 4, true ); | 1117 | catMenu->setItemChecked( 4, true ); |
1077 | } else if ( abList->showBook() == "Cards" ) { | 1118 | } else if ( abList->showBook() == "Cards" ) { |
1078 | catMenu->setItemChecked( 5, true ); | 1119 | catMenu->setItemChecked( 5, true ); |
1079 | } | 1120 | } |
1080 | 1121 | ||
1081 | if ( abList->showCategory().isEmpty() ) { | 1122 | if ( abList->showCategory().isEmpty() ) { |
1082 | slotSetCategory( 6 ); | 1123 | slotSetCategory( 6 ); |
1083 | } | 1124 | } |
1084 | else { | 1125 | else { |
1085 | slotSetCategory( rememberId ); | 1126 | slotSetCategory( rememberId ); |
1086 | } | 1127 | } |
1087 | } | 1128 | } |
1088 | 1129 | ||
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h index 299ed70..8027ccf 100644 --- a/core/pim/addressbook/addressbook.h +++ b/core/pim/addressbook/addressbook.h | |||
@@ -1,133 +1,136 @@ | |||
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 | void slotFindNext(); | 65 | void slotFindNext(); |
66 | void slotFindPrevious(); | 66 | void slotFindPrevious(); |
67 | #ifdef __DEBUG_RELEASE | 67 | #ifdef __DEBUG_RELEASE |
68 | void slotSave(); | 68 | void slotSave(); |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | private slots: | 71 | private slots: |
72 | void importvCard(); | 72 | void importvCard(); |
73 | void slotListNew(); | 73 | void slotListNew(); |
74 | void slotListView(); | 74 | void slotListView(); |
75 | void slotListDelete(); | 75 | void slotListDelete(); |
76 | void slotViewBack(); | 76 | void slotViewBack(); |
77 | void slotViewEdit(); | 77 | void slotViewEdit(); |
78 | void slotPersonalView(); | 78 | void slotPersonalView(); |
79 | void listIsEmpty( bool ); | 79 | void listIsEmpty( bool ); |
80 | void slotSettings(); | 80 | void slotSettings(); |
81 | void writeMail(); | 81 | void writeMail(); |
82 | void slotBeam(); | 82 | void slotBeam(); |
83 | void beamDone( Ir * ); | 83 | void beamDone( Ir * ); |
84 | void slotSetCategory( int ); | 84 | void slotSetCategory( int ); |
85 | void slotSetLetter( char ); | 85 | void slotSetLetter( char ); |
86 | void slotUpdateToolbar(); | 86 | void slotUpdateToolbar(); |
87 | void slotSetFont(int); | 87 | void slotSetFont(int); |
88 | 88 | ||
89 | void slotFindOpen(); | 89 | void slotFindOpen(); |
90 | void slotFindClose(); | 90 | void slotFindClose(); |
91 | void slotFind(); | 91 | void slotFind(); |
92 | void slotNotFound(); | 92 | void slotNotFound(); |
93 | void slotWrapAround(); | 93 | void slotWrapAround(); |
94 | 94 | ||
95 | void slotConfig(); | 95 | void slotConfig(); |
96 | 96 | ||
97 | private: | 97 | private: |
98 | void initFields(); // inititialize our fields... | 98 | void initFields(); // inititialize our fields... |
99 | AbLabel *abView(); | 99 | AbLabel *abView(); |
100 | void populateCategories(); | 100 | void populateCategories(); |
101 | 101 | ||
102 | QPopupMenu *catMenu, *fontMenu; | 102 | QPopupMenu *catMenu, *fontMenu; |
103 | QPEToolBar *listTools; | 103 | QPEToolBar *listTools; |
104 | QToolButton *deleteButton; | 104 | QToolButton *deleteButton; |
105 | QValueList<int> allFields, orderedFields; | 105 | QValueList<int> allFields, orderedFields; |
106 | QStringList slOrderedFields; | 106 | QStringList slOrderedFields; |
107 | enum Panes { paneList=0, paneView, paneEdit }; | 107 | enum Panes { paneList=0, paneView, paneEdit }; |
108 | ContactEditor *abEditor; | 108 | ContactEditor *abEditor; |
109 | AbLabel *mView; | 109 | AbLabel *mView; |
110 | LetterPicker *pLabel; | 110 | LetterPicker *pLabel; |
111 | AbTable *abList; | 111 | AbTable *abList; |
112 | QWidget *listContainer; | 112 | QWidget *listContainer; |
113 | 113 | ||
114 | // Searching stuff | 114 | // Searching stuff |
115 | OFloatBar* searchBar; | 115 | OFloatBar* searchBar; |
116 | QLineEdit* searchEdit; | 116 | QLineEdit* searchEdit; |
117 | bool useRegExp; | 117 | bool useRegExp; |
118 | bool doNotifyWrapAround; | 118 | bool doNotifyWrapAround; |
119 | bool caseSensitive; | 119 | bool caseSensitive; |
120 | 120 | ||
121 | bool m_useQtMail; | ||
122 | bool m_useOpieMail; | ||
123 | |||
121 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; | 124 | QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; |
122 | 125 | ||
123 | bool bAbEditFirstTime; | 126 | bool bAbEditFirstTime; |
124 | int viewMargin; | 127 | int viewMargin; |
125 | 128 | ||
126 | bool syncing; | 129 | bool syncing; |
127 | QFont *defaultFont; | 130 | QFont *defaultFont; |
128 | int startFontSize; | 131 | int startFontSize; |
129 | 132 | ||
130 | bool isLoading; | 133 | bool isLoading; |
131 | }; | 134 | }; |
132 | 135 | ||
133 | #endif | 136 | #endif |
diff --git a/core/pim/addressbook/configdlg.cpp b/core/pim/addressbook/configdlg.cpp index b7c3b77..c0195d1 100644 --- a/core/pim/addressbook/configdlg.cpp +++ b/core/pim/addressbook/configdlg.cpp | |||
@@ -1,45 +1,61 @@ | |||
1 | #include "configdlg.h" | 1 | #include "configdlg.h" |
2 | #include <qcheckbox.h> | 2 | #include <qcheckbox.h> |
3 | #include <qradiobutton.h> | 3 | #include <qradiobutton.h> |
4 | 4 | ||
5 | ConfigDlg::ConfigDlg( QWidget *parent = 0, const char *name = 0 ): | 5 | ConfigDlg::ConfigDlg( QWidget *parent = 0, const char *name = 0 ): |
6 | ConfigDlg_Base(parent, name, true ) | 6 | ConfigDlg_Base(parent, name, true ) |
7 | {} | 7 | {} |
8 | 8 | ||
9 | 9 | ||
10 | bool ConfigDlg::useRegExp() const | 10 | bool ConfigDlg::useRegExp() const |
11 | { | 11 | { |
12 | return m_useRegExp->isOn(); | 12 | return m_useRegExp->isOn(); |
13 | } | 13 | } |
14 | bool ConfigDlg::useWildCards() const | 14 | bool ConfigDlg::useWildCards() const |
15 | { | 15 | { |
16 | return m_useWildCard->isOn(); | 16 | return m_useWildCard->isOn(); |
17 | } | 17 | } |
18 | bool ConfigDlg::useQtMail() const | ||
19 | { | ||
20 | return m_useQtMail->isOn(); | ||
21 | } | ||
22 | bool ConfigDlg::useOpieMail() const | ||
23 | { | ||
24 | return m_useOpieMail->isOn(); | ||
25 | } | ||
18 | bool ConfigDlg::beCaseSensitive() const | 26 | bool ConfigDlg::beCaseSensitive() const |
19 | { | 27 | { |
20 | return m_useCaseSensitive->isChecked(); | 28 | return m_useCaseSensitive->isChecked(); |
21 | } | 29 | } |
22 | bool ConfigDlg::signalWrapAround() const | 30 | bool ConfigDlg::signalWrapAround() const |
23 | { | 31 | { |
24 | return m_signalWrapAround->isChecked(); | 32 | return m_signalWrapAround->isChecked(); |
25 | } | 33 | } |
26 | void ConfigDlg::setUseRegExp( bool v ) | 34 | void ConfigDlg::setUseRegExp( bool v ) |
27 | { | 35 | { |
28 | m_useRegExp->setChecked( v ); | 36 | m_useRegExp->setChecked( v ); |
29 | } | 37 | } |
30 | void ConfigDlg::setUseWildCards( bool v ) | 38 | void ConfigDlg::setUseWildCards( bool v ) |
31 | { | 39 | { |
32 | m_useWildCard->setChecked( v ); | 40 | m_useWildCard->setChecked( v ); |
33 | } | 41 | } |
34 | void ConfigDlg::setBeCaseSensitive( bool v ) | 42 | void ConfigDlg::setBeCaseSensitive( bool v ) |
35 | { | 43 | { |
36 | m_useCaseSensitive->setChecked( v ); | 44 | m_useCaseSensitive->setChecked( v ); |
37 | } | 45 | } |
38 | void ConfigDlg::setSignalWrapAround( bool v ) | 46 | void ConfigDlg::setSignalWrapAround( bool v ) |
39 | { | 47 | { |
40 | m_signalWrapAround->setChecked( v ); | 48 | m_signalWrapAround->setChecked( v ); |
41 | } | 49 | } |
50 | void ConfigDlg::setQtMail( bool v ) | ||
51 | { | ||
52 | m_useQtMail->setChecked( v ); | ||
53 | } | ||
54 | void ConfigDlg::setOpieMail( bool v ) | ||
55 | { | ||
56 | m_useOpieMail->setChecked( v ); | ||
57 | } | ||
42 | 58 | ||
43 | 59 | ||
44 | 60 | ||
45 | 61 | ||
diff --git a/core/pim/addressbook/configdlg.h b/core/pim/addressbook/configdlg.h index 8be469b..34e9718 100644 --- a/core/pim/addressbook/configdlg.h +++ b/core/pim/addressbook/configdlg.h | |||
@@ -1,25 +1,29 @@ | |||
1 | #ifndef _CONFIGDLG_H_ | 1 | #ifndef _CONFIGDLG_H_ |
2 | #define _CONFIGDLG_H_ | 2 | #define _CONFIGDLG_H_ |
3 | 3 | ||
4 | #include "configdlg_base.h" | 4 | #include "configdlg_base.h" |
5 | 5 | ||
6 | class ConfigDlg: public ConfigDlg_Base | 6 | class ConfigDlg: public ConfigDlg_Base |
7 | { | 7 | { |
8 | Q_OBJECT | 8 | Q_OBJECT |
9 | public: | 9 | public: |
10 | ConfigDlg( QWidget *parent = 0, const char *name = 0 ); | 10 | ConfigDlg( QWidget *parent = 0, const char *name = 0 ); |
11 | 11 | ||
12 | // Search Settings | 12 | // Search Settings |
13 | bool useRegExp() const; | 13 | bool useRegExp() const; |
14 | bool useWildCards() const; | 14 | bool useWildCards() const; |
15 | bool beCaseSensitive() const; | 15 | bool beCaseSensitive() const; |
16 | bool signalWrapAround() const; | 16 | bool signalWrapAround() const; |
17 | bool useQtMail() const; | ||
18 | bool useOpieMail() const; | ||
17 | 19 | ||
18 | void setUseRegExp( bool v ); | 20 | void setUseRegExp( bool v ); |
19 | void setUseWildCards( bool v ); | 21 | void setUseWildCards( bool v ); |
20 | void setBeCaseSensitive( bool v ); | 22 | void setBeCaseSensitive( bool v ); |
21 | void setSignalWrapAround( bool v ); | 23 | void setSignalWrapAround( bool v ); |
24 | void setQtMail( bool v ); | ||
25 | void setOpieMail( bool v ); | ||
22 | }; | 26 | }; |
23 | 27 | ||
24 | 28 | ||
25 | #endif | 29 | #endif |
diff --git a/core/pim/addressbook/configdlg_base.ui b/core/pim/addressbook/configdlg_base.ui index e082702..d3ea12e 100644 --- a/core/pim/addressbook/configdlg_base.ui +++ b/core/pim/addressbook/configdlg_base.ui | |||
@@ -1,232 +1,335 @@ | |||
1 | <!DOCTYPE UI><UI> | 1 | <!DOCTYPE UI><UI> |
2 | <class>ConfigDlg_Base</class> | 2 | <class>ConfigDlg_Base</class> |
3 | <author>Stefan Eilers</author> | 3 | <author>Stefan Eilers</author> |
4 | <widget> | 4 | <widget> |
5 | <class>QDialog</class> | 5 | <class>QDialog</class> |
6 | <property stdset="1"> | 6 | <property stdset="1"> |
7 | <name>name</name> | 7 | <name>name</name> |
8 | <cstring>Configuration</cstring> | 8 | <cstring>Configuration</cstring> |
9 | </property> | 9 | </property> |
10 | <property stdset="1"> | 10 | <property stdset="1"> |
11 | <name>geometry</name> | 11 | <name>geometry</name> |
12 | <rect> | 12 | <rect> |
13 | <x>0</x> | 13 | <x>0</x> |
14 | <y>0</y> | 14 | <y>0</y> |
15 | <width>227</width> | 15 | <width>217</width> |
16 | <height>287</height> | 16 | <height>287</height> |
17 | </rect> | 17 | </rect> |
18 | </property> | 18 | </property> |
19 | <property stdset="1"> | 19 | <property stdset="1"> |
20 | <name>caption</name> | 20 | <name>caption</name> |
21 | <string>MyDialog1</string> | 21 | <string>MyDialog1</string> |
22 | </property> | 22 | </property> |
23 | <property stdset="1"> | 23 | <property stdset="1"> |
24 | <name>sizeGripEnabled</name> | 24 | <name>sizeGripEnabled</name> |
25 | <bool>true</bool> | 25 | <bool>true</bool> |
26 | </property> | 26 | </property> |
27 | <vbox> | 27 | <vbox> |
28 | <property stdset="1"> | 28 | <property stdset="1"> |
29 | <name>margin</name> | 29 | <name>margin</name> |
30 | <number>11</number> | 30 | <number>11</number> |
31 | </property> | 31 | </property> |
32 | <property stdset="1"> | 32 | <property stdset="1"> |
33 | <name>spacing</name> | 33 | <name>spacing</name> |
34 | <number>6</number> | 34 | <number>6</number> |
35 | </property> | 35 | </property> |
36 | <widget> | 36 | <widget> |
37 | <class>QTabWidget</class> | 37 | <class>QTabWidget</class> |
38 | <property stdset="1"> | 38 | <property stdset="1"> |
39 | <name>name</name> | 39 | <name>name</name> |
40 | <cstring>configDlg_base</cstring> | 40 | <cstring>configDlg_base</cstring> |
41 | </property> | 41 | </property> |
42 | <property> | 42 | <property> |
43 | <name>layoutMargin</name> | 43 | <name>layoutMargin</name> |
44 | </property> | 44 | </property> |
45 | <widget> | 45 | <widget> |
46 | <class>QWidget</class> | 46 | <class>QWidget</class> |
47 | <property stdset="1"> | 47 | <property stdset="1"> |
48 | <name>name</name> | 48 | <name>name</name> |
49 | <cstring>Widget5</cstring> | 49 | <cstring>Widget5</cstring> |
50 | </property> | 50 | </property> |
51 | <attribute> | 51 | <attribute> |
52 | <name>title</name> | 52 | <name>title</name> |
53 | <string>Search</string> | 53 | <string>Search</string> |
54 | </attribute> | 54 | </attribute> |
55 | <vbox> | 55 | <vbox> |
56 | <property stdset="1"> | 56 | <property stdset="1"> |
57 | <name>margin</name> | 57 | <name>margin</name> |
58 | <number>5</number> | 58 | <number>5</number> |
59 | </property> | 59 | </property> |
60 | <property stdset="1"> | 60 | <property stdset="1"> |
61 | <name>spacing</name> | 61 | <name>spacing</name> |
62 | <number>6</number> | 62 | <number>6</number> |
63 | </property> | 63 | </property> |
64 | <widget> | 64 | <widget> |
65 | <class>QButtonGroup</class> | 65 | <class>QButtonGroup</class> |
66 | <property stdset="1"> | 66 | <property stdset="1"> |
67 | <name>name</name> | 67 | <name>name</name> |
68 | <cstring>ButtonGroup1</cstring> | 68 | <cstring>ButtonGroup1</cstring> |
69 | </property> | 69 | </property> |
70 | <property stdset="1"> | 70 | <property stdset="1"> |
71 | <name>title</name> | 71 | <name>title</name> |
72 | <string>Query Style</string> | 72 | <string>Query Style</string> |
73 | </property> | 73 | </property> |
74 | <vbox> | 74 | <vbox> |
75 | <property stdset="1"> | 75 | <property stdset="1"> |
76 | <name>margin</name> | 76 | <name>margin</name> |
77 | <number>11</number> | 77 | <number>11</number> |
78 | </property> | 78 | </property> |
79 | <property stdset="1"> | 79 | <property stdset="1"> |
80 | <name>spacing</name> | 80 | <name>spacing</name> |
81 | <number>6</number> | 81 | <number>6</number> |
82 | </property> | 82 | </property> |
83 | <widget> | 83 | <widget> |
84 | <class>QRadioButton</class> | 84 | <class>QRadioButton</class> |
85 | <property stdset="1"> | 85 | <property stdset="1"> |
86 | <name>name</name> | 86 | <name>name</name> |
87 | <cstring>m_useRegExp</cstring> | 87 | <cstring>m_useRegExp</cstring> |
88 | </property> | 88 | </property> |
89 | <property stdset="1"> | 89 | <property stdset="1"> |
90 | <name>text</name> | 90 | <name>text</name> |
91 | <string>Use Regular Expressions</string> | 91 | <string>Use Regular Expressions</string> |
92 | </property> | 92 | </property> |
93 | </widget> | 93 | </widget> |
94 | <widget> | 94 | <widget> |
95 | <class>QRadioButton</class> | 95 | <class>QRadioButton</class> |
96 | <property stdset="1"> | 96 | <property stdset="1"> |
97 | <name>name</name> | 97 | <name>name</name> |
98 | <cstring>m_useWildCard</cstring> | 98 | <cstring>m_useWildCard</cstring> |
99 | </property> | 99 | </property> |
100 | <property stdset="1"> | 100 | <property stdset="1"> |
101 | <name>text</name> | 101 | <name>text</name> |
102 | <string>Use Wildcards (*,?)</string> | 102 | <string>Use Wildcards (*,?)</string> |
103 | </property> | 103 | </property> |
104 | <property stdset="1"> | 104 | <property stdset="1"> |
105 | <name>checked</name> | 105 | <name>checked</name> |
106 | <bool>true</bool> | 106 | <bool>true</bool> |
107 | </property> | 107 | </property> |
108 | </widget> | 108 | </widget> |
109 | </vbox> | 109 | </vbox> |
110 | </widget> | 110 | </widget> |
111 | <widget> | 111 | <widget> |
112 | <class>QCheckBox</class> | 112 | <class>QCheckBox</class> |
113 | <property stdset="1"> | 113 | <property stdset="1"> |
114 | <name>name</name> | 114 | <name>name</name> |
115 | <cstring>m_useCaseSensitive</cstring> | 115 | <cstring>m_useCaseSensitive</cstring> |
116 | </property> | 116 | </property> |
117 | <property stdset="1"> | 117 | <property stdset="1"> |
118 | <name>text</name> | 118 | <name>text</name> |
119 | <string>Case Sensitive</string> | 119 | <string>Case Sensitive</string> |
120 | </property> | 120 | </property> |
121 | </widget> | 121 | </widget> |
122 | <widget> | 122 | <widget> |
123 | <class>QCheckBox</class> | 123 | <class>QCheckBox</class> |
124 | <property stdset="1"> | 124 | <property stdset="1"> |
125 | <name>name</name> | 125 | <name>name</name> |
126 | <cstring>m_signalWrapAround</cstring> | 126 | <cstring>m_signalWrapAround</cstring> |
127 | </property> | 127 | </property> |
128 | <property stdset="1"> | 128 | <property stdset="1"> |
129 | <name>text</name> | 129 | <name>text</name> |
130 | <string>Signal Wrap Around</string> | 130 | <string>Signal Wrap Around</string> |
131 | </property> | 131 | </property> |
132 | </widget> | 132 | </widget> |
133 | <spacer> | 133 | <spacer> |
134 | <property> | 134 | <property> |
135 | <name>name</name> | 135 | <name>name</name> |
136 | <cstring>Spacer3</cstring> | 136 | <cstring>Spacer3</cstring> |
137 | </property> | 137 | </property> |
138 | <property stdset="1"> | 138 | <property stdset="1"> |
139 | <name>orientation</name> | 139 | <name>orientation</name> |
140 | <enum>Vertical</enum> | 140 | <enum>Vertical</enum> |
141 | </property> | 141 | </property> |
142 | <property stdset="1"> | 142 | <property stdset="1"> |
143 | <name>sizeType</name> | 143 | <name>sizeType</name> |
144 | <enum>Expanding</enum> | 144 | <enum>Expanding</enum> |
145 | </property> | 145 | </property> |
146 | <property> | 146 | <property> |
147 | <name>sizeHint</name> | 147 | <name>sizeHint</name> |
148 | <size> | 148 | <size> |
149 | <width>20</width> | 149 | <width>20</width> |
150 | <height>20</height> | 150 | <height>20</height> |
151 | </size> | 151 | </size> |
152 | </property> | 152 | </property> |
153 | </spacer> | 153 | </spacer> |
154 | </vbox> | 154 | </vbox> |
155 | </widget> | 155 | </widget> |
156 | <widget> | ||
157 | <class>QWidget</class> | ||
158 | <property stdset="1"> | ||
159 | <name>name</name> | ||
160 | <cstring>tab</cstring> | ||
161 | </property> | ||
162 | <attribute> | ||
163 | <name>title</name> | ||
164 | <string>Mail</string> | ||
165 | </attribute> | ||
166 | <vbox> | ||
167 | <property stdset="1"> | ||
168 | <name>margin</name> | ||
169 | <number>5</number> | ||
170 | </property> | ||
171 | <property stdset="1"> | ||
172 | <name>spacing</name> | ||
173 | <number>6</number> | ||
174 | </property> | ||
175 | <widget> | ||
176 | <class>QButtonGroup</class> | ||
177 | <property stdset="1"> | ||
178 | <name>name</name> | ||
179 | <cstring>ButtonGroup2</cstring> | ||
180 | </property> | ||
181 | <property stdset="1"> | ||
182 | <name>title</name> | ||
183 | <string>Mail</string> | ||
184 | </property> | ||
185 | <vbox> | ||
186 | <property stdset="1"> | ||
187 | <name>margin</name> | ||
188 | <number>11</number> | ||
189 | </property> | ||
190 | <property stdset="1"> | ||
191 | <name>spacing</name> | ||
192 | <number>6</number> | ||
193 | </property> | ||
194 | <widget> | ||
195 | <class>QRadioButton</class> | ||
196 | <property stdset="1"> | ||
197 | <name>name</name> | ||
198 | <cstring>m_useQtMail</cstring> | ||
199 | </property> | ||
200 | <property stdset="1"> | ||
201 | <name>text</name> | ||
202 | <string>Prefer QT-Mail </string> | ||
203 | </property> | ||
204 | <property stdset="1"> | ||
205 | <name>checked</name> | ||
206 | <bool>true</bool> | ||
207 | </property> | ||
208 | </widget> | ||
209 | <widget> | ||
210 | <class>QRadioButton</class> | ||
211 | <property stdset="1"> | ||
212 | <name>name</name> | ||
213 | <cstring>m_useOpieMail</cstring> | ||
214 | </property> | ||
215 | <property stdset="1"> | ||
216 | <name>text</name> | ||
217 | <string>Prefer Opie-Mail</string> | ||
218 | </property> | ||
219 | </widget> | ||
220 | <widget> | ||
221 | <class>QLabel</class> | ||
222 | <property stdset="1"> | ||
223 | <name>name</name> | ||
224 | <cstring>TextLabel1</cstring> | ||
225 | </property> | ||
226 | <property stdset="1"> | ||
227 | <name>text</name> | ||
228 | <string>Notice: QT-Mail is just | ||
229 | provided in the SHARP | ||
230 | default ROM. Opie-Mail | ||
231 | is provided free !</string> | ||
232 | </property> | ||
233 | </widget> | ||
234 | </vbox> | ||
235 | </widget> | ||
236 | <spacer> | ||
237 | <property> | ||
238 | <name>name</name> | ||
239 | <cstring>Spacer2</cstring> | ||
240 | </property> | ||
241 | <property stdset="1"> | ||
242 | <name>orientation</name> | ||
243 | <enum>Vertical</enum> | ||
244 | </property> | ||
245 | <property stdset="1"> | ||
246 | <name>sizeType</name> | ||
247 | <enum>Expanding</enum> | ||
248 | </property> | ||
249 | <property> | ||
250 | <name>sizeHint</name> | ||
251 | <size> | ||
252 | <width>20</width> | ||
253 | <height>20</height> | ||
254 | </size> | ||
255 | </property> | ||
256 | </spacer> | ||
257 | </vbox> | ||
258 | </widget> | ||
156 | </widget> | 259 | </widget> |
157 | <widget> | 260 | <widget> |
158 | <class>QLayoutWidget</class> | 261 | <class>QLayoutWidget</class> |
159 | <property stdset="1"> | 262 | <property stdset="1"> |
160 | <name>name</name> | 263 | <name>name</name> |
161 | <cstring>Layout1</cstring> | 264 | <cstring>Layout1</cstring> |
162 | </property> | 265 | </property> |
163 | <hbox> | 266 | <hbox> |
164 | <property stdset="1"> | 267 | <property stdset="1"> |
165 | <name>margin</name> | 268 | <name>margin</name> |
166 | <number>0</number> | 269 | <number>0</number> |
167 | </property> | 270 | </property> |
168 | <property stdset="1"> | 271 | <property stdset="1"> |
169 | <name>spacing</name> | 272 | <name>spacing</name> |
170 | <number>6</number> | 273 | <number>6</number> |
171 | </property> | 274 | </property> |
172 | <widget> | 275 | <widget> |
173 | <class>QPushButton</class> | 276 | <class>QPushButton</class> |
174 | <property stdset="1"> | 277 | <property stdset="1"> |
175 | <name>name</name> | 278 | <name>name</name> |
176 | <cstring>buttonOk</cstring> | 279 | <cstring>buttonOk</cstring> |
177 | </property> | 280 | </property> |
178 | <property stdset="1"> | 281 | <property stdset="1"> |
179 | <name>text</name> | 282 | <name>text</name> |
180 | <string>&OK</string> | 283 | <string>&OK</string> |
181 | </property> | 284 | </property> |
182 | <property stdset="1"> | 285 | <property stdset="1"> |
183 | <name>autoDefault</name> | 286 | <name>autoDefault</name> |
184 | <bool>true</bool> | 287 | <bool>true</bool> |
185 | </property> | 288 | </property> |
186 | <property stdset="1"> | 289 | <property stdset="1"> |
187 | <name>default</name> | 290 | <name>default</name> |
188 | <bool>true</bool> | 291 | <bool>true</bool> |
189 | </property> | 292 | </property> |
190 | </widget> | 293 | </widget> |
191 | <widget> | 294 | <widget> |
192 | <class>QPushButton</class> | 295 | <class>QPushButton</class> |
193 | <property stdset="1"> | 296 | <property stdset="1"> |
194 | <name>name</name> | 297 | <name>name</name> |
195 | <cstring>buttonCancel</cstring> | 298 | <cstring>buttonCancel</cstring> |
196 | </property> | 299 | </property> |
197 | <property stdset="1"> | 300 | <property stdset="1"> |
198 | <name>text</name> | 301 | <name>text</name> |
199 | <string>&Cancel</string> | 302 | <string>&Cancel</string> |
200 | </property> | 303 | </property> |
201 | <property stdset="1"> | 304 | <property stdset="1"> |
202 | <name>autoDefault</name> | 305 | <name>autoDefault</name> |
203 | <bool>true</bool> | 306 | <bool>true</bool> |
204 | </property> | 307 | </property> |
205 | </widget> | 308 | </widget> |
206 | </hbox> | 309 | </hbox> |
207 | </widget> | 310 | </widget> |
208 | </vbox> | 311 | </vbox> |
209 | </widget> | 312 | </widget> |
210 | <connections> | 313 | <connections> |
211 | <connection> | 314 | <connection> |
212 | <sender>buttonOk</sender> | 315 | <sender>buttonOk</sender> |
213 | <signal>clicked()</signal> | 316 | <signal>clicked()</signal> |
214 | <receiver>Configuration</receiver> | 317 | <receiver>Configuration</receiver> |
215 | <slot>accept()</slot> | 318 | <slot>accept()</slot> |
216 | </connection> | 319 | </connection> |
217 | <connection> | 320 | <connection> |
218 | <sender>buttonCancel</sender> | 321 | <sender>buttonCancel</sender> |
219 | <signal>clicked()</signal> | 322 | <signal>clicked()</signal> |
220 | <receiver>Configuration</receiver> | 323 | <receiver>Configuration</receiver> |
221 | <slot>reject()</slot> | 324 | <slot>reject()</slot> |
222 | </connection> | 325 | </connection> |
223 | </connections> | 326 | </connections> |
224 | <tabstops> | 327 | <tabstops> |
225 | <tabstop>configDlg_base</tabstop> | 328 | <tabstop>configDlg_base</tabstop> |
226 | <tabstop>m_useWildCard</tabstop> | 329 | <tabstop>m_useWildCard</tabstop> |
227 | <tabstop>m_useCaseSensitive</tabstop> | 330 | <tabstop>m_useCaseSensitive</tabstop> |
228 | <tabstop>m_signalWrapAround</tabstop> | 331 | <tabstop>m_signalWrapAround</tabstop> |
229 | <tabstop>buttonOk</tabstop> | 332 | <tabstop>buttonOk</tabstop> |
230 | <tabstop>buttonCancel</tabstop> | 333 | <tabstop>buttonCancel</tabstop> |
231 | </tabstops> | 334 | </tabstops> |
232 | </UI> | 335 | </UI> |
diff --git a/core/pim/addressbook/opie-addressbook.control b/core/pim/addressbook/opie-addressbook.control index 14b0770..0a04ee6 100644 --- a/core/pim/addressbook/opie-addressbook.control +++ b/core/pim/addressbook/opie-addressbook.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Files: bin/addressbook apps/1Pim/addressbook.desktop | 1 | Files: bin/addressbook apps/1Pim/addressbook.desktop |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/applications | 3 | Section: opie/applications |
4 | Maintainer: Warwick Allison <warwick@trolltech.com> | 4 | Maintainer: Stefan Eilers <eilers.stefan@epost.de> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: $QPE_VERSION-$SUB_VERSION | 6 | Version: $QPE_VERSION-$SUB_VERSION |
7 | Depends: opie-base ($QPE_VERSION) libopie | 7 | Depends: opie-base ($QPE_VERSION) libopie |
8 | Description: Contacts | 8 | Description: Contacts |
9 | A simple addressbook for the Opie environment. | 9 | A simple addressbook for the Opie environment. |
diff --git a/core/pim/addressbook/picker.cpp b/core/pim/addressbook/picker.cpp index 7f4acb0..2c7dd71 100644 --- a/core/pim/addressbook/picker.cpp +++ b/core/pim/addressbook/picker.cpp | |||
@@ -1,239 +1,239 @@ | |||
1 | #include "picker.h" | 1 | #include "picker.h" |
2 | 2 | ||
3 | #include <qfont.h> | 3 | #include <qfont.h> |
4 | #include <qstring.h> | 4 | #include <qstring.h> |
5 | #include <qtimer.h> | 5 | #include <qtimer.h> |
6 | #include <qlayout.h> | 6 | #include <qlayout.h> |
7 | 7 | ||
8 | char PickerLabel::lastLetter = '\0'; | 8 | char PickerLabel::lastLetter = '\0'; |
9 | 9 | ||
10 | PickerLabel::PickerLabel( QWidget *parent, const char *name ) | 10 | PickerLabel::PickerLabel( QWidget *parent, const char *name ) |
11 | : QLabel ( parent, name ) | 11 | : QLabel ( parent, name ) |
12 | { | 12 | { |
13 | currentLetter = 0; | 13 | currentLetter = 0; |
14 | //lastLetter = 0; | 14 | //lastLetter = 0; |
15 | 15 | ||
16 | letter1 = '\0'; | 16 | letter1 = '\0'; |
17 | letter2 = '\0'; | 17 | letter2 = '\0'; |
18 | letter3 = '\0'; | 18 | letter3 = '\0'; |
19 | 19 | ||
20 | setFont( QFont( "smallsmooth", 9 ) ); | 20 | setFont( QFont( "smallsmooth", 9 ) ); |
21 | setTextFormat( Qt::RichText ); | 21 | setTextFormat( Qt::RichText ); |
22 | 22 | ||
23 | } | 23 | } |
24 | 24 | ||
25 | PickerLabel::~PickerLabel() | 25 | PickerLabel::~PickerLabel() |
26 | { | 26 | { |
27 | 27 | ||
28 | } | 28 | } |
29 | 29 | ||
30 | void PickerLabel::setLetters( char ch1, char ch2, char ch3 ) | 30 | void PickerLabel::setLetters( char ch1, char ch2, char ch3 ) |
31 | { | 31 | { |
32 | QString tmpStr; | 32 | QString tmpStr; |
33 | 33 | ||
34 | if (ch1 != '\0') | 34 | if (ch1 != '\0') |
35 | letter1 = ch1; | 35 | letter1 = ch1; |
36 | else | 36 | else |
37 | letter1 = ' '; | 37 | letter1 = ' '; |
38 | 38 | ||
39 | if (ch2 != '\0') | 39 | if (ch2 != '\0') |
40 | letter2 = ch2; | 40 | letter2 = ch2; |
41 | else | 41 | else |
42 | letter2 = ' '; | 42 | letter2 = ' '; |
43 | 43 | ||
44 | if (ch3 != '\0') | 44 | if (ch3 != '\0') |
45 | letter3 = ch3; | 45 | letter3 = ch3; |
46 | else | 46 | else |
47 | letter3 = ' '; | 47 | letter3 = ' '; |
48 | 48 | ||
49 | tmpStr = "<qt>"; | 49 | tmpStr = "<qt>"; |
50 | tmpStr += letter1; | 50 | tmpStr += letter1; |
51 | tmpStr += letter2; | 51 | tmpStr += letter2; |
52 | tmpStr += letter3; | 52 | tmpStr += letter3; |
53 | tmpStr += "</qt>"; | 53 | tmpStr += "</qt>"; |
54 | 54 | ||
55 | setText(tmpStr); | 55 | setText(tmpStr); |
56 | 56 | ||
57 | currentLetter = 0; | 57 | currentLetter = 0; |
58 | 58 | ||
59 | } | 59 | } |
60 | 60 | ||
61 | void PickerLabel::clearLetter() | 61 | void PickerLabel::clearLetter() |
62 | { | 62 | { |
63 | 63 | ||
64 | QString tmpStr; | 64 | QString tmpStr; |
65 | 65 | ||
66 | tmpStr = "<qt>"; | 66 | tmpStr = "<qt>"; |
67 | tmpStr += letter1; | 67 | tmpStr += letter1; |
68 | tmpStr += letter2; | 68 | tmpStr += letter2; |
69 | tmpStr += letter3; | 69 | tmpStr += letter3; |
70 | tmpStr += "</qt>"; | 70 | tmpStr += "</qt>"; |
71 | 71 | ||
72 | setText(tmpStr); | 72 | setText(tmpStr); |
73 | 73 | ||
74 | currentLetter = 0; | 74 | currentLetter = 0; |
75 | 75 | ||
76 | } | 76 | } |
77 | 77 | ||
78 | void PickerLabel::mousePressEvent( QMouseEvent* e ) | 78 | void PickerLabel::mousePressEvent( QMouseEvent* e ) |
79 | { | 79 | { |
80 | // If one pickerlabel is was, and an other is now selected, we | 80 | // If one pickerlabel is was, and an other is now selected, we |
81 | // have to simulate the releaseevent.. Otherwise the new label | 81 | // have to simulate the releaseevent.. Otherwise the new label |
82 | // will not get a highlighted letter.. | 82 | // will not get a highlighted letter.. |
83 | // Maybe there is a more intelligent solution, but this works and I am tired.. (se) | 83 | // Maybe there is a more intelligent solution, but this works and I am tired.. (se) |
84 | if ( ( currentLetter == 0 ) && ( lastLetter != '\0' ) ) mouseReleaseEvent( e ); | 84 | if ( ( currentLetter == 0 ) && ( lastLetter != '\0' ) ) mouseReleaseEvent( e ); |
85 | } | 85 | } |
86 | 86 | ||
87 | void PickerLabel::mouseReleaseEvent( QMouseEvent* /* e */ ) | 87 | void PickerLabel::mouseReleaseEvent( QMouseEvent* /* e */ ) |
88 | { | 88 | { |
89 | QString tmpStr; | 89 | QString tmpStr; |
90 | 90 | ||
91 | if (lastLetter != letter1 && lastLetter != letter2 && lastLetter != letter3 && lastLetter != '\0') | 91 | if (lastLetter != letter1 && lastLetter != letter2 && lastLetter != letter3 && lastLetter != '\0') |
92 | QTimer::singleShot( 0, this, SLOT(emitClearSignal()) ); | 92 | QTimer::singleShot( 0, this, SLOT(emitClearSignal()) ); |
93 | 93 | ||
94 | switch (currentLetter) { | 94 | switch (currentLetter) { |
95 | case 0: | 95 | case 0: |
96 | tmpStr = "<qt><u><font color=\"#7F0000\">"; | 96 | tmpStr = "<qt><u><b><font color=\"#FF00FF\">"; |
97 | tmpStr += letter1; | 97 | tmpStr += letter1; |
98 | tmpStr += "</font></u>"; | 98 | tmpStr += "</font></b></u>"; |
99 | tmpStr += letter2; | 99 | tmpStr += letter2; |
100 | tmpStr += letter3; | 100 | tmpStr += letter3; |
101 | tmpStr += "</qt>"; | 101 | tmpStr += "</qt>"; |
102 | 102 | ||
103 | setText(tmpStr); | 103 | setText(tmpStr); |
104 | 104 | ||
105 | currentLetter++; | 105 | currentLetter++; |
106 | lastLetter = letter1; | 106 | lastLetter = letter1; |
107 | emit selectedLetter( letter1 ); | 107 | emit selectedLetter( letter1 ); |
108 | break; | 108 | break; |
109 | 109 | ||
110 | case 1: | 110 | case 1: |
111 | tmpStr = "<qt>"; | 111 | tmpStr = "<qt>"; |
112 | tmpStr += letter1; | 112 | tmpStr += letter1; |
113 | tmpStr += "<u><font color=\"#7F0000\">"; | 113 | tmpStr += "<u><b><font color=\"#FF00FF\">"; |
114 | tmpStr += letter2; | 114 | tmpStr += letter2; |
115 | tmpStr += "</font></u>"; | 115 | tmpStr += "</font></b></u>"; |
116 | tmpStr += letter3; | 116 | tmpStr += letter3; |
117 | tmpStr += "</qt>"; | 117 | tmpStr += "</qt>"; |
118 | 118 | ||
119 | setText(tmpStr); | 119 | setText(tmpStr); |
120 | 120 | ||
121 | currentLetter++; | 121 | currentLetter++; |
122 | lastLetter = letter2; | 122 | lastLetter = letter2; |
123 | emit selectedLetter( letter2 ); | 123 | emit selectedLetter( letter2 ); |
124 | break; | 124 | break; |
125 | 125 | ||
126 | case 2: | 126 | case 2: |
127 | tmpStr = "<qt>"; | 127 | tmpStr = "<qt>"; |
128 | tmpStr += letter1; | 128 | tmpStr += letter1; |
129 | tmpStr += letter2; | 129 | tmpStr += letter2; |
130 | tmpStr += "<u><font color=\"#7F0000\">"; | 130 | tmpStr += "<u><b><font color=\"#FF00FF\">"; |
131 | tmpStr += letter3; | 131 | tmpStr += letter3; |
132 | tmpStr += "</font></u></qt>"; | 132 | tmpStr += "</font></b></u></qt>"; |
133 | 133 | ||
134 | setText(tmpStr); | 134 | setText(tmpStr); |
135 | 135 | ||
136 | currentLetter++; | 136 | currentLetter++; |
137 | lastLetter = letter3; | 137 | lastLetter = letter3; |
138 | emit selectedLetter( letter3 ); | 138 | emit selectedLetter( letter3 ); |
139 | break; | 139 | break; |
140 | 140 | ||
141 | default: | 141 | default: |
142 | clearLetter(); | 142 | clearLetter(); |
143 | lastLetter = '\0'; | 143 | lastLetter = '\0'; |
144 | emit selectedLetter( '\0' ); | 144 | emit selectedLetter( '\0' ); |
145 | 145 | ||
146 | 146 | ||
147 | } | 147 | } |
148 | } | 148 | } |
149 | 149 | ||
150 | void PickerLabel::emitClearSignal() { | 150 | void PickerLabel::emitClearSignal() { |
151 | emit clearAll(); | 151 | emit clearAll(); |
152 | } | 152 | } |
153 | 153 | ||
154 | LetterPicker::LetterPicker( QWidget *parent, const char *name ) | 154 | LetterPicker::LetterPicker( QWidget *parent, const char *name ) |
155 | : QFrame( parent, name ) | 155 | : QFrame( parent, name ) |
156 | { | 156 | { |
157 | QHBoxLayout *l = new QHBoxLayout(this); | 157 | QHBoxLayout *l = new QHBoxLayout(this); |
158 | 158 | ||
159 | lblABC = new PickerLabel( this ); | 159 | lblABC = new PickerLabel( this ); |
160 | l->addWidget( lblABC ); | 160 | l->addWidget( lblABC ); |
161 | 161 | ||
162 | lblDEF = new PickerLabel( this ); | 162 | lblDEF = new PickerLabel( this ); |
163 | l->addWidget( lblDEF ); | 163 | l->addWidget( lblDEF ); |
164 | 164 | ||
165 | lblGHI = new PickerLabel( this ); | 165 | lblGHI = new PickerLabel( this ); |
166 | l->addWidget( lblGHI ); | 166 | l->addWidget( lblGHI ); |
167 | 167 | ||
168 | lblJKL = new PickerLabel( this ); | 168 | lblJKL = new PickerLabel( this ); |
169 | l->addWidget( lblJKL ); | 169 | l->addWidget( lblJKL ); |
170 | 170 | ||
171 | lblMNO = new PickerLabel( this ); | 171 | lblMNO = new PickerLabel( this ); |
172 | l->addWidget( lblMNO ); | 172 | l->addWidget( lblMNO ); |
173 | 173 | ||
174 | lblPQR = new PickerLabel( this ); | 174 | lblPQR = new PickerLabel( this ); |
175 | l->addWidget( lblPQR ); | 175 | l->addWidget( lblPQR ); |
176 | 176 | ||
177 | lblSTU = new PickerLabel( this ); | 177 | lblSTU = new PickerLabel( this ); |
178 | l->addWidget( lblSTU ); | 178 | l->addWidget( lblSTU ); |
179 | 179 | ||
180 | lblVWX = new PickerLabel( this ); | 180 | lblVWX = new PickerLabel( this ); |
181 | l->addWidget( lblVWX ); | 181 | l->addWidget( lblVWX ); |
182 | 182 | ||
183 | lblYZ = new PickerLabel( this ); | 183 | lblYZ = new PickerLabel( this ); |
184 | l->addWidget( lblYZ ); | 184 | l->addWidget( lblYZ ); |
185 | 185 | ||
186 | lblABC->setLetters( 'A', 'B', 'C' ); | 186 | lblABC->setLetters( 'A', 'B', 'C' ); |
187 | lblDEF->setLetters( 'D', 'E', 'F' ); | 187 | lblDEF->setLetters( 'D', 'E', 'F' ); |
188 | lblGHI->setLetters( 'G', 'H', 'I' ); | 188 | lblGHI->setLetters( 'G', 'H', 'I' ); |
189 | lblJKL->setLetters( 'J', 'K', 'L' ); | 189 | lblJKL->setLetters( 'J', 'K', 'L' ); |
190 | lblMNO->setLetters( 'M', 'N', 'O' ); | 190 | lblMNO->setLetters( 'M', 'N', 'O' ); |
191 | lblPQR->setLetters( 'P', 'Q', 'R' ); | 191 | lblPQR->setLetters( 'P', 'Q', 'R' ); |
192 | lblSTU->setLetters( 'S', 'T', 'U' ); | 192 | lblSTU->setLetters( 'S', 'T', 'U' ); |
193 | lblVWX->setLetters( 'V', 'W', 'X' ); | 193 | lblVWX->setLetters( 'V', 'W', 'X' ); |
194 | lblYZ->setLetters( 'Y', 'Z', '#' ); | 194 | lblYZ->setLetters( 'Y', 'Z', '#' ); |
195 | 195 | ||
196 | connect(lblABC, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); | 196 | connect(lblABC, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); |
197 | connect(lblDEF, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); | 197 | connect(lblDEF, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); |
198 | connect(lblGHI, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); | 198 | connect(lblGHI, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); |
199 | connect(lblJKL, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); | 199 | connect(lblJKL, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); |
200 | connect(lblMNO, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); | 200 | connect(lblMNO, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); |
201 | connect(lblPQR, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); | 201 | connect(lblPQR, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); |
202 | connect(lblSTU, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); | 202 | connect(lblSTU, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); |
203 | connect(lblVWX, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); | 203 | connect(lblVWX, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); |
204 | connect(lblYZ, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); | 204 | connect(lblYZ, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char))); |
205 | connect(lblABC, SIGNAL(clearAll()), this, SLOT(clear())); | 205 | connect(lblABC, SIGNAL(clearAll()), this, SLOT(clear())); |
206 | connect(lblDEF, SIGNAL(clearAll()), this, SLOT(clear())); | 206 | connect(lblDEF, SIGNAL(clearAll()), this, SLOT(clear())); |
207 | connect(lblGHI, SIGNAL(clearAll()), this, SLOT(clear())); | 207 | connect(lblGHI, SIGNAL(clearAll()), this, SLOT(clear())); |
208 | connect(lblJKL, SIGNAL(clearAll()), this, SLOT(clear())); | 208 | connect(lblJKL, SIGNAL(clearAll()), this, SLOT(clear())); |
209 | connect(lblMNO, SIGNAL(clearAll()), this, SLOT(clear())); | 209 | connect(lblMNO, SIGNAL(clearAll()), this, SLOT(clear())); |
210 | connect(lblPQR, SIGNAL(clearAll()), this, SLOT(clear())); | 210 | connect(lblPQR, SIGNAL(clearAll()), this, SLOT(clear())); |
211 | connect(lblSTU, SIGNAL(clearAll()), this, SLOT(clear())); | 211 | connect(lblSTU, SIGNAL(clearAll()), this, SLOT(clear())); |
212 | connect(lblVWX, SIGNAL(clearAll()), this, SLOT(clear())); | 212 | connect(lblVWX, SIGNAL(clearAll()), this, SLOT(clear())); |
213 | connect(lblYZ, SIGNAL(clearAll()), this, SLOT(clear())); | 213 | connect(lblYZ, SIGNAL(clearAll()), this, SLOT(clear())); |
214 | 214 | ||
215 | } | 215 | } |
216 | 216 | ||
217 | LetterPicker::~LetterPicker() | 217 | LetterPicker::~LetterPicker() |
218 | { | 218 | { |
219 | } | 219 | } |
220 | 220 | ||
221 | void LetterPicker::clear() | 221 | void LetterPicker::clear() |
222 | { | 222 | { |
223 | lblABC->clearLetter(); | 223 | lblABC->clearLetter(); |
224 | lblDEF->clearLetter(); | 224 | lblDEF->clearLetter(); |
225 | lblGHI->clearLetter(); | 225 | lblGHI->clearLetter(); |
226 | lblJKL->clearLetter(); | 226 | lblJKL->clearLetter(); |
227 | lblMNO->clearLetter(); | 227 | lblMNO->clearLetter(); |
228 | lblPQR->clearLetter(); | 228 | lblPQR->clearLetter(); |
229 | lblSTU->clearLetter(); | 229 | lblSTU->clearLetter(); |
230 | lblVWX->clearLetter(); | 230 | lblVWX->clearLetter(); |
231 | lblYZ->clearLetter(); | 231 | lblYZ->clearLetter(); |
232 | } | 232 | } |
233 | 233 | ||
234 | void LetterPicker::newLetter( char letter ) | 234 | void LetterPicker::newLetter( char letter ) |
235 | { | 235 | { |
236 | qWarning("LetterClicked"); | 236 | qWarning("LetterClicked"); |
237 | emit letterClicked( letter ); | 237 | emit letterClicked( letter ); |
238 | 238 | ||
239 | } | 239 | } |