summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kaddressbookmain.cpp
Unidiff
Diffstat (limited to 'kaddressbook/kaddressbookmain.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kaddressbookmain.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp
index f48f214..8c4ca09 100644
--- a/kaddressbook/kaddressbookmain.cpp
+++ b/kaddressbook/kaddressbookmain.cpp
@@ -1,240 +1,250 @@
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 95void KAddressBookMain::recieve( const QCString& cmsg, const QByteArray& data )
96{
97 qDebug("KA: QCOP message received: %s ", cmsg.data() );
98 if ( cmsg == "setDocument(QString)" ) {
99 QDataStream stream( data, IO_ReadOnly );
100 QString fileName;
101 stream >> fileName;
102 mCore->recieve( fileName );
103 return;
104 }
105}
96void KAddressBookMain::showMinimized () 106void KAddressBookMain::showMinimized ()
97{ 107{
98 QWidget::showMinimized () ; 108 QWidget::showMinimized () ;
99} 109}
100void KAddressBookMain::addEmail( QString addr ) 110void KAddressBookMain::addEmail( QString addr )
101{ 111{
102 mCore->addEmail( addr ); 112 mCore->addEmail( addr );
103} 113}
104 114
105#ifndef KAB_EMBEDDED 115#ifndef KAB_EMBEDDED
106ASYNC KAddressBookMain::showContactEditor( QString uid ) 116ASYNC KAddressBookMain::showContactEditor( QString uid )
107{ 117{
108 mCore->editContact( uid ); 118 mCore->editContact( uid );
109} 119}
110#endif //KAB_EMBEDDED 120#endif //KAB_EMBEDDED
111void KAddressBookMain::newContact() 121void KAddressBookMain::newContact()
112{ 122{
113 mCore->newContact(); 123 mCore->newContact();
114} 124}
115 125
116QString KAddressBookMain::getNameByPhone( QString phone ) 126QString KAddressBookMain::getNameByPhone( QString phone )
117{ 127{
118 return mCore->getNameByPhone( phone ); 128 return mCore->getNameByPhone( phone );
119} 129}
120 130
121void KAddressBookMain::save() 131void KAddressBookMain::save()
122{ 132{
123 mCore->save(); 133 mCore->save();
124} 134}
125 135
126void KAddressBookMain::exit() 136void KAddressBookMain::exit()
127{ 137{
128 close( ); 138 close( );
129} 139}
130 140
131void KAddressBookMain::saveProperties( KConfig* ) 141void KAddressBookMain::saveProperties( KConfig* )
132{ 142{
133} 143}
134 144
135void KAddressBookMain::readProperties( KConfig* ) 145void KAddressBookMain::readProperties( KConfig* )
136{ 146{
137} 147}
138 148
139void KAddressBookMain::initActions() 149void KAddressBookMain::initActions()
140{ 150{
141#ifndef KAB_EMBEDDED 151#ifndef KAB_EMBEDDED
142 KStdAction::quit( this, SLOT( close() ), actionCollection() ); 152 KStdAction::quit( this, SLOT( close() ), actionCollection() );
143 KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); 153 KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() );
144#else //KAB_EMBEDDED 154#else //KAB_EMBEDDED
145 //US: transfered the setup of the actions into KABCore 155 //US: transfered the setup of the actions into KABCore
146#endif //KAB_EMBEDDED 156#endif //KAB_EMBEDDED
147 157
148 158
149} 159}
150 160
151//US new method to setup menues and toolbars on embedded systems 161//US new method to setup menues and toolbars on embedded systems
152#ifdef KAB_EMBEDDED 162#ifdef KAB_EMBEDDED
153/* 163/*
154QToolBar * KAddressBookMain::getIconToolBar() 164QToolBar * KAddressBookMain::getIconToolBar()
155{ 165{
156 return iconToolBar; 166 return iconToolBar;
157} 167}
158*/ 168*/
159 169
160void KAddressBookMain::createGUI() 170void KAddressBookMain::createGUI()
161{ 171{
162 172
163 173
164 174
165} 175}
166#endif //KAB_EMBEDDED 176#endif //KAB_EMBEDDED
167 177
168void KAddressBookMain::configureToolbars() 178void KAddressBookMain::configureToolbars()
169{ 179{
170#ifndef KAB_EMBEDDED 180#ifndef KAB_EMBEDDED
171 saveMainWindowSettings( KGlobal::config(), "MainWindow" ); 181 saveMainWindowSettings( KGlobal::config(), "MainWindow" );
172 182
173 KEditToolbar dlg( factory() ); 183 KEditToolbar dlg( factory() );
174 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); 184 connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) );
175 185
176 dlg.exec(); 186 dlg.exec();
177#else //KAB_EMBEDDED 187#else //KAB_EMBEDDED
178 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); 188 qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" );
179#endif //KAB_EMBEDDED 189#endif //KAB_EMBEDDED
180} 190}
181 191
182void KAddressBookMain::slotNewToolbarConfig() 192void KAddressBookMain::slotNewToolbarConfig()
183{ 193{
184#ifndef KAB_EMBEDDED 194#ifndef KAB_EMBEDDED
185 applyMainWindowSettings( KGlobal::config(), "MainWindow" ); 195 applyMainWindowSettings( KGlobal::config(), "MainWindow" );
186#else //KAB_EMBEDDED 196#else //KAB_EMBEDDED
187 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); 197 qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" );
188#endif //KAB_EMBEDDED 198#endif //KAB_EMBEDDED
189} 199}
190 200
191void KAddressBookMain::configureKeys() 201void KAddressBookMain::configureKeys()
192{ 202{
193#ifndef KAB_EMBEDDED 203#ifndef KAB_EMBEDDED
194 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); 204 KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this );
195#else //KAB_EMBEDDED 205#else //KAB_EMBEDDED
196 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); 206 qDebug("KAddressBookMain::configureKeys() not implemented by ulf" );
197#endif //KAB_EMBEDDED 207#endif //KAB_EMBEDDED
198} 208}
199 209
200void KAddressBookMain::closeEvent( QCloseEvent* ce ) 210void KAddressBookMain::closeEvent( QCloseEvent* ce )
201{ 211{
202 bool mModified = mCore->modified(); 212 bool mModified = mCore->modified();
203 bool mAskForQuit = KABPrefs::instance()->mAskForQuit; 213 bool mAskForQuit = KABPrefs::instance()->mAskForQuit;
204 214
205 QString mess = i18n( "Close KA/Pi?"); 215 QString mess = i18n( "Close KA/Pi?");
206 if ( mModified == true ) 216 if ( mModified == true )
207 mess += i18n( "\nChanges will be saved!"); 217 mess += i18n( "\nChanges will be saved!");
208 else 218 else
209 mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); 219 mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!");
210 220
211 bool mQuit = true; 221 bool mQuit = true;
212 222
213 223
214 if (mAskForQuit) 224 if (mAskForQuit)
215 { 225 {
216 226
217 int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); 227 int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 );
218 if (res == 0) 228 if (res == 0)
219 mQuit = true; 229 mQuit = true;
220 else 230 else
221 mQuit = false; 231 mQuit = false;
222 } 232 }
223 233
224 if (mQuit == false) 234 if (mQuit == false)
225 return; 235 return;
226 236
227 if (mModified == true) 237 if (mModified == true)
228 { 238 {
229 save(); 239 save();
230 mCore->saveSettings(); 240 mCore->saveSettings();
231 KABPrefs::instance()->writeConfig(); 241 KABPrefs::instance()->writeConfig();
232 } 242 }
233 243
234 ce->accept(); 244 ce->accept();
235} 245}
236 246
237#ifndef KAB_EMBEDDED 247#ifndef KAB_EMBEDDED
238#include "kaddressbookmain.moc" 248#include "kaddressbookmain.moc"
239#endif //KAB_EMBEDDED 249#endif //KAB_EMBEDDED
240 250