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