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