-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 975911e..25c6f3a 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -1,1050 +1,1051 @@ | |||
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 "abview.h" | 25 | #include "abview.h" |
26 | #include "abtable.h" | 26 | #include "abtable.h" |
27 | // #include "addresssettings.h" | 27 | // #include "addresssettings.h" |
28 | #include "addressbook.h" | 28 | #include "addressbook.h" |
29 | 29 | ||
30 | 30 | ||
31 | #include <opie/ofileselector.h> | 31 | #include <opie/ofileselector.h> |
32 | #include <opie/ofiledialog.h> | 32 | #include <opie/ofiledialog.h> |
33 | #include <opie/ocontact.h> | 33 | #include <opie/ocontact.h> |
34 | #include <opie/ocontactaccessbackend_vcard.h> | 34 | #include <opie/ocontactaccessbackend_vcard.h> |
35 | 35 | ||
36 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
37 | #include <qpe/ir.h> | 37 | #include <qpe/ir.h> |
38 | #include <qpe/qpemessagebox.h> | 38 | #include <qpe/qpemessagebox.h> |
39 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
40 | #include <qpe/qpetoolbar.h> | 40 | #include <qpe/qpetoolbar.h> |
41 | #include <qpe/qpemenubar.h> | 41 | #include <qpe/qpemenubar.h> |
42 | // #include <qtoolbar.h> | 42 | // #include <qtoolbar.h> |
43 | // #include <qmenubar.h> | 43 | // #include <qmenubar.h> |
44 | #include <qpe/qpeapplication.h> | 44 | #include <qpe/qpeapplication.h> |
45 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
46 | 46 | ||
47 | #include <qaction.h> | 47 | #include <qaction.h> |
48 | #include <qdialog.h> | 48 | #include <qdialog.h> |
49 | #include <qdir.h> | 49 | #include <qdir.h> |
50 | #include <qfile.h> | 50 | #include <qfile.h> |
51 | #include <qimage.h> | 51 | #include <qimage.h> |
52 | #include <qlayout.h> | 52 | #include <qlayout.h> |
53 | #include <qmessagebox.h> | 53 | #include <qmessagebox.h> |
54 | #include <qpixmap.h> | 54 | #include <qpixmap.h> |
55 | #include <qpopupmenu.h> | 55 | #include <qpopupmenu.h> |
56 | #include <qstringlist.h> | 56 | #include <qstringlist.h> |
57 | #include <qtoolbutton.h> | 57 | #include <qtoolbutton.h> |
58 | #include <qwhatsthis.h> | 58 | #include <qwhatsthis.h> |
59 | #include <qdatetime.h> | 59 | #include <qdatetime.h> |
60 | 60 | ||
61 | #include <stdlib.h> | 61 | #include <stdlib.h> |
62 | #include <sys/stat.h> | 62 | #include <sys/stat.h> |
63 | #include <sys/types.h> | 63 | #include <sys/types.h> |
64 | #include <fcntl.h> | 64 | #include <fcntl.h> |
65 | #include <unistd.h> | 65 | #include <unistd.h> |
66 | 66 | ||
67 | 67 | ||
68 | #include "picker.h" | 68 | #include "picker.h" |
69 | #include "configdlg.h" | 69 | #include "configdlg.h" |
70 | 70 | ||
71 | extern QString addressbookPersonalVCardName(); | 71 | extern QString addressbookPersonalVCardName(); |
72 | 72 | ||
73 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 73 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, |
74 | WFlags f ) | 74 | WFlags f ) |
75 | : QMainWindow( parent, name, f ), | 75 | : QMainWindow( parent, name, f ), |
76 | catMenu (0l), | 76 | catMenu (0l), |
77 | abEditor(0l), | 77 | abEditor(0l), |
78 | syncing(FALSE), | 78 | syncing(FALSE), |
79 | m_tableViewButton(0l), | 79 | m_tableViewButton(0l), |
80 | m_cardViewButton(0l) | 80 | m_cardViewButton(0l) |
81 | { | 81 | { |
82 | isLoading = true; | 82 | isLoading = true; |
83 | 83 | ||
84 | m_config.load(); | 84 | m_config.load(); |
85 | 85 | ||
86 | setCaption( tr("Contacts") ); | 86 | setCaption( tr("Contacts") ); |
87 | setIcon( Resource::loadPixmap( "AddressBook" ) ); | 87 | setIcon( Resource::loadPixmap( "AddressBook" ) ); |
88 | 88 | ||
89 | // Settings for Main Menu | 89 | // Settings for Main Menu |
90 | // setToolBarsMovable( false ); | 90 | // setToolBarsMovable( false ); |
91 | setToolBarsMovable( !m_config.fixedBars() ); | 91 | setToolBarsMovable( !m_config.fixedBars() ); |
92 | setRightJustification( true ); | 92 | setRightJustification( true ); |
93 | 93 | ||
94 | QPEToolBar *bar = new QPEToolBar( this ); | 94 | QPEToolBar *bar = new QPEToolBar( this ); |
95 | bar->setHorizontalStretchable( TRUE ); | 95 | bar->setHorizontalStretchable( TRUE ); |
96 | 96 | ||
97 | QPEMenuBar *mbList = new QPEMenuBar( bar ); | 97 | QPEMenuBar *mbList = new QPEMenuBar( bar ); |
98 | mbList->setMargin( 0 ); | 98 | mbList->setMargin( 0 ); |
99 | 99 | ||
100 | QPopupMenu *edit = new QPopupMenu( mbList ); | 100 | QPopupMenu *edit = new QPopupMenu( mbList ); |
101 | mbList->insertItem( tr( "Contact" ), edit ); | 101 | mbList->insertItem( tr( "Contact" ), edit ); |
102 | 102 | ||
103 | // Category Menu | 103 | // Category Menu |
104 | catMenu = new QPopupMenu( this ); | 104 | catMenu = new QPopupMenu( this ); |
105 | catMenu->setCheckable( TRUE ); | 105 | catMenu->setCheckable( TRUE ); |
106 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); | 106 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); |
107 | mbList->insertItem( tr("View"), catMenu ); | 107 | mbList->insertItem( tr("View"), catMenu ); |
108 | 108 | ||
109 | // Create Toolbar | 109 | // Create Toolbar |
110 | listTools = new QPEToolBar( this, "list operations" ); | 110 | listTools = new QPEToolBar( this, "list operations" ); |
111 | listTools->setHorizontalStretchable( true ); | 111 | listTools->setHorizontalStretchable( true ); |
112 | addToolBar( listTools ); | 112 | addToolBar( listTools ); |
113 | moveToolBar( listTools, m_config.getToolBarPos() ); | 113 | moveToolBar( listTools, m_config.getToolBarPos() ); |
114 | 114 | ||
115 | // View Icons | 115 | // View Icons |
116 | m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/weeklst" ), | 116 | m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/weeklst" ), |
117 | QString::null, 0, this, 0 ); | 117 | QString::null, 0, this, 0 ); |
118 | connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); | 118 | connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); |
119 | m_tableViewButton->setToggleAction( true ); | 119 | m_tableViewButton->setToggleAction( true ); |
120 | m_tableViewButton->addTo( listTools ); | 120 | m_tableViewButton->addTo( listTools ); |
121 | m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "day" ), QString::null, 0, this, 0 ); | 121 | m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "day" ), QString::null, 0, this, 0 ); |
122 | connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); | 122 | connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); |
123 | m_cardViewButton->setToggleAction( true ); | 123 | m_cardViewButton->setToggleAction( true ); |
124 | m_cardViewButton->addTo( listTools ); | 124 | m_cardViewButton->addTo( listTools ); |
125 | 125 | ||
126 | listTools->addSeparator(); | 126 | listTools->addSeparator(); |
127 | 127 | ||
128 | // Other Buttons | 128 | // Other Buttons |
129 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, | 129 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, |
130 | 0, this, 0 ); | 130 | 0, this, 0 ); |
131 | actionNew = a; | 131 | actionNew = a; |
132 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); | 132 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); |
133 | a->addTo( edit ); | 133 | a->addTo( edit ); |
134 | a->addTo( listTools ); | 134 | a->addTo( listTools ); |
135 | 135 | ||
136 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 136 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
137 | 0, this, 0 ); | 137 | 0, this, 0 ); |
138 | actionEdit = a; | 138 | actionEdit = a; |
139 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); | 139 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); |
140 | a->addTo( edit ); | 140 | a->addTo( edit ); |
141 | a->addTo( listTools ); | 141 | a->addTo( listTools ); |
142 | 142 | ||
143 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 143 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
144 | 0, this, 0 ); | 144 | 0, this, 0 ); |
145 | actionTrash = a; | 145 | actionTrash = a; |
146 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); | 146 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); |
147 | a->addTo( edit ); | 147 | a->addTo( edit ); |
148 | a->addTo( listTools ); | 148 | a->addTo( listTools ); |
149 | 149 | ||
150 | 150 | ||
151 | // make it possible to go directly to businesscard via qcop call | 151 | // make it possible to go directly to businesscard via qcop call |
152 | //#if defined(Q_WS_QWS) // Why this ? (se) | 152 | //#if defined(Q_WS_QWS) // Why this ? (se) |
153 | #if !defined(QT_NO_COP) | 153 | #if !defined(QT_NO_COP) |
154 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); | 154 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); |
155 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 155 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), |
156 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); | 156 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); |
157 | #endif | 157 | #endif |
158 | // #endif | 158 | // #endif |
159 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), | 159 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), |
160 | QString::null, 0, this, 0 ); | 160 | QString::null, 0, this, 0 ); |
161 | actionFind = a; | 161 | actionFind = a; |
162 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); | 162 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); |
163 | a->addTo( edit ); | 163 | a->addTo( edit ); |
164 | a->addTo( listTools ); | 164 | a->addTo( listTools ); |
165 | 165 | ||
166 | // Much better search widget, taken from QTReader.. (se) | 166 | // Much better search widget, taken from QTReader.. (se) |
167 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); | 167 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
168 | searchBar->setHorizontalStretchable( TRUE ); | 168 | searchBar->setHorizontalStretchable( TRUE ); |
169 | searchBar->hide(); | 169 | searchBar->hide(); |
170 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 170 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
171 | 171 | ||
172 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 172 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
173 | // searchEdit->setFont( f ); | 173 | // searchEdit->setFont( f ); |
174 | 174 | ||
175 | searchBar->setStretchableWidget( searchEdit ); | 175 | searchBar->setStretchableWidget( searchEdit ); |
176 | connect( searchEdit, SIGNAL( returnPressed( ) ), | 176 | connect( searchEdit, SIGNAL( returnPressed( ) ), |
177 | this, SLOT( slotFind( ) ) ); | 177 | this, SLOT( slotFind( ) ) ); |
178 | 178 | ||
179 | a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); | 179 | a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); |
180 | connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | 180 | connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); |
181 | a->addTo( searchBar ); | 181 | a->addTo( searchBar ); |
182 | 182 | ||
183 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 183 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
184 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); | 184 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); |
185 | a->addTo( searchBar ); | 185 | a->addTo( searchBar ); |
186 | 186 | ||
187 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), | 187 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), |
188 | QString::null, 0, this, 0 ); | 188 | QString::null, 0, this, 0 ); |
189 | //a->setEnabled( FALSE ); we got support for it now :) zecke | 189 | //a->setEnabled( FALSE ); we got support for it now :) zecke |
190 | actionMail = a; | 190 | actionMail = a; |
191 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); | 191 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); |
192 | a->addTo( edit ); | 192 | a->addTo( edit ); |
193 | a->addTo( listTools ); | 193 | a->addTo( listTools ); |
194 | 194 | ||
195 | if ( Ir::supported() ) { | 195 | if ( Ir::supported() ) { |
196 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, | 196 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, |
197 | 0, this, 0 ); | 197 | 0, this, 0 ); |
198 | actionBeam = a; | 198 | actionBeam = a; |
199 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | 199 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); |
200 | a->addTo( edit ); | 200 | a->addTo( edit ); |
201 | a->addTo( listTools ); | 201 | a->addTo( listTools ); |
202 | } | 202 | } |
203 | 203 | ||
204 | edit->insertSeparator(); | 204 | edit->insertSeparator(); |
205 | 205 | ||
206 | a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, | 206 | a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, |
207 | 0, this, 0); | 207 | 0, this, 0); |
208 | actionPersonal = a; | 208 | actionPersonal = a; |
209 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); | 209 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); |
210 | a->addTo( edit ); | 210 | a->addTo( edit ); |
211 | 211 | ||
212 | a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, | 212 | a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, |
213 | 0, this, 0); | 213 | 0, this, 0); |
214 | actionPersonal = a; | 214 | actionPersonal = a; |
215 | connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); | 215 | connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); |
216 | a->addTo( edit ); | 216 | a->addTo( edit ); |
217 | 217 | ||
218 | edit->insertSeparator(); | 218 | edit->insertSeparator(); |
219 | 219 | ||
220 | a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), | 220 | a = new QAction( tr("My Personal Details"), Resource::loadPixmap( "addressbook/identity" ), |
221 | QString::null, 0, this, 0 , TRUE ); | 221 | QString::null, 0, this, 0 , TRUE ); |
222 | actionPersonal = a; | 222 | actionPersonal = a; |
223 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); | 223 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); |
224 | a->addTo( edit ); | 224 | a->addTo( edit ); |
225 | 225 | ||
226 | 226 | ||
227 | #ifdef __DEBUG_RELEASE | 227 | #ifdef __DEBUG_RELEASE |
228 | // Remove this function for public Release ! This is only | 228 | // Remove this function for public Release ! This is only |
229 | // for debug purposes .. | 229 | // for debug purposes .. |
230 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); | 230 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); |
231 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); | 231 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); |
232 | a->addTo( edit ); | 232 | a->addTo( edit ); |
233 | #endif | 233 | #endif |
234 | a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, | 234 | a = new QAction( tr( "Config" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, |
235 | 0, this, 0 ); | 235 | 0, this, 0 ); |
236 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); | 236 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); |
237 | a->addTo( edit ); | 237 | a->addTo( edit ); |
238 | 238 | ||
239 | // Create Views | 239 | // Create Views |
240 | listContainer = new QWidget( this ); | 240 | listContainer = new QWidget( this ); |
241 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); | 241 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); |
242 | 242 | ||
243 | m_abView = new AbView( listContainer, m_config.orderList() ); | 243 | m_abView = new AbView( listContainer, m_config.orderList() ); |
244 | vb->addWidget( m_abView ); | 244 | vb->addWidget( m_abView ); |
245 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); | 245 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); |
246 | connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), | 246 | connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), |
247 | this, SLOT( slotViewSwitched( int ) ) ); | 247 | this, SLOT( slotViewSwitched( int ) ) ); |
248 | 248 | ||
249 | 249 | ||
250 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); | 250 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); |
251 | 251 | ||
252 | m_abView->load(); | 252 | m_abView->load(); |
253 | 253 | ||
254 | // Letter Picker | 254 | // Letter Picker |
255 | pLabel = new LetterPicker( listContainer ); | 255 | pLabel = new LetterPicker( listContainer ); |
256 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); | 256 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); |
257 | connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); | 257 | connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); |
258 | 258 | ||
259 | vb->addWidget( pLabel ); | 259 | vb->addWidget( pLabel ); |
260 | 260 | ||
261 | // All Categories into view-menu.. | 261 | // All Categories into view-menu.. |
262 | populateCategories(); | 262 | populateCategories(); |
263 | 263 | ||
264 | // Fontsize | 264 | // Fontsize |
265 | defaultFont = new QFont( m_abView->font() ); | 265 | defaultFont = new QFont( m_abView->font() ); |
266 | slotSetFont(m_config.fontSize()); | 266 | slotSetFont(m_config.fontSize()); |
267 | m_curFontSize = m_config.fontSize(); | 267 | m_curFontSize = m_config.fontSize(); |
268 | 268 | ||
269 | setCentralWidget(listContainer); | 269 | setCentralWidget(listContainer); |
270 | 270 | ||
271 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); | 271 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); |
272 | 272 | ||
273 | 273 | ||
274 | isLoading = false; | 274 | isLoading = false; |
275 | } | 275 | } |
276 | 276 | ||
277 | 277 | ||
278 | void AddressbookWindow::slotConfig() | 278 | void AddressbookWindow::slotConfig() |
279 | { | 279 | { |
280 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); | 280 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); |
281 | dlg -> setConfig( m_config ); | 281 | dlg -> setConfig( m_config ); |
282 | dlg -> showMaximized(); | 282 | dlg -> showMaximized(); |
283 | if ( dlg -> exec() ) { | 283 | if ( dlg -> exec() ) { |
284 | qWarning ("Config Dialog accepted!"); | 284 | qWarning ("Config Dialog accepted!"); |
285 | m_config = dlg -> getConfig(); | 285 | m_config = dlg -> getConfig(); |
286 | if ( m_curFontSize != m_config.fontSize() ){ | 286 | if ( m_curFontSize != m_config.fontSize() ){ |
287 | qWarning("Font was changed!"); | 287 | qWarning("Font was changed!"); |
288 | m_curFontSize = m_config.fontSize(); | 288 | m_curFontSize = m_config.fontSize(); |
289 | emit slotSetFont( m_curFontSize ); | 289 | emit slotSetFont( m_curFontSize ); |
290 | } | 290 | } |
291 | m_abView -> setListOrder( m_config.orderList() ); | 291 | m_abView -> setListOrder( m_config.orderList() ); |
292 | } | 292 | } |
293 | 293 | ||
294 | delete dlg; | 294 | delete dlg; |
295 | } | 295 | } |
296 | 296 | ||
297 | 297 | ||
298 | void AddressbookWindow::slotSetFont( int size ) | 298 | void AddressbookWindow::slotSetFont( int size ) |
299 | { | 299 | { |
300 | qWarning("void AddressbookWindow::slotSetFont( %d )", size); | 300 | qWarning("void AddressbookWindow::slotSetFont( %d )", size); |
301 | 301 | ||
302 | if (size > 2 || size < 0) | 302 | if (size > 2 || size < 0) |
303 | size = 1; | 303 | size = 1; |
304 | 304 | ||
305 | m_config.setFontSize( size ); | 305 | m_config.setFontSize( size ); |
306 | 306 | ||
307 | QFont *currentFont; | 307 | QFont *currentFont; |
308 | 308 | ||
309 | switch (size) { | 309 | switch (size) { |
310 | case 0: | 310 | case 0: |
311 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); | 311 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); |
312 | currentFont = new QFont (m_abView->font()); | 312 | currentFont = new QFont (m_abView->font()); |
313 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX | 313 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX |
314 | // abList->resizeRows(); | 314 | // abList->resizeRows(); |
315 | break; | 315 | break; |
316 | case 1: | 316 | case 1: |
317 | m_abView->setFont( *defaultFont ); | 317 | m_abView->setFont( *defaultFont ); |
318 | currentFont = new QFont (m_abView->font()); | 318 | currentFont = new QFont (m_abView->font()); |
319 | // // abList->resizeRows(currentFont->pixelSize() + 7); | 319 | // // abList->resizeRows(currentFont->pixelSize() + 7); |
320 | // abList->resizeRows(); | 320 | // abList->resizeRows(); |
321 | break; | 321 | break; |
322 | case 2: | 322 | case 2: |
323 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); | 323 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); |
324 | currentFont = new QFont (m_abView->font()); | 324 | currentFont = new QFont (m_abView->font()); |
325 | // //abList->resizeRows(currentFont->pixelSize() + 7); | 325 | // //abList->resizeRows(currentFont->pixelSize() + 7); |
326 | // abList->resizeRows(); | 326 | // abList->resizeRows(); |
327 | break; | 327 | break; |
328 | } | 328 | } |
329 | } | 329 | } |
330 | 330 | ||
331 | 331 | ||
332 | 332 | ||
333 | void AddressbookWindow::importvCard() { | 333 | void AddressbookWindow::importvCard() { |
334 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); | 334 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); |
335 | if(!str.isEmpty() ){ | 335 | if(!str.isEmpty() ){ |
336 | setDocument((const QString&) str ); | 336 | setDocument((const QString&) str ); |
337 | } | 337 | } |
338 | 338 | ||
339 | } | 339 | } |
340 | void AddressbookWindow::exportvCard() | 340 | void AddressbookWindow::exportvCard() |
341 | { | 341 | { |
342 | qWarning(" void AddressbookWindow::exportvCard()"); | 342 | qWarning(" void AddressbookWindow::exportvCard()"); |
343 | QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); | 343 | QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); |
344 | if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ | 344 | if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ |
345 | qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 ); | 345 | qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 ); |
346 | OContact curCont = m_abView->currentEntry(); | 346 | OContact curCont = m_abView->currentEntry(); |
347 | if ( !curCont.isEmpty() ){ | 347 | if ( !curCont.isEmpty() ){ |
348 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 348 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
349 | filename ); | 349 | filename ); |
350 | OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); | 350 | OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); |
351 | if ( access ){ | 351 | if ( access ){ |
352 | access->add( curCont ); | 352 | access->add( curCont ); |
353 | access->save(); | 353 | access->save(); |
354 | } | 354 | } |
355 | delete access; | 355 | delete access; |
356 | }else | 356 | }else |
357 | QMessageBox::critical( 0, "Export VCard", | 357 | QMessageBox::critical( 0, "Export VCard", |
358 | QString( tr( "You have to select a contact !") ) ); | 358 | QString( tr( "You have to select a contact !") ) ); |
359 | 359 | ||
360 | }else | 360 | }else |
361 | QMessageBox::critical( 0, "Export VCard", | 361 | QMessageBox::critical( 0, "Export VCard", |
362 | QString( tr( "You have to set a filename !") ) ); | 362 | QString( tr( "You have to set a filename !") ) ); |
363 | } | 363 | } |
364 | 364 | ||
365 | void AddressbookWindow::setDocument( const QString &filename ) | 365 | void AddressbookWindow::setDocument( const QString &filename ) |
366 | { | 366 | { |
367 | qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); | 367 | qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); |
368 | 368 | ||
369 | if ( filename.find(".vcf") != int(filename.length()) - 4 ){ | 369 | if ( filename.find(".vcf") != int(filename.length()) - 4 ){ |
370 | 370 | ||
371 | 371 | ||
372 | 372 | ||
373 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), | 373 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), |
374 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), | 374 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), |
375 | tr( "&Yes" ), tr( "&No" ), QString::null, | 375 | tr( "&Yes" ), tr( "&No" ), QString::null, |
376 | 0, // Enter == button 0 | 376 | 0, // Enter == button 0 |
377 | 2 ) ) { // Escape == button 2 | 377 | 2 ) ) { // Escape == button 2 |
378 | case 0: | 378 | case 0: |
379 | qWarning("YES clicked"); | 379 | qWarning("YES clicked"); |
380 | break; | 380 | break; |
381 | case 1: | 381 | case 1: |
382 | qWarning("NO clicked"); | 382 | qWarning("NO clicked"); |
383 | return; | 383 | return; |
384 | break; | 384 | break; |
385 | } | 385 | } |
386 | } | 386 | } |
387 | 387 | ||
388 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 388 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
389 | filename ); | 389 | filename ); |
390 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 390 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
391 | OContactAccess::List allList = access->allRecords(); | 391 | OContactAccess::List allList = access->allRecords(); |
392 | qWarning( "Found number of contacts in File: %d", allList.count() ); | 392 | qWarning( "Found number of contacts in File: %d", allList.count() ); |
393 | 393 | ||
394 | if ( !allList.count() ) { | 394 | if ( !allList.count() ) { |
395 | QMessageBox::information( this, "Import VCard", | 395 | QMessageBox::information( this, "Import VCard", |
396 | "It was impossible to import\nthe VCard.\n" | 396 | "It was impossible to import\nthe VCard.\n" |
397 | "The VCard may be corrupted!" ); | 397 | "The VCard may be corrupted!" ); |
398 | } | 398 | } |
399 | 399 | ||
400 | bool doAsk = true; | 400 | bool doAsk = true; |
401 | OContactAccess::List::Iterator it; | 401 | OContactAccess::List::Iterator it; |
402 | for ( it = allList.begin(); it != allList.end(); ++it ){ | 402 | for ( it = allList.begin(); it != allList.end(); ++it ){ |
403 | qWarning("Adding Contact from: %s", (*it).fullName().latin1() ); | 403 | qWarning("Adding Contact from: %s", (*it).fullName().latin1() ); |
404 | if ( doAsk ){ | 404 | if ( doAsk ){ |
405 | switch( QMessageBox::information( this, tr ( "Add Contact?" ), | 405 | switch( QMessageBox::information( this, tr ( "Add Contact?" ), |
406 | tr( "Do you really want add contact for \n%1?" ) | 406 | tr( "Do you really want add contact for \n%1?" ) |
407 | .arg( (*it).fullName().latin1() ), | 407 | .arg( (*it).fullName().latin1() ), |
408 | tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), | 408 | tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), |
409 | 0, // Enter == button 0 | 409 | 0, // Enter == button 0 |
410 | 2 ) ) { // Escape == button 2 | 410 | 2 ) ) { // Escape == button 2 |
411 | case 0: | 411 | case 0: |
412 | qWarning("YES clicked"); | 412 | qWarning("YES clicked"); |
413 | m_abView->addEntry( *it ); | 413 | m_abView->addEntry( *it ); |
414 | break; | 414 | break; |
415 | case 1: | 415 | case 1: |
416 | qWarning("NO clicked"); | 416 | qWarning("NO clicked"); |
417 | break; | 417 | break; |
418 | case 2: | 418 | case 2: |
419 | qWarning("YesAll clicked"); | 419 | qWarning("YesAll clicked"); |
420 | doAsk = false; | 420 | doAsk = false; |
421 | break; | 421 | break; |
422 | } | 422 | } |
423 | }else | 423 | }else |
424 | m_abView->addEntry( *it ); | 424 | m_abView->addEntry( *it ); |
425 | 425 | ||
426 | } | 426 | } |
427 | 427 | ||
428 | delete access; | 428 | delete access; |
429 | } | 429 | } |
430 | 430 | ||
431 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) | 431 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) |
432 | { | 432 | { |
433 | QMainWindow::resizeEvent( e ); | 433 | QMainWindow::resizeEvent( e ); |
434 | 434 | ||
435 | 435 | ||
436 | } | 436 | } |
437 | 437 | ||
438 | AddressbookWindow::~AddressbookWindow() | 438 | AddressbookWindow::~AddressbookWindow() |
439 | { | 439 | { |
440 | ToolBarDock dock; | 440 | ToolBarDock dock; |
441 | int dummy; | 441 | int dummy; |
442 | bool bDummy; | 442 | bool bDummy; |
443 | getLocation ( listTools, dock, dummy, bDummy, dummy ); | 443 | getLocation ( listTools, dock, dummy, bDummy, dummy ); |
444 | m_config.setToolBarDock( dock ); | 444 | m_config.setToolBarDock( dock ); |
445 | m_config.save(); | 445 | m_config.save(); |
446 | } | 446 | } |
447 | 447 | ||
448 | void AddressbookWindow::slotUpdateToolbar() | 448 | void AddressbookWindow::slotUpdateToolbar() |
449 | { | 449 | { |
450 | OContact ce = m_abView->currentEntry(); | 450 | OContact ce = m_abView->currentEntry(); |
451 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); | 451 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); |
452 | } | 452 | } |
453 | 453 | ||
454 | void AddressbookWindow::slotListNew() | 454 | void AddressbookWindow::slotListNew() |
455 | { | 455 | { |
456 | OContact cnt; | 456 | OContact cnt; |
457 | if( !syncing ) { | 457 | if( !syncing ) { |
458 | editEntry( NewEntry ); | 458 | editEntry( NewEntry ); |
459 | } else { | 459 | } else { |
460 | QMessageBox::warning(this, tr("Contacts"), | 460 | QMessageBox::warning(this, tr("Contacts"), |
461 | tr("Can not edit data, currently syncing")); | 461 | tr("Can not edit data, currently syncing")); |
462 | } | 462 | } |
463 | } | 463 | } |
464 | 464 | ||
465 | // void AddressbookWindow::slotListView() | 465 | // void AddressbookWindow::slotListView() |
466 | // { | 466 | // { |
467 | // m_abView -> init( abList->currentEntry() ); | 467 | // m_abView -> init( abList->currentEntry() ); |
468 | // // :SX mView->sync(); | 468 | // // :SX mView->sync(); |
469 | // //:SXshowView(); | 469 | // //:SXshowView(); |
470 | // } | 470 | // } |
471 | 471 | ||
472 | void AddressbookWindow::slotListDelete() | 472 | void AddressbookWindow::slotListDelete() |
473 | { | 473 | { |
474 | if(!syncing) { | 474 | if(!syncing) { |
475 | OContact tmpEntry = m_abView ->currentEntry(); | 475 | OContact tmpEntry = m_abView ->currentEntry(); |
476 | 476 | ||
477 | // get a name, do the best we can... | 477 | // get a name, do the best we can... |
478 | QString strName = tmpEntry.fullName(); | 478 | QString strName = tmpEntry.fullName(); |
479 | if ( strName.isEmpty() ) { | 479 | if ( strName.isEmpty() ) { |
480 | strName = tmpEntry.company(); | 480 | strName = tmpEntry.company(); |
481 | if ( strName.isEmpty() ) | 481 | if ( strName.isEmpty() ) |
482 | strName = "No Name"; | 482 | strName = "No Name"; |
483 | } | 483 | } |
484 | 484 | ||
485 | 485 | ||
486 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), | 486 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), |
487 | strName ) ) { | 487 | strName ) ) { |
488 | m_abView->removeEntry( tmpEntry.uid() ); | 488 | m_abView->removeEntry( tmpEntry.uid() ); |
489 | } | 489 | } |
490 | } else { | 490 | } else { |
491 | QMessageBox::warning( this, tr("Contacts"), | 491 | QMessageBox::warning( this, tr("Contacts"), |
492 | tr("Can not edit data, currently syncing") ); | 492 | tr("Can not edit data, currently syncing") ); |
493 | } | 493 | } |
494 | } | 494 | } |
495 | 495 | ||
496 | void AddressbookWindow::slotFindOpen() | 496 | void AddressbookWindow::slotFindOpen() |
497 | { | 497 | { |
498 | searchBar->show(); | 498 | searchBar->show(); |
499 | m_abView -> inSearch(); | 499 | m_abView -> inSearch(); |
500 | searchEdit->setFocus(); | 500 | searchEdit->setFocus(); |
501 | } | 501 | } |
502 | void AddressbookWindow::slotFindClose() | 502 | void AddressbookWindow::slotFindClose() |
503 | { | 503 | { |
504 | searchBar->hide(); | 504 | searchBar->hide(); |
505 | m_abView -> offSearch(); | 505 | m_abView -> offSearch(); |
506 | // m_abView->setFocus(); | 506 | // m_abView->setFocus(); |
507 | } | 507 | } |
508 | 508 | ||
509 | 509 | ||
510 | void AddressbookWindow::slotFind() | 510 | void AddressbookWindow::slotFind() |
511 | { | 511 | { |
512 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); | 512 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); |
513 | 513 | ||
514 | searchEdit->clearFocus(); | 514 | searchEdit->clearFocus(); |
515 | // m_abView->setFocus(); | 515 | // m_abView->setFocus(); |
516 | 516 | ||
517 | } | 517 | } |
518 | 518 | ||
519 | void AddressbookWindow::slotViewBack() | 519 | void AddressbookWindow::slotViewBack() |
520 | { | 520 | { |
521 | // :SX showList(); | 521 | // :SX showList(); |
522 | } | 522 | } |
523 | 523 | ||
524 | void AddressbookWindow::slotViewEdit() | 524 | void AddressbookWindow::slotViewEdit() |
525 | { | 525 | { |
526 | if(!syncing) { | 526 | if(!syncing) { |
527 | if (actionPersonal->isOn()) { | 527 | if (actionPersonal->isOn()) { |
528 | editPersonal(); | 528 | editPersonal(); |
529 | } else { | 529 | } else { |
530 | editEntry( EditEntry ); | 530 | editEntry( EditEntry ); |
531 | } | 531 | } |
532 | } else { | 532 | } else { |
533 | QMessageBox::warning( this, tr("Contacts"), | 533 | QMessageBox::warning( this, tr("Contacts"), |
534 | tr("Can not edit data, currently syncing") ); | 534 | tr("Can not edit data, currently syncing") ); |
535 | } | 535 | } |
536 | } | 536 | } |
537 | 537 | ||
538 | 538 | ||
539 | 539 | ||
540 | void AddressbookWindow::writeMail() | 540 | void AddressbookWindow::writeMail() |
541 | { | 541 | { |
542 | OContact c = m_abView -> currentEntry(); | 542 | OContact c = m_abView -> currentEntry(); |
543 | QString name = c.fileAs(); | 543 | QString name = c.fileAs(); |
544 | QString email = c.defaultEmail(); | 544 | QString email = c.defaultEmail(); |
545 | 545 | ||
546 | // I prefer the OPIE-Environment variable before the | 546 | // I prefer the OPIE-Environment variable before the |
547 | // QPE-one.. | 547 | // QPE-one.. |
548 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); | 548 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); |
549 | if ( basepath.isEmpty() ) | 549 | if ( basepath.isEmpty() ) |
550 | basepath = QString::fromLatin1( getenv("QPEDIR") ); | 550 | basepath = QString::fromLatin1( getenv("QPEDIR") ); |
551 | 551 | ||
552 | // Try to access the preferred. If not possible, try to | 552 | // Try to access the preferred. If not possible, try to |
553 | // switch to the other one.. | 553 | // switch to the other one.. |
554 | if ( m_config.useQtMail() ){ | 554 | if ( m_config.useQtMail() ){ |
555 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); | 555 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); |
556 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ | 556 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ |
557 | qWarning ("QCop"); | 557 | qWarning ("QCop"); |
558 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); | 558 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); |
559 | e << name << email; | 559 | e << name << email; |
560 | return; | 560 | return; |
561 | } else | 561 | } else |
562 | m_config.setUseOpieMail( true ); | 562 | m_config.setUseOpieMail( true ); |
563 | } | 563 | } |
564 | if ( m_config.useOpieMail() ){ | 564 | if ( m_config.useOpieMail() ){ |
565 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); | 565 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); |
566 | if ( QFile::exists( basepath + "/bin/mail" ) ){ | 566 | if ( QFile::exists( basepath + "/bin/mail" ) ){ |
567 | qWarning ("QCop"); | 567 | qWarning ("QCop"); |
568 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); | 568 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); |
569 | e << name << email; | 569 | e << name << email; |
570 | return; | 570 | return; |
571 | } else | 571 | } else |
572 | m_config.setUseQtMail( true ); | 572 | m_config.setUseQtMail( true ); |
573 | } | 573 | } |
574 | 574 | ||
575 | } | 575 | } |
576 | 576 | ||
577 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 577 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
578 | 578 | ||
579 | void AddressbookWindow::slotBeam() | 579 | void AddressbookWindow::slotBeam() |
580 | { | 580 | { |
581 | QString beamFilename; | 581 | QString beamFilename; |
582 | OContact c; | 582 | OContact c; |
583 | if ( actionPersonal->isOn() ) { | 583 | if ( actionPersonal->isOn() ) { |
584 | beamFilename = addressbookPersonalVCardName(); | 584 | beamFilename = addressbookPersonalVCardName(); |
585 | if ( !QFile::exists( beamFilename ) ) | 585 | if ( !QFile::exists( beamFilename ) ) |
586 | return; // can't beam a non-existent file | 586 | return; // can't beam a non-existent file |
587 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 587 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
588 | beamFilename ); | 588 | beamFilename ); |
589 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 589 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
590 | OContactAccess::List allList = access->allRecords(); | 590 | OContactAccess::List allList = access->allRecords(); |
591 | OContactAccess::List::Iterator it = allList.begin(); // Just take first | 591 | OContactAccess::List::Iterator it = allList.begin(); // Just take first |
592 | c = *it; | 592 | c = *it; |
593 | 593 | ||
594 | delete access; | 594 | delete access; |
595 | } else { | 595 | } else { |
596 | unlink( beamfile ); // delete if exists | 596 | unlink( beamfile ); // delete if exists |
597 | mkdir("/tmp/obex/", 0755); | 597 | mkdir("/tmp/obex/", 0755); |
598 | c = m_abView -> currentEntry(); | 598 | c = m_abView -> currentEntry(); |
599 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 599 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
600 | beamfile ); | 600 | beamfile ); |
601 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 601 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
602 | access->add( c ); | 602 | access->add( c ); |
603 | access->save(); | 603 | access->save(); |
604 | delete access; | 604 | delete access; |
605 | 605 | ||
606 | beamFilename = beamfile; | 606 | beamFilename = beamfile; |
607 | } | 607 | } |
608 | 608 | ||
609 | qWarning("Beaming: %s", beamFilename.latin1() ); | 609 | qWarning("Beaming: %s", beamFilename.latin1() ); |
610 | 610 | ||
611 | Ir *ir = new Ir( this ); | 611 | Ir *ir = new Ir( this ); |
612 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 612 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
613 | QString description = c.fullName(); | 613 | QString description = c.fullName(); |
614 | ir->send( beamFilename, description, "text/x-vCard" ); | 614 | ir->send( beamFilename, description, "text/x-vCard" ); |
615 | } | 615 | } |
616 | 616 | ||
617 | void AddressbookWindow::beamDone( Ir *ir ) | 617 | void AddressbookWindow::beamDone( Ir *ir ) |
618 | { | 618 | { |
619 | 619 | ||
620 | delete ir; | 620 | delete ir; |
621 | unlink( beamfile ); | 621 | unlink( beamfile ); |
622 | } | 622 | } |
623 | 623 | ||
624 | 624 | ||
625 | static void parseName( const QString& name, QString *first, QString *middle, | 625 | static void parseName( const QString& name, QString *first, QString *middle, |
626 | QString * last ) | 626 | QString * last ) |
627 | { | 627 | { |
628 | 628 | ||
629 | int comma = name.find ( "," ); | 629 | int comma = name.find ( "," ); |
630 | QString rest; | 630 | QString rest; |
631 | if ( comma > 0 ) { | 631 | if ( comma > 0 ) { |
632 | *last = name.left( comma ); | 632 | *last = name.left( comma ); |
633 | comma++; | 633 | comma++; |
634 | while ( comma < int(name.length()) && name[comma] == ' ' ) | 634 | while ( comma < int(name.length()) && name[comma] == ' ' ) |
635 | comma++; | 635 | comma++; |
636 | rest = name.mid( comma ); | 636 | rest = name.mid( comma ); |
637 | } else { | 637 | } else { |
638 | int space = name.findRev( ' ' ); | 638 | int space = name.findRev( ' ' ); |
639 | *last = name.mid( space+1 ); | 639 | *last = name.mid( space+1 ); |
640 | rest = name.left( space ); | 640 | rest = name.left( space ); |
641 | } | 641 | } |
642 | int space = rest.find( ' ' ); | 642 | int space = rest.find( ' ' ); |
643 | if ( space <= 0 ) { | 643 | if ( space <= 0 ) { |
644 | *first = rest; | 644 | *first = rest; |
645 | } else { | 645 | } else { |
646 | *first = rest.left( space ); | 646 | *first = rest.left( space ); |
647 | *middle = rest.mid( space+1 ); | 647 | *middle = rest.mid( space+1 ); |
648 | } | 648 | } |
649 | 649 | ||
650 | } | 650 | } |
651 | 651 | ||
652 | 652 | ||
653 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | 653 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) |
654 | { | 654 | { |
655 | qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() ); | 655 | qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() ); |
656 | 656 | ||
657 | if (msg == "editPersonal()") { | 657 | if (msg == "editPersonal()") { |
658 | editPersonal(); | 658 | editPersonal(); |
659 | } else if (msg == "editPersonalAndClose()") { | 659 | } else if (msg == "editPersonalAndClose()") { |
660 | editPersonal(); | 660 | editPersonal(); |
661 | close(); | 661 | close(); |
662 | } else if ( msg == "addContact(QString,QString)" ) { | 662 | } else if ( msg == "addContact(QString,QString)" ) { |
663 | QDataStream stream(data,IO_ReadOnly); | 663 | QDataStream stream(data,IO_ReadOnly); |
664 | QString name, email; | 664 | QString name, email; |
665 | stream >> name >> email; | 665 | stream >> name >> email; |
666 | 666 | ||
667 | OContact cnt; | 667 | OContact cnt; |
668 | QString fn, mn, ln; | 668 | QString fn, mn, ln; |
669 | parseName( name, &fn, &mn, &ln ); | 669 | parseName( name, &fn, &mn, &ln ); |
670 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); | 670 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); |
671 | cnt.setFirstName( fn ); | 671 | cnt.setFirstName( fn ); |
672 | cnt.setMiddleName( mn ); | 672 | cnt.setMiddleName( mn ); |
673 | cnt.setLastName( ln ); | 673 | cnt.setLastName( ln ); |
674 | cnt.insertEmails( email ); | 674 | cnt.insertEmails( email ); |
675 | cnt.setDefaultEmail( email ); | 675 | cnt.setDefaultEmail( email ); |
676 | cnt.setFileAs(); | 676 | cnt.setFileAs(); |
677 | 677 | ||
678 | m_abView -> addEntry( cnt ); | 678 | m_abView -> addEntry( cnt ); |
679 | 679 | ||
680 | // :SXm_abView()->init( cnt ); | 680 | // :SXm_abView()->init( cnt ); |
681 | editEntry( EditEntry ); | 681 | editEntry( EditEntry ); |
682 | } else if ( msg == "beamBusinessCard()" ) { | 682 | } else if ( msg == "beamBusinessCard()" ) { |
683 | QString beamFilename = addressbookPersonalVCardName(); | 683 | QString beamFilename = addressbookPersonalVCardName(); |
684 | if ( !QFile::exists( beamFilename ) ) | 684 | if ( !QFile::exists( beamFilename ) ) |
685 | return; // can't beam a non-existent file | 685 | return; // can't beam a non-existent file |
686 | 686 | ||
687 | Ir *ir = new Ir( this ); | 687 | Ir *ir = new Ir( this ); |
688 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 688 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
689 | QString description = "mycard.vcf"; | 689 | QString description = "mycard.vcf"; |
690 | ir->send( beamFilename, description, "text/x-vCard" ); | 690 | ir->send( beamFilename, description, "text/x-vCard" ); |
691 | } else if ( msg == "show(int)" ) { | 691 | } else if ( msg == "show(int)" ) { |
692 | QDataStream stream(data,IO_ReadOnly); | 692 | QDataStream stream(data,IO_ReadOnly); |
693 | int uid; | 693 | int uid; |
694 | stream >> uid; | 694 | stream >> uid; |
695 | 695 | ||
696 | qWarning( "Showing uid: %d" , uid ); | 696 | qWarning( "Showing uid: %d" , uid ); |
697 | 697 | ||
698 | // Deactivate Personal View.. | 698 | // Deactivate Personal View.. |
699 | if ( actionPersonal->isOn() ){ | 699 | if ( actionPersonal->isOn() ){ |
700 | actionPersonal->setOn( false ); | 700 | actionPersonal->setOn( false ); |
701 | slotPersonalView(); | 701 | slotPersonalView(); |
702 | } | 702 | } |
703 | 703 | ||
704 | // Reset category and show as card.. | 704 | // Reset category and show as card.. |
705 | m_abView -> setShowByCategory( QString::null ); | 705 | m_abView -> setShowByCategory( QString::null ); |
706 | m_abView -> setCurrentUid( uid ); | 706 | m_abView -> setCurrentUid( uid ); |
707 | slotViewSwitched ( AbView::CardView ); | 707 | slotViewSwitched ( AbView::CardView ); |
708 | 708 | ||
709 | showMaximized(); | ||
709 | qApp->exec(); | 710 | qApp->exec(); |
710 | 711 | ||
711 | } else if ( msg == "edit(int)" ) { | 712 | } else if ( msg == "edit(int)" ) { |
712 | QDataStream stream(data,IO_ReadOnly); | 713 | QDataStream stream(data,IO_ReadOnly); |
713 | int uid; | 714 | int uid; |
714 | stream >> uid; | 715 | stream >> uid; |
715 | 716 | ||
716 | // Deactivate Personal View.. | 717 | // Deactivate Personal View.. |
717 | if ( actionPersonal->isOn() ){ | 718 | if ( actionPersonal->isOn() ){ |
718 | actionPersonal->setOn( false ); | 719 | actionPersonal->setOn( false ); |
719 | slotPersonalView(); | 720 | slotPersonalView(); |
720 | } | 721 | } |
721 | 722 | ||
722 | // Reset category and edit.. | 723 | // Reset category and edit.. |
723 | m_abView -> setShowByCategory( QString::null ); | 724 | m_abView -> setShowByCategory( QString::null ); |
724 | m_abView -> setCurrentUid( uid ); | 725 | m_abView -> setCurrentUid( uid ); |
725 | slotViewEdit(); | 726 | slotViewEdit(); |
726 | } | 727 | } |
727 | 728 | ||
728 | } | 729 | } |
729 | 730 | ||
730 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 731 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
731 | { | 732 | { |
732 | OContact entry; | 733 | OContact entry; |
733 | if ( !abEditor ) { | 734 | if ( !abEditor ) { |
734 | abEditor = new ContactEditor( entry, this, "editor" ); | 735 | abEditor = new ContactEditor( entry, this, "editor" ); |
735 | } | 736 | } |
736 | if ( entryMode == EditEntry ) | 737 | if ( entryMode == EditEntry ) |
737 | abEditor->setEntry( m_abView -> currentEntry() ); | 738 | abEditor->setEntry( m_abView -> currentEntry() ); |
738 | else if ( entryMode == NewEntry ) | 739 | else if ( entryMode == NewEntry ) |
739 | abEditor->setEntry( entry ); | 740 | abEditor->setEntry( entry ); |
740 | // other things may change the caption. | 741 | // other things may change the caption. |
741 | abEditor->setCaption( tr("Edit Address") ); | 742 | abEditor->setCaption( tr("Edit Address") ); |
742 | 743 | ||
743 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 744 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
744 | abEditor->showMaximized(); | 745 | abEditor->showMaximized(); |
745 | #endif | 746 | #endif |
746 | // fix the foxus... | 747 | // fix the foxus... |
747 | abEditor->setNameFocus(); | 748 | abEditor->setNameFocus(); |
748 | if ( abEditor->exec() ) { | 749 | if ( abEditor->exec() ) { |
749 | setFocus(); | 750 | setFocus(); |
750 | if ( entryMode == NewEntry ) { | 751 | if ( entryMode == NewEntry ) { |
751 | OContact insertEntry = abEditor->entry(); | 752 | OContact insertEntry = abEditor->entry(); |
752 | insertEntry.assignUid(); | 753 | insertEntry.assignUid(); |
753 | m_abView -> addEntry( insertEntry ); | 754 | m_abView -> addEntry( insertEntry ); |
754 | } else { | 755 | } else { |
755 | OContact replEntry = abEditor->entry(); | 756 | OContact replEntry = abEditor->entry(); |
756 | 757 | ||
757 | if ( !replEntry.isValidUid() ) | 758 | if ( !replEntry.isValidUid() ) |
758 | replEntry.assignUid(); | 759 | replEntry.assignUid(); |
759 | 760 | ||
760 | m_abView -> replaceEntry( replEntry ); | 761 | m_abView -> replaceEntry( replEntry ); |
761 | } | 762 | } |
762 | } | 763 | } |
763 | // populateCategories(); | 764 | // populateCategories(); |
764 | 765 | ||
765 | } | 766 | } |
766 | 767 | ||
767 | void AddressbookWindow::editPersonal() | 768 | void AddressbookWindow::editPersonal() |
768 | { | 769 | { |
769 | OContact entry; | 770 | OContact entry; |
770 | 771 | ||
771 | // Switch to personal view if not selected | 772 | // Switch to personal view if not selected |
772 | // but take care of the menu, too | 773 | // but take care of the menu, too |
773 | if ( ! actionPersonal->isOn() ){ | 774 | if ( ! actionPersonal->isOn() ){ |
774 | qWarning("*** ++++"); | 775 | qWarning("*** ++++"); |
775 | actionPersonal->setOn( true ); | 776 | actionPersonal->setOn( true ); |
776 | slotPersonalView(); | 777 | slotPersonalView(); |
777 | } | 778 | } |
778 | 779 | ||
779 | if ( !abEditor ) { | 780 | if ( !abEditor ) { |
780 | abEditor = new ContactEditor( entry, this, "editor" ); | 781 | abEditor = new ContactEditor( entry, this, "editor" ); |
781 | } | 782 | } |
782 | 783 | ||
783 | abEditor->setCaption(tr("Edit My Personal Details")); | 784 | abEditor->setCaption(tr("Edit My Personal Details")); |
784 | abEditor->setPersonalView( true ); | 785 | abEditor->setPersonalView( true ); |
785 | editEntry( EditEntry ); | 786 | editEntry( EditEntry ); |
786 | abEditor->setPersonalView( false ); | 787 | abEditor->setPersonalView( false ); |
787 | 788 | ||
788 | } | 789 | } |
789 | 790 | ||
790 | 791 | ||
791 | void AddressbookWindow::slotPersonalView() | 792 | void AddressbookWindow::slotPersonalView() |
792 | { | 793 | { |
793 | qWarning("slotPersonalView()"); | 794 | qWarning("slotPersonalView()"); |
794 | if (!actionPersonal->isOn()) { | 795 | if (!actionPersonal->isOn()) { |
795 | // we just turned it off | 796 | // we just turned it off |
796 | qWarning("slotPersonalView()-> OFF"); | 797 | qWarning("slotPersonalView()-> OFF"); |
797 | setCaption( tr("Contacts") ); | 798 | setCaption( tr("Contacts") ); |
798 | actionNew->setEnabled(TRUE); | 799 | actionNew->setEnabled(TRUE); |
799 | actionTrash->setEnabled(TRUE); | 800 | actionTrash->setEnabled(TRUE); |
800 | actionFind->setEnabled(TRUE); | 801 | actionFind->setEnabled(TRUE); |
801 | actionMail->setEnabled(TRUE); | 802 | actionMail->setEnabled(TRUE); |
802 | // slotUpdateToolbar(); | 803 | // slotUpdateToolbar(); |
803 | 804 | ||
804 | m_abView->showPersonal( false ); | 805 | m_abView->showPersonal( false ); |
805 | 806 | ||
806 | return; | 807 | return; |
807 | } | 808 | } |
808 | 809 | ||
809 | qWarning("slotPersonalView()-> ON"); | 810 | qWarning("slotPersonalView()-> ON"); |
810 | // XXX need to disable some QActions. | 811 | // XXX need to disable some QActions. |
811 | actionNew->setEnabled(FALSE); | 812 | actionNew->setEnabled(FALSE); |
812 | actionTrash->setEnabled(FALSE); | 813 | actionTrash->setEnabled(FALSE); |
813 | actionFind->setEnabled(FALSE); | 814 | actionFind->setEnabled(FALSE); |
814 | actionMail->setEnabled(FALSE); | 815 | actionMail->setEnabled(FALSE); |
815 | 816 | ||
816 | setCaption( tr("Contacts - My Personal Details") ); | 817 | setCaption( tr("Contacts - My Personal Details") ); |
817 | 818 | ||
818 | m_abView->showPersonal( true ); | 819 | m_abView->showPersonal( true ); |
819 | 820 | ||
820 | } | 821 | } |
821 | 822 | ||
822 | 823 | ||
823 | void AddressbookWindow::listIsEmpty( bool empty ) | 824 | void AddressbookWindow::listIsEmpty( bool empty ) |
824 | { | 825 | { |
825 | if ( !empty ) { | 826 | if ( !empty ) { |
826 | deleteButton->setEnabled( TRUE ); | 827 | deleteButton->setEnabled( TRUE ); |
827 | } | 828 | } |
828 | } | 829 | } |
829 | 830 | ||
830 | void AddressbookWindow::reload() | 831 | void AddressbookWindow::reload() |
831 | { | 832 | { |
832 | syncing = FALSE; | 833 | syncing = FALSE; |
833 | m_abView->clear(); | 834 | m_abView->clear(); |
834 | m_abView->reload(); | 835 | m_abView->reload(); |
835 | } | 836 | } |
836 | 837 | ||
837 | void AddressbookWindow::flush() | 838 | void AddressbookWindow::flush() |
838 | { | 839 | { |
839 | syncing = TRUE; | 840 | syncing = TRUE; |
840 | m_abView->save(); | 841 | m_abView->save(); |
841 | } | 842 | } |
842 | 843 | ||
843 | 844 | ||
844 | void AddressbookWindow::closeEvent( QCloseEvent *e ) | 845 | void AddressbookWindow::closeEvent( QCloseEvent *e ) |
845 | { | 846 | { |
846 | if(active_view == AbView::CardView){ | 847 | if(active_view == AbView::CardView){ |
847 | slotViewSwitched( AbView::TableView ); | 848 | slotViewSwitched( AbView::TableView ); |
848 | e->ignore(); | 849 | e->ignore(); |
849 | return; | 850 | return; |
850 | } | 851 | } |
851 | if(syncing) { | 852 | if(syncing) { |
852 | /* shouldn't we save, I hear you say? well its already been set | 853 | /* shouldn't we save, I hear you say? well its already been set |
853 | so that an edit can not occur during a sync, and we flushed | 854 | so that an edit can not occur during a sync, and we flushed |
854 | at the start of the sync, so there is no need to save | 855 | at the start of the sync, so there is no need to save |
855 | Saving however itself would cause problems. */ | 856 | Saving however itself would cause problems. */ |
856 | e->accept(); | 857 | e->accept(); |
857 | return; | 858 | return; |
858 | } | 859 | } |
859 | //################## shouldn't always save | 860 | //################## shouldn't always save |
860 | // True, but the database handles this automatically ! (se) | 861 | // True, but the database handles this automatically ! (se) |
861 | if ( save() ) | 862 | if ( save() ) |
862 | e->accept(); | 863 | e->accept(); |
863 | else | 864 | else |
864 | e->ignore(); | 865 | e->ignore(); |
865 | } | 866 | } |
866 | 867 | ||
867 | /* | 868 | /* |
868 | Returns TRUE if it is OK to exit | 869 | Returns TRUE if it is OK to exit |
869 | */ | 870 | */ |
870 | 871 | ||
871 | bool AddressbookWindow::save() | 872 | bool AddressbookWindow::save() |
872 | { | 873 | { |
873 | if ( !m_abView->save() ) { | 874 | if ( !m_abView->save() ) { |
874 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | 875 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
875 | tr("Unable to save information.\n" | 876 | tr("Unable to save information.\n" |
876 | "Free up some space\n" | 877 | "Free up some space\n" |
877 | "and try again.\n" | 878 | "and try again.\n" |
878 | "\nQuit anyway?"), | 879 | "\nQuit anyway?"), |
879 | QMessageBox::Yes|QMessageBox::Escape, | 880 | QMessageBox::Yes|QMessageBox::Escape, |
880 | QMessageBox::No|QMessageBox::Default ) | 881 | QMessageBox::No|QMessageBox::Default ) |
881 | != QMessageBox::No ) | 882 | != QMessageBox::No ) |
882 | return TRUE; | 883 | return TRUE; |
883 | else | 884 | else |
884 | return FALSE; | 885 | return FALSE; |
885 | } | 886 | } |
886 | return TRUE; | 887 | return TRUE; |
887 | } | 888 | } |
888 | 889 | ||
889 | #ifdef __DEBUG_RELEASE | 890 | #ifdef __DEBUG_RELEASE |
890 | void AddressbookWindow::slotSave() | 891 | void AddressbookWindow::slotSave() |
891 | { | 892 | { |
892 | save(); | 893 | save(); |
893 | } | 894 | } |
894 | #endif | 895 | #endif |
895 | 896 | ||
896 | 897 | ||
897 | void AddressbookWindow::slotNotFound() | 898 | void AddressbookWindow::slotNotFound() |
898 | { | 899 | { |
899 | qWarning("Got notfound signal!"); | 900 | qWarning("Got notfound signal!"); |
900 | QMessageBox::information( this, tr( "Not Found" ), | 901 | QMessageBox::information( this, tr( "Not Found" ), |
901 | tr( "Unable to find a contact for this \n search pattern!" ) ); | 902 | tr( "Unable to find a contact for this \n search pattern!" ) ); |
902 | 903 | ||
903 | 904 | ||
904 | } | 905 | } |
905 | void AddressbookWindow::slotWrapAround() | 906 | void AddressbookWindow::slotWrapAround() |
906 | { | 907 | { |
907 | qWarning("Got wrap signal!"); | 908 | qWarning("Got wrap signal!"); |
908 | // if ( doNotifyWrapAround ) | 909 | // if ( doNotifyWrapAround ) |
909 | // QMessageBox::information( this, tr( "End of list" ), | 910 | // QMessageBox::information( this, tr( "End of list" ), |
910 | // tr( "End of list. Wrap around now...!" ) + "\n" ); | 911 | // tr( "End of list. Wrap around now...!" ) + "\n" ); |
911 | 912 | ||
912 | } | 913 | } |
913 | 914 | ||
914 | void AddressbookWindow::slotSetCategory( int c ) | 915 | void AddressbookWindow::slotSetCategory( int c ) |
915 | { | 916 | { |
916 | qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); | 917 | qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); |
917 | 918 | ||
918 | QString cat, book; | 919 | QString cat, book; |
919 | AbView::Views view = AbView::TableView; | 920 | AbView::Views view = AbView::TableView; |
920 | 921 | ||
921 | if ( c <= 0 ) | 922 | if ( c <= 0 ) |
922 | return; | 923 | return; |
923 | 924 | ||
924 | // Switch view | 925 | // Switch view |
925 | if ( c < 3 ) | 926 | if ( c < 3 ) |
926 | for ( unsigned int i = 1; i < 3; i++ ){ | 927 | for ( unsigned int i = 1; i < 3; i++ ){ |
927 | if ( catMenu ) | 928 | if ( catMenu ) |
928 | catMenu->setItemChecked( i, c == (int)i ); | 929 | catMenu->setItemChecked( i, c == (int)i ); |
929 | } | 930 | } |
930 | else | 931 | else |
931 | // Checkmark Category Menu Item Selected | 932 | // Checkmark Category Menu Item Selected |
932 | for ( unsigned int i = 3; i < catMenu->count(); i++ ) | 933 | for ( unsigned int i = 3; i < catMenu->count(); i++ ) |
933 | catMenu->setItemChecked( i, c == (int)i ); | 934 | catMenu->setItemChecked( i, c == (int)i ); |
934 | 935 | ||
935 | // Now switch to the selected category | 936 | // Now switch to the selected category |
936 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { | 937 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { |
937 | if (catMenu->isItemChecked( i )) { | 938 | if (catMenu->isItemChecked( i )) { |
938 | if ( i == 1 ){ // default List view | 939 | if ( i == 1 ){ // default List view |
939 | book = QString::null; | 940 | book = QString::null; |
940 | view = AbView::TableView; | 941 | view = AbView::TableView; |
941 | }else if ( i == 2 ){ | 942 | }else if ( i == 2 ){ |
942 | book = tr( "Cards" ); | 943 | book = tr( "Cards" ); |
943 | view = AbView::CardView; | 944 | view = AbView::CardView; |
944 | // }else if ( i == 3 ){ | 945 | // }else if ( i == 3 ){ |
945 | // book = tr( "Personal" ); | 946 | // book = tr( "Personal" ); |
946 | // view = AbView:: PersonalView; | 947 | // view = AbView:: PersonalView; |
947 | }else if ( i == 3 ){ // default All Categories | 948 | }else if ( i == 3 ){ // default All Categories |
948 | cat = QString::null; | 949 | cat = QString::null; |
949 | }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled | 950 | }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled |
950 | cat = "Unfiled"; | 951 | cat = "Unfiled"; |
951 | qWarning ("Unfiled selected!!!"); | 952 | qWarning ("Unfiled selected!!!"); |
952 | }else{ | 953 | }else{ |
953 | cat = m_abView->categories()[i - 4]; | 954 | cat = m_abView->categories()[i - 4]; |
954 | } | 955 | } |
955 | } | 956 | } |
956 | } | 957 | } |
957 | 958 | ||
958 | // Switch to the selected View | 959 | // Switch to the selected View |
959 | slotViewSwitched( view ); | 960 | slotViewSwitched( view ); |
960 | 961 | ||
961 | // Tell the view about the selected category | 962 | // Tell the view about the selected category |
962 | m_abView -> setShowByCategory( cat ); | 963 | m_abView -> setShowByCategory( cat ); |
963 | 964 | ||
964 | if ( book.isEmpty() ) | 965 | if ( book.isEmpty() ) |
965 | book = "List"; | 966 | book = "List"; |
966 | if ( cat.isEmpty() ) | 967 | if ( cat.isEmpty() ) |
967 | cat = "All"; | 968 | cat = "All"; |
968 | 969 | ||
969 | setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); | 970 | setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); |
970 | } | 971 | } |
971 | 972 | ||
972 | void AddressbookWindow::slotViewSwitched( int view ) | 973 | void AddressbookWindow::slotViewSwitched( int view ) |
973 | { | 974 | { |
974 | qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); | 975 | qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); |
975 | int menu = 0; | 976 | int menu = 0; |
976 | 977 | ||
977 | // Switch to selected view | 978 | // Switch to selected view |
978 | switch ( view ){ | 979 | switch ( view ){ |
979 | case AbView::TableView: | 980 | case AbView::TableView: |
980 | menu = 1; | 981 | menu = 1; |
981 | m_tableViewButton->setOn(true); | 982 | m_tableViewButton->setOn(true); |
982 | m_cardViewButton->setOn(false); | 983 | m_cardViewButton->setOn(false); |
983 | break; | 984 | break; |
984 | case AbView::CardView: | 985 | case AbView::CardView: |
985 | menu = 2; | 986 | menu = 2; |
986 | m_tableViewButton->setOn(false); | 987 | m_tableViewButton->setOn(false); |
987 | m_cardViewButton->setOn(true); | 988 | m_cardViewButton->setOn(true); |
988 | break; | 989 | break; |
989 | } | 990 | } |
990 | for ( unsigned int i = 1; i < 3; i++ ){ | 991 | for ( unsigned int i = 1; i < 3; i++ ){ |
991 | if ( catMenu ) | 992 | if ( catMenu ) |
992 | catMenu->setItemChecked( i, menu == (int)i ); | 993 | catMenu->setItemChecked( i, menu == (int)i ); |
993 | } | 994 | } |
994 | 995 | ||
995 | // Tell the view about the selected view | 996 | // Tell the view about the selected view |
996 | m_abView -> setShowToView ( (AbView::Views) view ); | 997 | m_abView -> setShowToView ( (AbView::Views) view ); |
997 | active_view = view; | 998 | active_view = view; |
998 | } | 999 | } |
999 | 1000 | ||
1000 | 1001 | ||
1001 | void AddressbookWindow::slotListView() | 1002 | void AddressbookWindow::slotListView() |
1002 | { | 1003 | { |
1003 | slotViewSwitched( AbView::TableView ); | 1004 | slotViewSwitched( AbView::TableView ); |
1004 | } | 1005 | } |
1005 | 1006 | ||
1006 | void AddressbookWindow::slotCardView() | 1007 | void AddressbookWindow::slotCardView() |
1007 | { | 1008 | { |
1008 | slotViewSwitched( AbView::CardView ); | 1009 | slotViewSwitched( AbView::CardView ); |
1009 | } | 1010 | } |
1010 | 1011 | ||
1011 | void AddressbookWindow::slotSetLetter( char c ) { | 1012 | void AddressbookWindow::slotSetLetter( char c ) { |
1012 | 1013 | ||
1013 | m_abView->setShowByLetter( c ); | 1014 | m_abView->setShowByLetter( c ); |
1014 | 1015 | ||
1015 | } | 1016 | } |
1016 | 1017 | ||
1017 | 1018 | ||
1018 | void AddressbookWindow::populateCategories() | 1019 | void AddressbookWindow::populateCategories() |
1019 | { | 1020 | { |
1020 | catMenu->clear(); | 1021 | catMenu->clear(); |
1021 | 1022 | ||
1022 | int id, rememberId; | 1023 | int id, rememberId; |
1023 | id = 1; | 1024 | id = 1; |
1024 | rememberId = 0; | 1025 | rememberId = 0; |
1025 | 1026 | ||
1026 | catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ ); | 1027 | catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ ); |
1027 | catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ ); | 1028 | catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ ); |
1028 | // catMenu->insertItem( tr( "Personal" ), id++ ); | 1029 | // catMenu->insertItem( tr( "Personal" ), id++ ); |
1029 | catMenu->insertSeparator(); | 1030 | catMenu->insertSeparator(); |
1030 | 1031 | ||
1031 | catMenu->insertItem( tr( "All" ), id++ ); | 1032 | catMenu->insertItem( tr( "All" ), id++ ); |
1032 | QStringList categories = m_abView->categories(); | 1033 | QStringList categories = m_abView->categories(); |
1033 | categories.append( tr( "Unfiled" ) ); | 1034 | categories.append( tr( "Unfiled" ) ); |
1034 | for ( QStringList::Iterator it = categories.begin(); | 1035 | for ( QStringList::Iterator it = categories.begin(); |
1035 | it != categories.end(); ++it ) { | 1036 | it != categories.end(); ++it ) { |
1036 | catMenu->insertItem( *it, id ); | 1037 | catMenu->insertItem( *it, id ); |
1037 | if ( *it == m_abView -> showCategory() ) | 1038 | if ( *it == m_abView -> showCategory() ) |
1038 | rememberId = id; | 1039 | rememberId = id; |
1039 | ++id; | 1040 | ++id; |
1040 | } | 1041 | } |
1041 | 1042 | ||
1042 | 1043 | ||
1043 | if ( m_abView -> showCategory().isEmpty() ) { | 1044 | if ( m_abView -> showCategory().isEmpty() ) { |
1044 | slotSetCategory( 3 ); | 1045 | slotSetCategory( 3 ); |
1045 | } | 1046 | } |
1046 | else { | 1047 | else { |
1047 | slotSetCategory( rememberId ); | 1048 | slotSetCategory( rememberId ); |
1048 | } | 1049 | } |
1049 | } | 1050 | } |
1050 | 1051 | ||