kaddressbook

kaddressbookmain.cpp
1/*
2 This file is part of KAddressbook.
3 Copyright (c) 1999 Don Sanders <dsanders@kde.org>
4
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
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
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
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of TQt, and distribute the resulting executable,
21 without including the source code for TQt in the source distribution.
22*/
23
24#include <kedittoolbar.h>
25#include <kkeydialog.h>
26#include <tdelocale.h>
27#include <tdemessagebox.h>
28#include <kstatusbar.h>
29
30#include <libtdepim/statusbarprogresswidget.h>
31#include <libtdepim/progressdialog.h>
32
33#include "kabcore.h"
34
35#include "kaddressbookmain.h"
36
37KAddressBookMain::KAddressBookMain( const TQString &file )
38 : DCOPObject( "KAddressBookIface" ), TDEMainWindow( 0 )
39{
40 // Set this to be the group leader for all subdialogs - this means
41 // modal subdialogs will only affect this dialog, not the other windows
42 setWFlags( getWFlags() | WGroupLeader );
43
44 setCaption( i18n( "Address Book Browser" ) );
45
46 mCore = new KABCore( this, true, this, file );
47 mCore->restoreSettings();
48
49 initActions();
50
51 setCentralWidget( mCore->widget() );
52
53 statusBar()->show();
54 statusBar()->insertItem( "", 1 );
55
56 KPIM::ProgressDialog *progressDialog = new KPIM::ProgressDialog( statusBar(),
57 this );
58 progressDialog->hide();
59
60 KPIM::StatusbarProgressWidget *progressWidget;
61 progressWidget = new KPIM::StatusbarProgressWidget( progressDialog,
62 statusBar() );
63 progressWidget->show();
64
65 statusBar()->addWidget( progressWidget, 0, true );
66
67 mCore->setStatusBar( statusBar() );
68
69 setStandardToolBarMenuEnabled( true );
70
71 createGUI( "kaddressbookui.rc", false );
72
73 resize( 400, 300 ); // initial size
74 setAutoSaveSettings();
75}
76
77KAddressBookMain::~KAddressBookMain()
78{
79 mCore->saveSettings();
80}
81
82void KAddressBookMain::addEmail( TQString addr )
83{
84 mCore->addEmail( addr );
85}
86
87void KAddressBookMain::importVCard( const KURL& url )
88{
89 mCore->importVCard( url );
90}
91
92void KAddressBookMain::importVCardFromData( const TQString& vCard )
93{
94 mCore->importVCardFromData( vCard );
95}
96
97ASYNC KAddressBookMain::showContactEditor( TQString uid )
98{
99 mCore->editContact( uid );
100}
101
102void KAddressBookMain::newDistributionList()
103{
104 mCore->newDistributionList();
105}
106
107void KAddressBookMain::newContact()
108{
109 mCore->newContact();
110}
111
112TQString KAddressBookMain::getNameByPhone( TQString phone )
113{
114 return mCore->getNameByPhone( phone );
115}
116
117void KAddressBookMain::save()
118{
119 mCore->save();
120}
121
122void KAddressBookMain::exit()
123{
124 close();
125}
126
127bool KAddressBookMain::handleCommandLine()
128{
129 return mCore->handleCommandLine( this );
130}
131
132void KAddressBookMain::syncAllResources()
133{
134 mCore->save();
135 mCore->load();
136}
137
139{
140}
141
143{
144}
145
146bool KAddressBookMain::queryClose()
147{
148 return mCore->queryClose();
149}
150
151void KAddressBookMain::initActions()
152{
153 KStdAction::quit( this, TQ_SLOT( close() ), actionCollection() );
154
155 TDEAction *action;
156 action = KStdAction::keyBindings( this, TQ_SLOT( configureKeyBindings() ), actionCollection() );
157 action->setWhatsThis( i18n( "You will be presented with a dialog, where you can configure the application wide shortcuts." ) );
158
159 KStdAction::configureToolbars( this, TQ_SLOT( configureToolbars() ), actionCollection() );
160}
161
162void KAddressBookMain::configureKeyBindings()
163{
164 KKeyDialog::configure( actionCollection(), this );
165}
166
167void KAddressBookMain::loadProfile( const TQString& )
168{
169}
170
171void KAddressBookMain::saveToProfile( const TQString& ) const
172{
173}
174
175void KAddressBookMain::configureToolbars()
176{
177 saveMainWindowSettings( TDEGlobal::config(), "MainWindow" );
178
179 KEditToolbar edit( factory() );
180 connect( &edit, TQ_SIGNAL( newToolbarConfig() ),
181 this, TQ_SLOT( newToolbarConfig() ) );
182
183 edit.exec();
184}
185
186void KAddressBookMain::newToolbarConfig()
187{
188 createGUI( "kaddressbookui.rc", false );
189 applyMainWindowSettings( TDEGlobal::config(), "MainWindow" );
190}
191
192#include "kaddressbookmain.moc"
void saveProperties(TDEConfig *)
This function is called when it is time for the app to save its properties for session management pur...
void readProperties(TDEConfig *)
This function is called when this app is restored.