summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kaddressbookmain.cpp
Unidiff
Diffstat (limited to 'kaddressbook/kaddressbookmain.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kaddressbookmain.cpp19
1 files changed, 1 insertions, 18 deletions
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp
index 92c32ca..8ebb93a 100644
--- a/kaddressbook/kaddressbookmain.cpp
+++ b/kaddressbook/kaddressbookmain.cpp
@@ -1,293 +1,276 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 1999 Don Sanders <dsanders@kde.org> 3 Copyright (c) 1999 Don Sanders <dsanders@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifdef KAB_EMBEDDED 24#ifdef KAB_EMBEDDED
25#include "kabprefs.h" 25#include "kabprefs.h"
26#include <kglobal.h> 26#include <kglobal.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qtoolbar.h> 28#include <qtoolbar.h>
29#include <qapplication.h> 29#include <qapplication.h>
30#else //KAB_EMBEDDED 30#else //KAB_EMBEDDED
31#include <kedittoolbar.h> 31#include <kedittoolbar.h>
32#include <kkeydialog.h> 32#include <kkeydialog.h>
33#include <kmessagebox.h> 33#include <kmessagebox.h>
34#include <kstatusbar.h> 34#include <kstatusbar.h>
35#endif //KAB_EMBEDDED 35#endif //KAB_EMBEDDED
36#include <klocale.h> 36#include <klocale.h>
37 37
38#include "kabcore.h" 38#include "kabcore.h"
39#include "kaddressbookmain.h" 39#include "kaddressbookmain.h"
40#include "kactioncollection.h" 40#include "kactioncollection.h"
41 41
42#ifdef KAB_EMBEDDED 42#ifdef KAB_EMBEDDED
43KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" ) 43KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" )
44#else //KAB_EMBEDDED 44#else //KAB_EMBEDDED
45//MOC_SKIP_BEGIN 45//MOC_SKIP_BEGIN
46KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) 46KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 )
47//MOC_SKIP_END 47//MOC_SKIP_END
48#endif //KAB_EMBEDDED 48#endif //KAB_EMBEDDED
49{ 49{
50 50
51 setIcon(SmallIcon( "ka24" ) ); 51 setIcon(SmallIcon( "ka24" ) );
52#if 0 52#if 0
53 //US for embedded systems, create the toolbar before we initiate KABCore. 53 //US for embedded systems, create the toolbar before we initiate KABCore.
54 // KABCore will fill the toolbar with menues and icons 54 // KABCore will fill the toolbar with menues and icons
55 QMainWindow::ToolBarDock tbd; 55 QMainWindow::ToolBarDock tbd;
56 tbd = Top; 56 tbd = Top;
57 iconToolBar = new QToolBar( this ); 57 iconToolBar = new QToolBar( this );
58 addToolBar (iconToolBar , tbd ); 58 addToolBar (iconToolBar , tbd );
59 iconToolBar->setHorizontalStretchable(true); 59 iconToolBar->setHorizontalStretchable(true);
60//US iconToolBar->setWidth(300); 60//US iconToolBar->setWidth(300);
61#endif // 0 61#endif // 0
62 62
63 mCore = new KABCore( this, true, this ); 63 mCore = new KABCore( this, true, this );
64 64
65#ifdef KAB_EMBEDDED 65#ifdef KAB_EMBEDDED
66 setCaption( i18n( "KAddressbook/Pi" ) ); 66 setCaption( i18n( "KAddressbook/Pi" ) );
67#else //KAB_EMBEDDED 67#else //KAB_EMBEDDED
68 setCaption( i18n( "Address Book Browser" ) ); 68 setCaption( i18n( "Address Book Browser" ) );
69#endif //KAB_EMBEDDED 69#endif //KAB_EMBEDDED
70 70
71 //mCore->restoreSettings(); 71 //mCore->restoreSettings();
72 72
73 initActions(); 73 initActions();
74 74
75 setCentralWidget( mCore ); 75 setCentralWidget( mCore );
76 76
77//US statusBar()->show(); 77//US statusBar()->show();
78 78
79#ifndef KAB_EMBEDDED 79#ifndef KAB_EMBEDDED
80 setStandardToolBarMenuEnabled(true); 80 setStandardToolBarMenuEnabled(true);
81 81
82 createGUI( "kaddressbookui.rc", false ); 82 createGUI( "kaddressbookui.rc", false );
83 83
84 84
85#endif //KAB_EMBEDDED 85#endif //KAB_EMBEDDED
86 setAutoSaveSettings(); 86 setAutoSaveSettings();
87 qApp->processEvents(); 87 qApp->processEvents();
88 mCore->restoreSettings(); 88 mCore->restoreSettings();
89} 89}
90 90
91KAddressBookMain::~KAddressBookMain() 91KAddressBookMain::~KAddressBookMain()
92{ 92{
93 // mCore->saveSettings(); 93 // mCore->saveSettings();
94} 94}
95#ifndef DESKTOP_VERSION 95
96void KAddressBookMain::show ()
97{
98 static bool block = false;
99 if( block ) {
100 QWidget::show();
101 return;
102 } else {
103 block = true ;
104 QWidget::showFullScreen();
105 }
106 int min = 20;
107 if ( QApplication::desktop()->width() > 320 )
108 min += 20;
109 setGeometry( 0,0,QApplication::desktop()->width(), QApplication::desktop()->height() - min );
110 block = false;
111}
112#endif
113void KAddressBookMain::showMinimized () 96void KAddressBookMain::showMinimized ()
114{ 97{
115 QWidget::showMinimized () ; 98 QWidget::showMinimized () ;
116} 99}
117void KAddressBookMain::addEmail( QString addr ) 100void KAddressBookMain::addEmail( QString addr )
118{ 101{
119 mCore->addEmail( addr ); 102 mCore->addEmail( addr );
120} 103}
121 104
122#ifndef KAB_EMBEDDED 105#ifndef KAB_EMBEDDED
123ASYNC KAddressBookMain::showContactEditor( QString uid ) 106ASYNC KAddressBookMain::showContactEditor( QString uid )
124{ 107{
125 mCore->editContact( uid ); 108 mCore->editContact( uid );
126} 109}
127#endif //KAB_EMBEDDED 110#endif //KAB_EMBEDDED
128void KAddressBookMain::newContact() 111void KAddressBookMain::newContact()
129{ 112{
130 mCore->newContact(); 113 mCore->newContact();
131} 114}
132 115
133QString KAddressBookMain::getNameByPhone( QString phone ) 116QString KAddressBookMain::getNameByPhone( QString phone )
134{ 117{
135 return mCore->getNameByPhone( phone ); 118 return mCore->getNameByPhone( phone );
136} 119}
137 120
138void KAddressBookMain::save() 121void KAddressBookMain::save()
139{ 122{
140 mCore->save(); 123 mCore->save();
141} 124}
142 125
143void KAddressBookMain::exit() 126void KAddressBookMain::exit()
144{ 127{
145 close( ); 128 close( );
146} 129}
147 130
148void KAddressBookMain::saveProperties( KConfig* ) 131void KAddressBookMain::saveProperties( KConfig* )
149{ 132{
150} 133}
151 134
152void KAddressBookMain::readProperties( KConfig* ) 135void KAddressBookMain::readProperties( KConfig* )
153{ 136{
154} 137}
155 138
156void KAddressBookMain::initActions() 139void KAddressBookMain::initActions()
157{ 140{
158#ifndef KAB_EMBEDDED 141#ifndef KAB_EMBEDDED
159 KStdAction::quit( this, SLOT( close() ), actionCollection() ); 142 KStdAction::quit( this, SLOT( close() ), actionCollection() );
160 KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); 143 KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() );
161#else //KAB_EMBEDDED 144#else //KAB_EMBEDDED
162 //US: transfered the setup of the actions into KABCore 145 //US: transfered the setup of the actions into KABCore
163#endif //KAB_EMBEDDED 146#endif //KAB_EMBEDDED
164 147
165 148
166} 149}
167 150
168//US new method to setup menues and toolbars on embedded systems 151//US new method to setup menues and toolbars on embedded systems
169#ifdef KAB_EMBEDDED 152#ifdef KAB_EMBEDDED
170/* 153/*
171QToolBar * KAddressBookMain::getIconToolBar() 154QToolBar * KAddressBookMain::getIconToolBar()
172{ 155{
173 return iconToolBar; 156 return iconToolBar;
174} 157}
175*/ 158*/
176 159
177void KAddressBookMain::createGUI() 160void KAddressBookMain::createGUI()
178{ 161{
179 162
180 163
181 164
182} 165}
183#endif //KAB_EMBEDDED 166#endif //KAB_EMBEDDED
184 167
185void KAddressBookMain::configureToolbars() 168void KAddressBookMain::configureToolbars()
186{ 169{
187#ifndef KAB_EMBEDDED 170#ifndef KAB_EMBEDDED
188 saveMainWindowSettings( KGlobal::config(), "MainWindow" ); 171 saveMainWindowSettings( KGlobal::config(), "MainWindow" );
189 172
190 KEditToolbar dlg( factory() ); 173 KEditToolbar dlg( factory() );
191 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); 174 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) );
192 175
193 dlg.exec(); 176 dlg.exec();
194#else //KAB_EMBEDDED 177#else //KAB_EMBEDDED
195 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); 178 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" );
196#endif //KAB_EMBEDDED 179#endif //KAB_EMBEDDED
197} 180}
198 181
199void KAddressBookMain::slotNewToolbarConfig() 182void KAddressBookMain::slotNewToolbarConfig()
200{ 183{
201#ifndef KAB_EMBEDDED 184#ifndef KAB_EMBEDDED
202 applyMainWindowSettings( KGlobal::config(), "MainWindow" ); 185 applyMainWindowSettings( KGlobal::config(), "MainWindow" );
203#else //KAB_EMBEDDED 186#else //KAB_EMBEDDED
204 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); 187 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" );
205#endif //KAB_EMBEDDED 188#endif //KAB_EMBEDDED
206} 189}
207 190
208void KAddressBookMain::configureKeys() 191void KAddressBookMain::configureKeys()
209{ 192{
210#ifndef KAB_EMBEDDED 193#ifndef KAB_EMBEDDED
211 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); 194 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this );
212#else //KAB_EMBEDDED 195#else //KAB_EMBEDDED
213 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); 196 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" );
214#endif //KAB_EMBEDDED 197#endif //KAB_EMBEDDED
215} 198}
216 199
217void KAddressBookMain::closeEvent( QCloseEvent* ce ) 200void KAddressBookMain::closeEvent( QCloseEvent* ce )
218{ 201{
219 QString mess = i18n( "Close KA/Pi?"); 202 QString mess = i18n( "Close KA/Pi?");
220 if ( mCore->modified() ) 203 if ( mCore->modified() )
221 mess += i18n( "\n\nChanges will be saved!"); 204 mess += i18n( "\n\nChanges will be saved!");
222 else 205 else
223 mess += i18n( "\n\nNo unsaved changes detected!\nNothing will be saved!"); 206 mess += i18n( "\n\nNo unsaved changes detected!\nNothing will be saved!");
224 207
225 switch( QMessageBox::information( this, "KA/Pi", mess , 208 switch( QMessageBox::information( this, "KA/Pi", mess ,
226 i18n("Yes!"), i18n("No"), 0, 0 ) ) { 209 i18n("Yes!"), i18n("No"), 0, 0 ) ) {
227 case 0: 210 case 0:
228 211
229 break; 212 break;
230 case 1: 213 case 1:
231 return; 214 return;
232 break; 215 break;
233 case 2: 216 case 2:
234 return; 217 return;
235 break; 218 break;
236 219
237 default: 220 default:
238 return; 221 return;
239 break; 222 break;
240 } 223 }
241 224
242#if 0 225#if 0
243 226
244 if ( mCore->modified() ) { 227 if ( mCore->modified() ) {
245 QString text = i18n( "The address book has been modified.\nDo you want to save your changes?" ); 228 QString text = i18n( "The address book has been modified.\nDo you want to save your changes?" );
246 229
247#ifndef KAB_EMBEDDED 230#ifndef KAB_EMBEDDED
248 int ret = KMessageBox::warningYesNoCancel( this, text, "", 231 int ret = KMessageBox::warningYesNoCancel( this, text, "",
249 KStdGuiItem::yes(), 232 KStdGuiItem::yes(),
250 KStdGuiItem::no(), "AskForSave" ); 233 KStdGuiItem::no(), "AskForSave" );
251 switch ( ret ) { 234 switch ( ret ) {
252 case KMessageBox::Yes: 235 case KMessageBox::Yes:
253 save(); 236 save();
254 break; 237 break;
255 case KMessageBox::No: 238 case KMessageBox::No:
256 return true; 239 return true;
257 break; 240 break;
258 default: //cancel 241 default: //cancel
259 return ; 242 return ;
260 break; 243 break;
261 } 244 }
262 245
263#else //KAB_EMBEDDED 246#else //KAB_EMBEDDED
264 switch( QMessageBox::information( this, "KA/Pi", 247 switch( QMessageBox::information( this, "KA/Pi",
265 text, 248 text,
266 i18n("Yes!"), i18n("No"), 0, 0 ) ) { 249 i18n("Yes!"), i18n("No"), 0, 0 ) ) {
267 case 0: 250 case 0:
268 save(); 251 save();
269 break; 252 break;
270 case 1: 253 case 1:
271 break; 254 break;
272 case 2: 255 case 2:
273 return; 256 return;
274 default: 257 default:
275 return; 258 return;
276 break; 259 break;
277 } 260 }
278#endif //KAB_EMBEDDED 261#endif //KAB_EMBEDDED
279 } 262 }
280 263
281#endif 264#endif
282 265
283 save(); 266 save();
284 mCore->saveSettings(); 267 mCore->saveSettings();
285 KABPrefs::instance()->writeConfig(); 268 KABPrefs::instance()->writeConfig();
286 ce->accept(); 269 ce->accept();
287 270
288} 271}
289 272
290#ifndef KAB_EMBEDDED 273#ifndef KAB_EMBEDDED
291#include "kaddressbookmain.moc" 274#include "kaddressbookmain.moc"
292#endif //KAB_EMBEDDED 275#endif //KAB_EMBEDDED
293 276