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