author | eilers <eilers> | 2003-08-01 13:57:54 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-08-01 13:57:54 (UTC) |
commit | 5346424fc26bde232a15aa34fbb720f86218b26f (patch) (unidiff) | |
tree | b6ce224b1fb517e8b31db1b9e0ef30cf539f6f6f | |
parent | 307b353d11842b0994827e4130b48386454b3f94 (diff) | |
download | opie-5346424fc26bde232a15aa34fbb720f86218b26f.zip opie-5346424fc26bde232a15aa34fbb720f86218b26f.tar.gz opie-5346424fc26bde232a15aa34fbb720f86218b26f.tar.bz2 |
Icon bug.. fixed.
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 6819085..03c96c8 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -1,1057 +1,1057 @@ | |||
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 <qpe/qpetoolbar.h> | 39 | #include <qpe/qpetoolbar.h> |
40 | #include <qpe/qpemenubar.h> | 40 | #include <qpe/qpemenubar.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 | QPEToolBar *bar = new QPEToolBar( this ); | 93 | QPEToolBar *bar = new QPEToolBar( this ); |
94 | bar->setHorizontalStretchable( TRUE ); | 94 | bar->setHorizontalStretchable( TRUE ); |
95 | 95 | ||
96 | QPEMenuBar *mbList = new QPEMenuBar( bar ); | 96 | QPEMenuBar *mbList = new QPEMenuBar( 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 QPEToolBar( this, "list operations" ); | 109 | listTools = new QPEToolBar( 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(); | 251 | m_abView->load(); |
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 | 271 | ||
272 | 272 | ||
273 | isLoading = false; | 273 | isLoading = false; |
274 | } | 274 | } |
275 | 275 | ||
276 | 276 | ||
277 | void AddressbookWindow::slotConfig() | 277 | void AddressbookWindow::slotConfig() |
278 | { | 278 | { |
279 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); | 279 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); |
280 | dlg -> setConfig( m_config ); | 280 | dlg -> setConfig( m_config ); |
281 | dlg -> showMaximized(); | 281 | dlg -> showMaximized(); |
282 | if ( dlg -> exec() ) { | 282 | if ( dlg -> exec() ) { |
283 | qWarning ("Config Dialog accepted!"); | 283 | qWarning ("Config Dialog accepted!"); |
284 | m_config = dlg -> getConfig(); | 284 | m_config = dlg -> getConfig(); |
285 | if ( m_curFontSize != m_config.fontSize() ){ | 285 | if ( m_curFontSize != m_config.fontSize() ){ |
286 | qWarning("Font was changed!"); | 286 | qWarning("Font was changed!"); |
287 | m_curFontSize = m_config.fontSize(); | 287 | m_curFontSize = m_config.fontSize(); |
288 | emit slotSetFont( m_curFontSize ); | 288 | emit slotSetFont( m_curFontSize ); |
289 | } | 289 | } |
290 | m_abView -> setListOrder( m_config.orderList() ); | 290 | m_abView -> setListOrder( m_config.orderList() ); |
291 | } | 291 | } |
292 | 292 | ||
293 | delete dlg; | 293 | delete dlg; |
294 | } | 294 | } |
295 | 295 | ||
296 | 296 | ||
297 | void AddressbookWindow::slotSetFont( int size ) | 297 | void AddressbookWindow::slotSetFont( int size ) |
298 | { | 298 | { |
299 | qWarning("void AddressbookWindow::slotSetFont( %d )", size); | 299 | qWarning("void AddressbookWindow::slotSetFont( %d )", size); |
300 | 300 | ||
301 | if (size > 2 || size < 0) | 301 | if (size > 2 || size < 0) |
302 | size = 1; | 302 | size = 1; |
303 | 303 | ||
304 | m_config.setFontSize( size ); | 304 | m_config.setFontSize( size ); |
305 | 305 | ||
306 | QFont *currentFont; | 306 | QFont *currentFont; |
307 | 307 | ||
308 | switch (size) { | 308 | switch (size) { |
309 | case 0: | 309 | case 0: |
310 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); | 310 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); |
311 | currentFont = new QFont (m_abView->font()); | 311 | currentFont = new QFont (m_abView->font()); |
312 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX | 312 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX |
313 | // abList->resizeRows(); | 313 | // abList->resizeRows(); |
314 | break; | 314 | break; |
315 | case 1: | 315 | case 1: |
316 | m_abView->setFont( *defaultFont ); | 316 | m_abView->setFont( *defaultFont ); |
317 | currentFont = new QFont (m_abView->font()); | 317 | currentFont = new QFont (m_abView->font()); |
318 | // // abList->resizeRows(currentFont->pixelSize() + 7); | 318 | // // abList->resizeRows(currentFont->pixelSize() + 7); |
319 | // abList->resizeRows(); | 319 | // abList->resizeRows(); |
320 | break; | 320 | break; |
321 | case 2: | 321 | case 2: |
322 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); | 322 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); |
323 | currentFont = new QFont (m_abView->font()); | 323 | currentFont = new QFont (m_abView->font()); |
324 | // //abList->resizeRows(currentFont->pixelSize() + 7); | 324 | // //abList->resizeRows(currentFont->pixelSize() + 7); |
325 | // abList->resizeRows(); | 325 | // abList->resizeRows(); |
326 | break; | 326 | break; |
327 | } | 327 | } |
328 | } | 328 | } |
329 | 329 | ||
330 | 330 | ||
331 | 331 | ||
332 | void AddressbookWindow::importvCard() { | 332 | void AddressbookWindow::importvCard() { |
333 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); | 333 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); |
334 | if(!str.isEmpty() ){ | 334 | if(!str.isEmpty() ){ |
335 | setDocument((const QString&) str ); | 335 | setDocument((const QString&) str ); |
336 | } | 336 | } |
337 | 337 | ||
338 | } | 338 | } |
339 | void AddressbookWindow::exportvCard() | 339 | void AddressbookWindow::exportvCard() |
340 | { | 340 | { |
341 | qWarning(" void AddressbookWindow::exportvCard()"); | 341 | qWarning(" void AddressbookWindow::exportvCard()"); |
342 | QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); | 342 | QString filename = OFileDialog::getSaveFileName( 1,"/home/"); //,"", "*", this ); |
343 | if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ | 343 | if( !filename.isEmpty() && ( filename[filename.length()-1] != '/' ) ){ |
344 | qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 ); | 344 | qWarning(" Save to file %s, (%d)", filename.latin1(), filename.length()-1 ); |
345 | OContact curCont = m_abView->currentEntry(); | 345 | OContact curCont = m_abView->currentEntry(); |
346 | if ( !curCont.isEmpty() ){ | 346 | if ( !curCont.isEmpty() ){ |
347 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 347 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
348 | filename ); | 348 | filename ); |
349 | OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); | 349 | OContactAccess* access = new OContactAccess ( "addressbook_exp", QString::null , vcard_backend, true ); |
350 | if ( access ){ | 350 | if ( access ){ |
351 | access->add( curCont ); | 351 | access->add( curCont ); |
352 | access->save(); | 352 | access->save(); |
353 | } | 353 | } |
354 | delete access; | 354 | delete access; |
355 | }else | 355 | }else |
356 | QMessageBox::critical( 0, "Export VCard", | 356 | QMessageBox::critical( 0, "Export VCard", |
357 | QString( tr( "You have to select a contact !") ) ); | 357 | QString( tr( "You have to select a contact !") ) ); |
358 | 358 | ||
359 | }else | 359 | }else |
360 | QMessageBox::critical( 0, "Export VCard", | 360 | QMessageBox::critical( 0, "Export VCard", |
361 | QString( tr( "You have to set a filename !") ) ); | 361 | QString( tr( "You have to set a filename !") ) ); |
362 | } | 362 | } |
363 | 363 | ||
364 | void AddressbookWindow::setDocument( const QString &filename ) | 364 | void AddressbookWindow::setDocument( const QString &filename ) |
365 | { | 365 | { |
366 | qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); | 366 | qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); |
367 | 367 | ||
368 | if ( filename.find(".vcf") != int(filename.length()) - 4 ){ | 368 | if ( filename.find(".vcf") != int(filename.length()) - 4 ){ |
369 | 369 | ||
370 | 370 | ||
371 | 371 | ||
372 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), | 372 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), |
373 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), | 373 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), |
374 | tr( "&Yes" ), tr( "&No" ), QString::null, | 374 | tr( "&Yes" ), tr( "&No" ), QString::null, |
375 | 0, // Enter == button 0 | 375 | 0, // Enter == button 0 |
376 | 2 ) ) { // Escape == button 2 | 376 | 2 ) ) { // Escape == button 2 |
377 | case 0: | 377 | case 0: |
378 | qWarning("YES clicked"); | 378 | qWarning("YES clicked"); |
379 | break; | 379 | break; |
380 | case 1: | 380 | case 1: |
381 | qWarning("NO clicked"); | 381 | qWarning("NO clicked"); |
382 | return; | 382 | return; |
383 | break; | 383 | break; |
384 | } | 384 | } |
385 | } | 385 | } |
386 | 386 | ||
387 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 387 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
388 | filename ); | 388 | filename ); |
389 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 389 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
390 | OContactAccess::List allList = access->allRecords(); | 390 | OContactAccess::List allList = access->allRecords(); |
391 | qWarning( "Found number of contacts in File: %d", allList.count() ); | 391 | qWarning( "Found number of contacts in File: %d", allList.count() ); |
392 | 392 | ||
393 | if ( !allList.count() ) { | 393 | if ( !allList.count() ) { |
394 | QMessageBox::information( this, "Import VCard", | 394 | QMessageBox::information( this, "Import VCard", |
395 | "It was impossible to import\nthe VCard.\n" | 395 | "It was impossible to import\nthe VCard.\n" |
396 | "The VCard may be corrupted!" ); | 396 | "The VCard may be corrupted!" ); |
397 | } | 397 | } |
398 | 398 | ||
399 | bool doAsk = true; | 399 | bool doAsk = true; |
400 | OContactAccess::List::Iterator it; | 400 | OContactAccess::List::Iterator it; |
401 | for ( it = allList.begin(); it != allList.end(); ++it ){ | 401 | for ( it = allList.begin(); it != allList.end(); ++it ){ |
402 | qWarning("Adding Contact from: %s", (*it).fullName().latin1() ); | 402 | qWarning("Adding Contact from: %s", (*it).fullName().latin1() ); |
403 | if ( doAsk ){ | 403 | if ( doAsk ){ |
404 | switch( QMessageBox::information( this, tr ( "Add Contact?" ), | 404 | switch( QMessageBox::information( this, tr ( "Add Contact?" ), |
405 | tr( "Do you really want add contact for \n%1?" ) | 405 | tr( "Do you really want add contact for \n%1?" ) |
406 | .arg( (*it).fullName().latin1() ), | 406 | .arg( (*it).fullName().latin1() ), |
407 | tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), | 407 | tr( "&Yes" ), tr( "&No" ), tr( "&All Yes"), |
408 | 0, // Enter == button 0 | 408 | 0, // Enter == button 0 |
409 | 2 ) ) { // Escape == button 2 | 409 | 2 ) ) { // Escape == button 2 |
410 | case 0: | 410 | case 0: |
411 | qWarning("YES clicked"); | 411 | qWarning("YES clicked"); |
412 | m_abView->addEntry( *it ); | 412 | m_abView->addEntry( *it ); |
413 | break; | 413 | break; |
414 | case 1: | 414 | case 1: |
415 | qWarning("NO clicked"); | 415 | qWarning("NO clicked"); |
416 | break; | 416 | break; |
417 | case 2: | 417 | case 2: |
418 | qWarning("YesAll clicked"); | 418 | qWarning("YesAll clicked"); |
419 | doAsk = false; | 419 | doAsk = false; |
420 | break; | 420 | break; |
421 | } | 421 | } |
422 | }else | 422 | }else |
423 | m_abView->addEntry( *it ); | 423 | m_abView->addEntry( *it ); |
424 | 424 | ||
425 | } | 425 | } |
426 | 426 | ||
427 | delete access; | 427 | delete access; |
428 | } | 428 | } |
429 | 429 | ||
430 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) | 430 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) |
431 | { | 431 | { |
432 | QMainWindow::resizeEvent( e ); | 432 | QMainWindow::resizeEvent( e ); |
433 | 433 | ||
434 | 434 | ||
435 | } | 435 | } |
436 | 436 | ||
437 | AddressbookWindow::~AddressbookWindow() | 437 | AddressbookWindow::~AddressbookWindow() |
438 | { | 438 | { |
439 | ToolBarDock dock; | 439 | ToolBarDock dock; |
440 | int dummy; | 440 | int dummy; |
441 | bool bDummy; | 441 | bool bDummy; |
442 | getLocation ( listTools, dock, dummy, bDummy, dummy ); | 442 | getLocation ( listTools, dock, dummy, bDummy, dummy ); |
443 | m_config.setToolBarDock( dock ); | 443 | m_config.setToolBarDock( dock ); |
444 | m_config.save(); | 444 | m_config.save(); |
445 | } | 445 | } |
446 | 446 | ||
447 | void AddressbookWindow::slotUpdateToolbar() | 447 | void AddressbookWindow::slotUpdateToolbar() |
448 | { | 448 | { |
449 | OContact ce = m_abView->currentEntry(); | 449 | OContact ce = m_abView->currentEntry(); |
450 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); | 450 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); |
451 | } | 451 | } |
452 | 452 | ||
453 | void AddressbookWindow::slotListNew() | 453 | void AddressbookWindow::slotListNew() |
454 | { | 454 | { |
455 | OContact cnt; | 455 | OContact cnt; |
456 | if( !syncing ) { | 456 | if( !syncing ) { |
457 | editEntry( NewEntry ); | 457 | editEntry( NewEntry ); |
458 | } else { | 458 | } else { |
459 | QMessageBox::warning(this, tr("Contacts"), | 459 | QMessageBox::warning(this, tr("Contacts"), |
460 | tr("Can not edit data, currently syncing")); | 460 | tr("Can not edit data, currently syncing")); |
461 | } | 461 | } |
462 | } | 462 | } |
463 | 463 | ||
464 | // void AddressbookWindow::slotListView() | 464 | // void AddressbookWindow::slotListView() |
465 | // { | 465 | // { |
466 | // m_abView -> init( abList->currentEntry() ); | 466 | // m_abView -> init( abList->currentEntry() ); |
467 | // // :SX mView->sync(); | 467 | // // :SX mView->sync(); |
468 | // //:SXshowView(); | 468 | // //:SXshowView(); |
469 | // } | 469 | // } |
470 | 470 | ||
471 | void AddressbookWindow::slotListDelete() | 471 | void AddressbookWindow::slotListDelete() |
472 | { | 472 | { |
473 | if(!syncing) { | 473 | if(!syncing) { |
474 | OContact tmpEntry = m_abView ->currentEntry(); | 474 | OContact tmpEntry = m_abView ->currentEntry(); |
475 | 475 | ||
476 | // get a name, do the best we can... | 476 | // get a name, do the best we can... |
477 | QString strName = tmpEntry.fullName(); | 477 | QString strName = tmpEntry.fullName(); |
478 | if ( strName.isEmpty() ) { | 478 | if ( strName.isEmpty() ) { |
479 | strName = tmpEntry.company(); | 479 | strName = tmpEntry.company(); |
480 | if ( strName.isEmpty() ) | 480 | if ( strName.isEmpty() ) |
481 | strName = "No Name"; | 481 | strName = "No Name"; |
482 | } | 482 | } |
483 | 483 | ||
484 | 484 | ||
485 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), | 485 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), |
486 | strName ) ) { | 486 | strName ) ) { |
487 | m_abView->removeEntry( tmpEntry.uid() ); | 487 | m_abView->removeEntry( tmpEntry.uid() ); |
488 | } | 488 | } |
489 | } else { | 489 | } else { |
490 | QMessageBox::warning( this, tr("Contacts"), | 490 | QMessageBox::warning( this, tr("Contacts"), |
491 | tr("Can not edit data, currently syncing") ); | 491 | tr("Can not edit data, currently syncing") ); |
492 | } | 492 | } |
493 | } | 493 | } |
494 | 494 | ||
495 | void AddressbookWindow::slotFindOpen() | 495 | void AddressbookWindow::slotFindOpen() |
496 | { | 496 | { |
497 | searchBar->show(); | 497 | searchBar->show(); |
498 | m_abView -> inSearch(); | 498 | m_abView -> inSearch(); |
499 | searchEdit->setFocus(); | 499 | searchEdit->setFocus(); |
500 | } | 500 | } |
501 | void AddressbookWindow::slotFindClose() | 501 | void AddressbookWindow::slotFindClose() |
502 | { | 502 | { |
503 | searchBar->hide(); | 503 | searchBar->hide(); |
504 | m_abView -> offSearch(); | 504 | m_abView -> offSearch(); |
505 | // m_abView->setFocus(); | 505 | // m_abView->setFocus(); |
506 | } | 506 | } |
507 | 507 | ||
508 | 508 | ||
509 | void AddressbookWindow::slotFind() | 509 | void AddressbookWindow::slotFind() |
510 | { | 510 | { |
511 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); | 511 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); |
512 | 512 | ||
513 | searchEdit->clearFocus(); | 513 | searchEdit->clearFocus(); |
514 | // m_abView->setFocus(); | 514 | // m_abView->setFocus(); |
515 | 515 | ||
516 | } | 516 | } |
517 | 517 | ||
518 | void AddressbookWindow::slotViewBack() | 518 | void AddressbookWindow::slotViewBack() |
519 | { | 519 | { |
520 | // :SX showList(); | 520 | // :SX showList(); |
521 | } | 521 | } |
522 | 522 | ||
523 | void AddressbookWindow::slotViewEdit() | 523 | void AddressbookWindow::slotViewEdit() |
524 | { | 524 | { |
525 | if(!syncing) { | 525 | if(!syncing) { |
526 | if (actionPersonal->isOn()) { | 526 | if (actionPersonal->isOn()) { |
527 | editPersonal(); | 527 | editPersonal(); |
528 | } else { | 528 | } else { |
529 | editEntry( EditEntry ); | 529 | editEntry( EditEntry ); |
530 | } | 530 | } |
531 | } else { | 531 | } else { |
532 | QMessageBox::warning( this, tr("Contacts"), | 532 | QMessageBox::warning( this, tr("Contacts"), |
533 | tr("Can not edit data, currently syncing") ); | 533 | tr("Can not edit data, currently syncing") ); |
534 | } | 534 | } |
535 | } | 535 | } |
536 | 536 | ||
537 | 537 | ||
538 | 538 | ||
539 | void AddressbookWindow::writeMail() | 539 | void AddressbookWindow::writeMail() |
540 | { | 540 | { |
541 | OContact c = m_abView -> currentEntry(); | 541 | OContact c = m_abView -> currentEntry(); |
542 | QString name = c.fileAs(); | 542 | QString name = c.fileAs(); |
543 | QString email = c.defaultEmail(); | 543 | QString email = c.defaultEmail(); |
544 | 544 | ||
545 | // I prefer the OPIE-Environment variable before the | 545 | // I prefer the OPIE-Environment variable before the |
546 | // QPE-one.. | 546 | // QPE-one.. |
547 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); | 547 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); |
548 | if ( basepath.isEmpty() ) | 548 | if ( basepath.isEmpty() ) |
549 | basepath = QString::fromLatin1( getenv("QPEDIR") ); | 549 | basepath = QString::fromLatin1( getenv("QPEDIR") ); |
550 | 550 | ||
551 | // Try to access the preferred. If not possible, try to | 551 | // Try to access the preferred. If not possible, try to |
552 | // switch to the other one.. | 552 | // switch to the other one.. |
553 | if ( m_config.useQtMail() ){ | 553 | if ( m_config.useQtMail() ){ |
554 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); | 554 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); |
555 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ | 555 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ |
556 | qWarning ("QCop"); | 556 | qWarning ("QCop"); |
557 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); | 557 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); |
558 | e << name << email; | 558 | e << name << email; |
559 | return; | 559 | return; |
560 | } else | 560 | } else |
561 | m_config.setUseOpieMail( true ); | 561 | m_config.setUseOpieMail( true ); |
562 | } | 562 | } |
563 | if ( m_config.useOpieMail() ){ | 563 | if ( m_config.useOpieMail() ){ |
564 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); | 564 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); |
565 | if ( QFile::exists( basepath + "/bin/mail" ) ){ | 565 | if ( QFile::exists( basepath + "/bin/mail" ) ){ |
566 | qWarning ("QCop"); | 566 | qWarning ("QCop"); |
567 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); | 567 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); |
568 | e << name << email; | 568 | e << name << email; |
569 | return; | 569 | return; |
570 | } else | 570 | } else |
571 | m_config.setUseQtMail( true ); | 571 | m_config.setUseQtMail( true ); |
572 | } | 572 | } |
573 | 573 | ||
574 | } | 574 | } |
575 | 575 | ||
576 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 576 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
577 | 577 | ||
578 | void AddressbookWindow::slotBeam() | 578 | void AddressbookWindow::slotBeam() |
579 | { | 579 | { |
580 | QString beamFilename; | 580 | QString beamFilename; |
581 | OContact c; | 581 | OContact c; |
582 | if ( actionPersonal->isOn() ) { | 582 | if ( actionPersonal->isOn() ) { |
583 | beamFilename = addressbookPersonalVCardName(); | 583 | beamFilename = addressbookPersonalVCardName(); |
584 | if ( !QFile::exists( beamFilename ) ) | 584 | if ( !QFile::exists( beamFilename ) ) |
585 | return; // can't beam a non-existent file | 585 | return; // can't beam a non-existent file |
586 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 586 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
587 | beamFilename ); | 587 | beamFilename ); |
588 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 588 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
589 | OContactAccess::List allList = access->allRecords(); | 589 | OContactAccess::List allList = access->allRecords(); |
590 | OContactAccess::List::Iterator it = allList.begin(); // Just take first | 590 | OContactAccess::List::Iterator it = allList.begin(); // Just take first |
591 | c = *it; | 591 | c = *it; |
592 | 592 | ||
593 | delete access; | 593 | delete access; |
594 | } else { | 594 | } else { |
595 | unlink( beamfile ); // delete if exists | 595 | unlink( beamfile ); // delete if exists |
596 | mkdir("/tmp/obex/", 0755); | 596 | mkdir("/tmp/obex/", 0755); |
597 | c = m_abView -> currentEntry(); | 597 | c = m_abView -> currentEntry(); |
598 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 598 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
599 | beamfile ); | 599 | beamfile ); |
600 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 600 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
601 | access->add( c ); | 601 | access->add( c ); |
602 | access->save(); | 602 | access->save(); |
603 | delete access; | 603 | delete access; |
604 | 604 | ||
605 | beamFilename = beamfile; | 605 | beamFilename = beamfile; |
606 | } | 606 | } |
607 | 607 | ||
608 | qWarning("Beaming: %s", beamFilename.latin1() ); | 608 | qWarning("Beaming: %s", beamFilename.latin1() ); |
609 | 609 | ||
610 | Ir *ir = new Ir( this ); | 610 | Ir *ir = new Ir( this ); |
611 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 611 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
612 | QString description = c.fullName(); | 612 | QString description = c.fullName(); |
613 | ir->send( beamFilename, description, "text/x-vCard" ); | 613 | ir->send( beamFilename, description, "text/x-vCard" ); |
614 | } | 614 | } |
615 | 615 | ||
616 | void AddressbookWindow::beamDone( Ir *ir ) | 616 | void AddressbookWindow::beamDone( Ir *ir ) |
617 | { | 617 | { |
618 | 618 | ||
619 | delete ir; | 619 | delete ir; |
620 | unlink( beamfile ); | 620 | unlink( beamfile ); |
621 | } | 621 | } |
622 | 622 | ||
623 | 623 | ||
624 | static void parseName( const QString& name, QString *first, QString *middle, | 624 | static void parseName( const QString& name, QString *first, QString *middle, |
625 | QString * last ) | 625 | QString * last ) |
626 | { | 626 | { |
627 | 627 | ||
628 | int comma = name.find ( "," ); | 628 | int comma = name.find ( "," ); |
629 | QString rest; | 629 | QString rest; |
630 | if ( comma > 0 ) { | 630 | if ( comma > 0 ) { |
631 | *last = name.left( comma ); | 631 | *last = name.left( comma ); |
632 | comma++; | 632 | comma++; |
633 | while ( comma < int(name.length()) && name[comma] == ' ' ) | 633 | while ( comma < int(name.length()) && name[comma] == ' ' ) |
634 | comma++; | 634 | comma++; |
635 | rest = name.mid( comma ); | 635 | rest = name.mid( comma ); |
636 | } else { | 636 | } else { |
637 | int space = name.findRev( ' ' ); | 637 | int space = name.findRev( ' ' ); |
638 | *last = name.mid( space+1 ); | 638 | *last = name.mid( space+1 ); |
639 | rest = name.left( space ); | 639 | rest = name.left( space ); |
640 | } | 640 | } |
641 | int space = rest.find( ' ' ); | 641 | int space = rest.find( ' ' ); |
642 | if ( space <= 0 ) { | 642 | if ( space <= 0 ) { |
643 | *first = rest; | 643 | *first = rest; |
644 | } else { | 644 | } else { |
645 | *first = rest.left( space ); | 645 | *first = rest.left( space ); |
646 | *middle = rest.mid( space+1 ); | 646 | *middle = rest.mid( space+1 ); |
647 | } | 647 | } |
648 | 648 | ||
649 | } | 649 | } |
650 | 650 | ||
651 | 651 | ||
652 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | 652 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) |
653 | { | 653 | { |
654 | bool needShow = FALSE; | 654 | bool needShow = FALSE; |
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 | 657 | ||
658 | if (msg == "editPersonal()") { | 658 | if (msg == "editPersonal()") { |
659 | editPersonal(); | 659 | editPersonal(); |
660 | } else if (msg == "editPersonalAndClose()") { | 660 | } else if (msg == "editPersonalAndClose()") { |
661 | editPersonal(); | 661 | editPersonal(); |
662 | close(); | 662 | close(); |
663 | } else if ( msg == "addContact(QString,QString)" ) { | 663 | } else if ( msg == "addContact(QString,QString)" ) { |
664 | QDataStream stream(data,IO_ReadOnly); | 664 | QDataStream stream(data,IO_ReadOnly); |
665 | QString name, email; | 665 | QString name, email; |
666 | stream >> name >> email; | 666 | stream >> name >> email; |
667 | 667 | ||
668 | OContact cnt; | 668 | OContact cnt; |
669 | QString fn, mn, ln; | 669 | QString fn, mn, ln; |
670 | parseName( name, &fn, &mn, &ln ); | 670 | parseName( name, &fn, &mn, &ln ); |
671 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); | 671 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); |
672 | cnt.setFirstName( fn ); | 672 | cnt.setFirstName( fn ); |
673 | cnt.setMiddleName( mn ); | 673 | cnt.setMiddleName( mn ); |
674 | cnt.setLastName( ln ); | 674 | cnt.setLastName( ln ); |
675 | cnt.insertEmails( email ); | 675 | cnt.insertEmails( email ); |
676 | cnt.setDefaultEmail( email ); | 676 | cnt.setDefaultEmail( email ); |
677 | cnt.setFileAs(); | 677 | cnt.setFileAs(); |
678 | 678 | ||
679 | m_abView -> addEntry( cnt ); | 679 | m_abView -> addEntry( cnt ); |
680 | 680 | ||
681 | // :SXm_abView()->init( cnt ); | 681 | // :SXm_abView()->init( cnt ); |
682 | editEntry( EditEntry ); | 682 | editEntry( EditEntry ); |
683 | } else if ( msg == "beamBusinessCard()" ) { | 683 | } else if ( msg == "beamBusinessCard()" ) { |
684 | QString beamFilename = addressbookPersonalVCardName(); | 684 | QString beamFilename = addressbookPersonalVCardName(); |
685 | if ( !QFile::exists( beamFilename ) ) | 685 | if ( !QFile::exists( beamFilename ) ) |
686 | return; // can't beam a non-existent file | 686 | return; // can't beam a non-existent file |
687 | 687 | ||
688 | Ir *ir = new Ir( this ); | 688 | Ir *ir = new Ir( this ); |
689 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 689 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
690 | QString description = "mycard.vcf"; | 690 | QString description = "mycard.vcf"; |
691 | ir->send( beamFilename, description, "text/x-vCard" ); | 691 | ir->send( beamFilename, description, "text/x-vCard" ); |
692 | } else if ( msg == "show(int)" ) { | 692 | } else if ( msg == "show(int)" ) { |
693 | raise(); | 693 | raise(); |
694 | QDataStream stream(data,IO_ReadOnly); | 694 | QDataStream stream(data,IO_ReadOnly); |
695 | int uid; | 695 | int uid; |
696 | stream >> uid; | 696 | stream >> uid; |
697 | 697 | ||
698 | qWarning( "Showing uid: %d" , uid ); | 698 | qWarning( "Showing uid: %d" , uid ); |
699 | 699 | ||
700 | // Deactivate Personal View.. | 700 | // Deactivate Personal View.. |
701 | if ( actionPersonal->isOn() ){ | 701 | if ( actionPersonal->isOn() ){ |
702 | actionPersonal->setOn( false ); | 702 | actionPersonal->setOn( false ); |
703 | slotPersonalView(); | 703 | slotPersonalView(); |
704 | } | 704 | } |
705 | 705 | ||
706 | // Reset category and show as card.. | 706 | // Reset category and show as card.. |
707 | m_abView -> setShowByCategory( QString::null ); | 707 | m_abView -> setShowByCategory( QString::null ); |
708 | m_abView -> setCurrentUid( uid ); | 708 | m_abView -> setCurrentUid( uid ); |
709 | slotViewSwitched ( AbView::CardView ); | 709 | slotViewSwitched ( AbView::CardView ); |
710 | 710 | ||
711 | needShow = true; | 711 | needShow = true; |
712 | 712 | ||
713 | 713 | ||
714 | } else if ( msg == "edit(int)" ) { | 714 | } else if ( msg == "edit(int)" ) { |
715 | QDataStream stream(data,IO_ReadOnly); | 715 | QDataStream stream(data,IO_ReadOnly); |
716 | int uid; | 716 | int uid; |
717 | stream >> uid; | 717 | stream >> uid; |
718 | 718 | ||
719 | // Deactivate Personal View.. | 719 | // Deactivate Personal View.. |
720 | if ( actionPersonal->isOn() ){ | 720 | if ( actionPersonal->isOn() ){ |
721 | actionPersonal->setOn( false ); | 721 | actionPersonal->setOn( false ); |
722 | slotPersonalView(); | 722 | slotPersonalView(); |
723 | } | 723 | } |
724 | 724 | ||
725 | // Reset category and edit.. | 725 | // Reset category and edit.. |
726 | m_abView -> setShowByCategory( QString::null ); | 726 | m_abView -> setShowByCategory( QString::null ); |
727 | m_abView -> setCurrentUid( uid ); | 727 | m_abView -> setCurrentUid( uid ); |
728 | slotViewEdit(); | 728 | slotViewEdit(); |
729 | } | 729 | } |
730 | 730 | ||
731 | if (needShow) | 731 | if (needShow) |
732 | QPEApplication::setKeepRunning(); | 732 | QPEApplication::setKeepRunning(); |
733 | 733 | ||
734 | } | 734 | } |
735 | 735 | ||
736 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 736 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
737 | { | 737 | { |
738 | OContact entry; | 738 | OContact entry; |
739 | if ( !abEditor ) { | 739 | if ( !abEditor ) { |
740 | abEditor = new ContactEditor( entry, this, "editor" ); | 740 | abEditor = new ContactEditor( entry, this, "editor" ); |
741 | } | 741 | } |
742 | if ( entryMode == EditEntry ) | 742 | if ( entryMode == EditEntry ) |
743 | abEditor->setEntry( m_abView -> currentEntry() ); | 743 | abEditor->setEntry( m_abView -> currentEntry() ); |
744 | else if ( entryMode == NewEntry ) | 744 | else if ( entryMode == NewEntry ) |
745 | abEditor->setEntry( entry ); | 745 | abEditor->setEntry( entry ); |
746 | // other things may change the caption. | 746 | // other things may change the caption. |
747 | abEditor->setCaption( tr("Edit Address") ); | 747 | abEditor->setCaption( tr("Edit Address") ); |
748 | 748 | ||
749 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 749 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
750 | abEditor->showMaximized(); | 750 | abEditor->showMaximized(); |
751 | #endif | 751 | #endif |
752 | // fix the foxus... | 752 | // fix the foxus... |
753 | abEditor->setNameFocus(); | 753 | abEditor->setNameFocus(); |
754 | if ( abEditor->exec() ) { | 754 | if ( abEditor->exec() ) { |
755 | setFocus(); | 755 | setFocus(); |
756 | if ( entryMode == NewEntry ) { | 756 | if ( entryMode == NewEntry ) { |
757 | OContact insertEntry = abEditor->entry(); | 757 | OContact insertEntry = abEditor->entry(); |
758 | insertEntry.assignUid(); | 758 | insertEntry.assignUid(); |
759 | m_abView -> addEntry( insertEntry ); | 759 | m_abView -> addEntry( insertEntry ); |
760 | m_abView -> setCurrentUid( insertEntry.uid() ); | 760 | m_abView -> setCurrentUid( insertEntry.uid() ); |
761 | } else { | 761 | } else { |
762 | OContact replEntry = abEditor->entry(); | 762 | OContact replEntry = abEditor->entry(); |
763 | 763 | ||
764 | if ( !replEntry.isValidUid() ) | 764 | if ( !replEntry.isValidUid() ) |
765 | replEntry.assignUid(); | 765 | replEntry.assignUid(); |
766 | 766 | ||
767 | m_abView -> replaceEntry( replEntry ); | 767 | m_abView -> replaceEntry( replEntry ); |
768 | } | 768 | } |
769 | } | 769 | } |
770 | // populateCategories(); | 770 | // populateCategories(); |
771 | 771 | ||
772 | } | 772 | } |
773 | 773 | ||
774 | void AddressbookWindow::editPersonal() | 774 | void AddressbookWindow::editPersonal() |
775 | { | 775 | { |
776 | OContact entry; | 776 | OContact entry; |
777 | 777 | ||
778 | // Switch to personal view if not selected | 778 | // Switch to personal view if not selected |
779 | // but take care of the menu, too | 779 | // but take care of the menu, too |
780 | if ( ! actionPersonal->isOn() ){ | 780 | if ( ! actionPersonal->isOn() ){ |
781 | qWarning("*** ++++"); | 781 | qWarning("*** ++++"); |
782 | actionPersonal->setOn( true ); | 782 | actionPersonal->setOn( true ); |
783 | slotPersonalView(); | 783 | slotPersonalView(); |
784 | } | 784 | } |
785 | 785 | ||
786 | if ( !abEditor ) { | 786 | if ( !abEditor ) { |
787 | abEditor = new ContactEditor( entry, this, "editor" ); | 787 | abEditor = new ContactEditor( entry, this, "editor" ); |
788 | } | 788 | } |
789 | 789 | ||
790 | abEditor->setCaption(tr("Edit My Personal Details")); | 790 | abEditor->setCaption(tr("Edit My Personal Details")); |
791 | abEditor->setPersonalView( true ); | 791 | abEditor->setPersonalView( true ); |
792 | editEntry( EditEntry ); | 792 | editEntry( EditEntry ); |
793 | abEditor->setPersonalView( false ); | 793 | abEditor->setPersonalView( false ); |
794 | 794 | ||
795 | } | 795 | } |
796 | 796 | ||
797 | 797 | ||
798 | void AddressbookWindow::slotPersonalView() | 798 | void AddressbookWindow::slotPersonalView() |
799 | { | 799 | { |
800 | qWarning("slotPersonalView()"); | 800 | qWarning("slotPersonalView()"); |
801 | if (!actionPersonal->isOn()) { | 801 | if (!actionPersonal->isOn()) { |
802 | // we just turned it off | 802 | // we just turned it off |
803 | qWarning("slotPersonalView()-> OFF"); | 803 | qWarning("slotPersonalView()-> OFF"); |
804 | setCaption( tr("Contacts") ); | 804 | setCaption( tr("Contacts") ); |
805 | actionNew->setEnabled(TRUE); | 805 | actionNew->setEnabled(TRUE); |
806 | actionTrash->setEnabled(TRUE); | 806 | actionTrash->setEnabled(TRUE); |
807 | actionFind->setEnabled(TRUE); | 807 | actionFind->setEnabled(TRUE); |
808 | actionMail->setEnabled(TRUE); | 808 | actionMail->setEnabled(TRUE); |
809 | // slotUpdateToolbar(); | 809 | // slotUpdateToolbar(); |
810 | 810 | ||
811 | m_abView->showPersonal( false ); | 811 | m_abView->showPersonal( false ); |
812 | 812 | ||
813 | return; | 813 | return; |
814 | } | 814 | } |
815 | 815 | ||
816 | qWarning("slotPersonalView()-> ON"); | 816 | qWarning("slotPersonalView()-> ON"); |
817 | // XXX need to disable some QActions. | 817 | // XXX need to disable some QActions. |
818 | actionNew->setEnabled(FALSE); | 818 | actionNew->setEnabled(FALSE); |
819 | actionTrash->setEnabled(FALSE); | 819 | actionTrash->setEnabled(FALSE); |
820 | actionFind->setEnabled(FALSE); | 820 | actionFind->setEnabled(FALSE); |
821 | actionMail->setEnabled(FALSE); | 821 | actionMail->setEnabled(FALSE); |
822 | 822 | ||
823 | setCaption( tr("Contacts - My Personal Details") ); | 823 | setCaption( tr("Contacts - My Personal Details") ); |
824 | 824 | ||
825 | m_abView->showPersonal( true ); | 825 | m_abView->showPersonal( true ); |
826 | 826 | ||
827 | } | 827 | } |
828 | 828 | ||
829 | 829 | ||
830 | void AddressbookWindow::listIsEmpty( bool empty ) | 830 | void AddressbookWindow::listIsEmpty( bool empty ) |
831 | { | 831 | { |
832 | if ( !empty ) { | 832 | if ( !empty ) { |
833 | deleteButton->setEnabled( TRUE ); | 833 | deleteButton->setEnabled( TRUE ); |
834 | } | 834 | } |
835 | } | 835 | } |
836 | 836 | ||
837 | void AddressbookWindow::reload() | 837 | void AddressbookWindow::reload() |
838 | { | 838 | { |
839 | syncing = FALSE; | 839 | syncing = FALSE; |
840 | m_abView->clear(); | 840 | m_abView->clear(); |
841 | m_abView->reload(); | 841 | m_abView->reload(); |
842 | } | 842 | } |
843 | 843 | ||
844 | void AddressbookWindow::flush() | 844 | void AddressbookWindow::flush() |
845 | { | 845 | { |
846 | syncing = TRUE; | 846 | syncing = TRUE; |
847 | m_abView->save(); | 847 | m_abView->save(); |
848 | } | 848 | } |
849 | 849 | ||
850 | 850 | ||
851 | void AddressbookWindow::closeEvent( QCloseEvent *e ) | 851 | void AddressbookWindow::closeEvent( QCloseEvent *e ) |
852 | { | 852 | { |
853 | if(active_view == AbView::CardView){ | 853 | if(active_view == AbView::CardView){ |
854 | slotViewSwitched( AbView::TableView ); | 854 | slotViewSwitched( AbView::TableView ); |
855 | e->ignore(); | 855 | e->ignore(); |
856 | return; | 856 | return; |
857 | } | 857 | } |
858 | if(syncing) { | 858 | if(syncing) { |
859 | /* shouldn't we save, I hear you say? well its already been set | 859 | /* shouldn't we save, I hear you say? well its already been set |
860 | so that an edit can not occur during a sync, and we flushed | 860 | so that an edit can not occur during a sync, and we flushed |
861 | at the start of the sync, so there is no need to save | 861 | at the start of the sync, so there is no need to save |
862 | Saving however itself would cause problems. */ | 862 | Saving however itself would cause problems. */ |
863 | e->accept(); | 863 | e->accept(); |
864 | return; | 864 | return; |
865 | } | 865 | } |
866 | //################## shouldn't always save | 866 | //################## shouldn't always save |
867 | // True, but the database handles this automatically ! (se) | 867 | // True, but the database handles this automatically ! (se) |
868 | if ( save() ) | 868 | if ( save() ) |
869 | e->accept(); | 869 | e->accept(); |
870 | else | 870 | else |
871 | e->ignore(); | 871 | e->ignore(); |
872 | } | 872 | } |
873 | 873 | ||
874 | /* | 874 | /* |
875 | Returns TRUE if it is OK to exit | 875 | Returns TRUE if it is OK to exit |
876 | */ | 876 | */ |
877 | 877 | ||
878 | bool AddressbookWindow::save() | 878 | bool AddressbookWindow::save() |
879 | { | 879 | { |
880 | if ( !m_abView->save() ) { | 880 | if ( !m_abView->save() ) { |
881 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | 881 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
882 | tr("Unable to save information.\n" | 882 | tr("Unable to save information.\n" |
883 | "Free up some space\n" | 883 | "Free up some space\n" |
884 | "and try again.\n" | 884 | "and try again.\n" |
885 | "\nQuit anyway?"), | 885 | "\nQuit anyway?"), |
886 | QMessageBox::Yes|QMessageBox::Escape, | 886 | QMessageBox::Yes|QMessageBox::Escape, |
887 | QMessageBox::No|QMessageBox::Default ) | 887 | QMessageBox::No|QMessageBox::Default ) |
888 | != QMessageBox::No ) | 888 | != QMessageBox::No ) |
889 | return TRUE; | 889 | return TRUE; |
890 | else | 890 | else |
891 | return FALSE; | 891 | return FALSE; |
892 | } | 892 | } |
893 | return TRUE; | 893 | return TRUE; |
894 | } | 894 | } |
895 | 895 | ||
896 | #ifdef __DEBUG_RELEASE | 896 | #ifdef __DEBUG_RELEASE |
897 | void AddressbookWindow::slotSave() | 897 | void AddressbookWindow::slotSave() |
898 | { | 898 | { |
899 | save(); | 899 | save(); |
900 | } | 900 | } |
901 | #endif | 901 | #endif |
902 | 902 | ||
903 | 903 | ||
904 | void AddressbookWindow::slotNotFound() | 904 | void AddressbookWindow::slotNotFound() |
905 | { | 905 | { |
906 | qWarning("Got notfound signal!"); | 906 | qWarning("Got notfound signal!"); |
907 | QMessageBox::information( this, tr( "Not Found" ), | 907 | QMessageBox::information( this, tr( "Not Found" ), |
908 | "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" ); | 908 | "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" ); |
909 | 909 | ||
910 | 910 | ||
911 | } | 911 | } |
912 | void AddressbookWindow::slotWrapAround() | 912 | void AddressbookWindow::slotWrapAround() |
913 | { | 913 | { |
914 | qWarning("Got wrap signal!"); | 914 | qWarning("Got wrap signal!"); |
915 | // if ( doNotifyWrapAround ) | 915 | // if ( doNotifyWrapAround ) |
916 | // QMessageBox::information( this, tr( "End of list" ), | 916 | // QMessageBox::information( this, tr( "End of list" ), |
917 | // tr( "End of list. Wrap around now...!" ) + "\n" ); | 917 | // tr( "End of list. Wrap around now...!" ) + "\n" ); |
918 | 918 | ||
919 | } | 919 | } |
920 | 920 | ||
921 | void AddressbookWindow::slotSetCategory( int c ) | 921 | void AddressbookWindow::slotSetCategory( int c ) |
922 | { | 922 | { |
923 | qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); | 923 | qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); |
924 | 924 | ||
925 | QString cat, book; | 925 | QString cat, book; |
926 | AbView::Views view = AbView::TableView; | 926 | AbView::Views view = AbView::TableView; |
927 | 927 | ||
928 | if ( c <= 0 ) | 928 | if ( c <= 0 ) |
929 | return; | 929 | return; |
930 | 930 | ||
931 | // Switch view | 931 | // Switch view |
932 | if ( c < 3 ) | 932 | if ( c < 3 ) |
933 | for ( unsigned int i = 1; i < 3; i++ ){ | 933 | for ( unsigned int i = 1; i < 3; i++ ){ |
934 | if ( catMenu ) | 934 | if ( catMenu ) |
935 | catMenu->setItemChecked( i, c == (int)i ); | 935 | catMenu->setItemChecked( i, c == (int)i ); |
936 | } | 936 | } |
937 | else | 937 | else |
938 | // Checkmark Category Menu Item Selected | 938 | // Checkmark Category Menu Item Selected |
939 | for ( unsigned int i = 3; i < catMenu->count(); i++ ) | 939 | for ( unsigned int i = 3; i < catMenu->count(); i++ ) |
940 | catMenu->setItemChecked( i, c == (int)i ); | 940 | catMenu->setItemChecked( i, c == (int)i ); |
941 | 941 | ||
942 | // Now switch to the selected category | 942 | // Now switch to the selected category |
943 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { | 943 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { |
944 | if (catMenu->isItemChecked( i )) { | 944 | if (catMenu->isItemChecked( i )) { |
945 | if ( i == 1 ){ // default List view | 945 | if ( i == 1 ){ // default List view |
946 | book = QString::null; | 946 | book = QString::null; |
947 | view = AbView::TableView; | 947 | view = AbView::TableView; |
948 | }else if ( i == 2 ){ | 948 | }else if ( i == 2 ){ |
949 | book = tr( "Cards" ); | 949 | book = tr( "Cards" ); |
950 | view = AbView::CardView; | 950 | view = AbView::CardView; |
951 | // }else if ( i == 3 ){ | 951 | // }else if ( i == 3 ){ |
952 | // book = tr( "Personal" ); | 952 | // book = tr( "Personal" ); |
953 | // view = AbView:: PersonalView; | 953 | // view = AbView:: PersonalView; |
954 | }else if ( i == 3 ){ // default All Categories | 954 | }else if ( i == 3 ){ // default All Categories |
955 | cat = QString::null; | 955 | cat = QString::null; |
956 | }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled | 956 | }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled |
957 | cat = "Unfiled"; | 957 | cat = "Unfiled"; |
958 | qWarning ("Unfiled selected!"); | 958 | qWarning ("Unfiled selected!"); |
959 | }else{ | 959 | }else{ |
960 | cat = m_abView->categories()[i - 4]; | 960 | cat = m_abView->categories()[i - 4]; |
961 | } | 961 | } |
962 | } | 962 | } |
963 | } | 963 | } |
964 | 964 | ||
965 | // Switch to the selected View | 965 | // Switch to the selected View |
966 | slotViewSwitched( view ); | 966 | slotViewSwitched( view ); |
967 | 967 | ||
968 | // Tell the view about the selected category | 968 | // Tell the view about the selected category |
969 | m_abView -> setShowByCategory( cat ); | 969 | m_abView -> setShowByCategory( cat ); |
970 | 970 | ||
971 | if ( book.isEmpty() ) | 971 | if ( book.isEmpty() ) |
972 | book = "List"; | 972 | book = "List"; |
973 | if ( cat.isEmpty() ) | 973 | if ( cat.isEmpty() ) |
974 | cat = "All"; | 974 | cat = "All"; |
975 | 975 | ||
976 | setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); | 976 | setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); |
977 | } | 977 | } |
978 | 978 | ||
979 | void AddressbookWindow::slotViewSwitched( int view ) | 979 | void AddressbookWindow::slotViewSwitched( int view ) |
980 | { | 980 | { |
981 | qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); | 981 | qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); |
982 | int menu = 0; | 982 | int menu = 0; |
983 | 983 | ||
984 | // Switch to selected view | 984 | // Switch to selected view |
985 | switch ( view ){ | 985 | switch ( view ){ |
986 | case AbView::TableView: | 986 | case AbView::TableView: |
987 | menu = 1; | 987 | menu = 1; |
988 | m_tableViewButton->setOn(true); | 988 | m_tableViewButton->setOn(true); |
989 | m_cardViewButton->setOn(false); | 989 | m_cardViewButton->setOn(false); |
990 | break; | 990 | break; |
991 | case AbView::CardView: | 991 | case AbView::CardView: |
992 | menu = 2; | 992 | menu = 2; |
993 | m_tableViewButton->setOn(false); | 993 | m_tableViewButton->setOn(false); |
994 | m_cardViewButton->setOn(true); | 994 | m_cardViewButton->setOn(true); |
995 | break; | 995 | break; |
996 | } | 996 | } |
997 | for ( unsigned int i = 1; i < 3; i++ ){ | 997 | for ( unsigned int i = 1; i < 3; i++ ){ |
998 | if ( catMenu ) | 998 | if ( catMenu ) |
999 | catMenu->setItemChecked( i, menu == (int)i ); | 999 | catMenu->setItemChecked( i, menu == (int)i ); |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | // Tell the view about the selected view | 1002 | // Tell the view about the selected view |
1003 | m_abView -> setShowToView ( (AbView::Views) view ); | 1003 | m_abView -> setShowToView ( (AbView::Views) view ); |
1004 | active_view = view; | 1004 | active_view = view; |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | 1007 | ||
1008 | void AddressbookWindow::slotListView() | 1008 | void AddressbookWindow::slotListView() |
1009 | { | 1009 | { |
1010 | slotViewSwitched( AbView::TableView ); | 1010 | slotViewSwitched( AbView::TableView ); |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | void AddressbookWindow::slotCardView() | 1013 | void AddressbookWindow::slotCardView() |
1014 | { | 1014 | { |
1015 | slotViewSwitched( AbView::CardView ); | 1015 | slotViewSwitched( AbView::CardView ); |
1016 | } | 1016 | } |
1017 | 1017 | ||
1018 | void AddressbookWindow::slotSetLetter( char c ) { | 1018 | void AddressbookWindow::slotSetLetter( char c ) { |
1019 | 1019 | ||
1020 | m_abView->setShowByLetter( c, m_config.letterPickerSearch() ); | 1020 | m_abView->setShowByLetter( c, m_config.letterPickerSearch() ); |
1021 | 1021 | ||
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | 1024 | ||
1025 | void AddressbookWindow::populateCategories() | 1025 | void AddressbookWindow::populateCategories() |
1026 | { | 1026 | { |
1027 | catMenu->clear(); | 1027 | catMenu->clear(); |
1028 | 1028 | ||
1029 | int id, rememberId; | 1029 | int id, rememberId; |
1030 | id = 1; | 1030 | id = 1; |
1031 | rememberId = 0; | 1031 | rememberId = 0; |
1032 | 1032 | ||
1033 | catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ ); | 1033 | catMenu->insertItem( Resource::loadPixmap( "addressbook/listview" ), tr( "List" ), id++ ); |
1034 | catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ ); | 1034 | catMenu->insertItem( Resource::loadPixmap( "addressbook/cardview" ), tr( "Cards" ), id++ ); |
1035 | // catMenu->insertItem( tr( "Personal" ), id++ ); | 1035 | // catMenu->insertItem( tr( "Personal" ), id++ ); |
1036 | catMenu->insertSeparator(); | 1036 | catMenu->insertSeparator(); |
1037 | 1037 | ||
1038 | catMenu->insertItem( tr( "All" ), id++ ); | 1038 | catMenu->insertItem( tr( "All" ), id++ ); |
1039 | QStringList categories = m_abView->categories(); | 1039 | QStringList categories = m_abView->categories(); |
1040 | categories.append( tr( "Unfiled" ) ); | 1040 | categories.append( tr( "Unfiled" ) ); |
1041 | for ( QStringList::Iterator it = categories.begin(); | 1041 | for ( QStringList::Iterator it = categories.begin(); |
1042 | it != categories.end(); ++it ) { | 1042 | it != categories.end(); ++it ) { |
1043 | catMenu->insertItem( *it, id ); | 1043 | catMenu->insertItem( *it, id ); |
1044 | if ( *it == m_abView -> showCategory() ) | 1044 | if ( *it == m_abView -> showCategory() ) |
1045 | rememberId = id; | 1045 | rememberId = id; |
1046 | ++id; | 1046 | ++id; |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | 1049 | ||
1050 | if ( m_abView -> showCategory().isEmpty() ) { | 1050 | if ( m_abView -> showCategory().isEmpty() ) { |
1051 | slotSetCategory( 3 ); | 1051 | slotSetCategory( 3 ); |
1052 | } | 1052 | } |
1053 | else { | 1053 | else { |
1054 | slotSetCategory( rememberId ); | 1054 | slotSetCategory( rememberId ); |
1055 | } | 1055 | } |
1056 | } | 1056 | } |
1057 | 1057 | ||