Diffstat (limited to 'kaddressbook/kaddressbookmain.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/kaddressbookmain.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp index f48f214..2832257 100644 --- a/kaddressbook/kaddressbookmain.cpp +++ b/kaddressbook/kaddressbookmain.cpp | |||
@@ -1,240 +1,239 @@ | |||
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 |
43 | KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" ) | 43 | KAddressBookMain::KAddressBookMain() : KMainWindow( 0, "adrressbook" ) |
44 | #else //KAB_EMBEDDED | 44 | #else //KAB_EMBEDDED |
45 | //MOC_SKIP_BEGIN | 45 | //MOC_SKIP_BEGIN |
46 | KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) | 46 | KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 ) |
47 | //MOC_SKIP_END | 47 | //MOC_SKIP_END |
48 | #endif //KAB_EMBEDDED | 48 | #endif //KAB_EMBEDDED |
49 | { | 49 | { |
50 | |||
51 | setIcon(SmallIcon( "ka24" ) ); | 50 | setIcon(SmallIcon( "ka24" ) ); |
52 | #if 0 | 51 | #if 0 |
53 | //US for embedded systems, create the toolbar before we initiate KABCore. | 52 | //US for embedded systems, create the toolbar before we initiate KABCore. |
54 | // KABCore will fill the toolbar with menues and icons | 53 | // KABCore will fill the toolbar with menues and icons |
55 | QMainWindow::ToolBarDock tbd; | 54 | QMainWindow::ToolBarDock tbd; |
56 | tbd = Top; | 55 | tbd = Top; |
57 | iconToolBar = new QToolBar( this ); | 56 | iconToolBar = new QToolBar( this ); |
58 | addToolBar (iconToolBar , tbd ); | 57 | addToolBar (iconToolBar , tbd ); |
59 | iconToolBar->setHorizontalStretchable(true); | 58 | iconToolBar->setHorizontalStretchable(true); |
60 | //US iconToolBar->setWidth(300); | 59 | //US iconToolBar->setWidth(300); |
61 | #endif // 0 | 60 | #endif // 0 |
62 | 61 | ||
63 | mCore = new KABCore( this, true, this ); | 62 | mCore = new KABCore( this, true, this ); |
64 | 63 | ||
65 | #ifdef KAB_EMBEDDED | 64 | #ifdef KAB_EMBEDDED |
66 | setCaption( i18n( "KAddressbook/Pi" ) ); | 65 | setCaption( i18n( "KAddressbook/Pi" ) ); |
67 | #else //KAB_EMBEDDED | 66 | #else //KAB_EMBEDDED |
68 | setCaption( i18n( "Address Book Browser" ) ); | 67 | setCaption( i18n( "Address Book Browser" ) ); |
69 | #endif //KAB_EMBEDDED | 68 | #endif //KAB_EMBEDDED |
70 | 69 | ||
71 | //mCore->restoreSettings(); | 70 | //mCore->restoreSettings(); |
72 | 71 | ||
73 | initActions(); | 72 | initActions(); |
74 | 73 | ||
75 | setCentralWidget( mCore ); | 74 | setCentralWidget( mCore ); |
76 | 75 | ||
77 | //US statusBar()->show(); | 76 | //US statusBar()->show(); |
78 | 77 | ||
79 | #ifndef KAB_EMBEDDED | 78 | #ifndef KAB_EMBEDDED |
80 | setStandardToolBarMenuEnabled(true); | 79 | setStandardToolBarMenuEnabled(true); |
81 | 80 | ||
82 | createGUI( "kaddressbookui.rc", false ); | 81 | createGUI( "kaddressbookui.rc", false ); |
83 | 82 | ||
84 | 83 | ||
85 | #endif //KAB_EMBEDDED | 84 | #endif //KAB_EMBEDDED |
86 | setAutoSaveSettings(); | 85 | setAutoSaveSettings(); |
87 | qApp->processEvents(); | 86 | qApp->processEvents(); |
88 | mCore->restoreSettings(); | 87 | mCore->restoreSettings(); |
89 | } | 88 | } |
90 | 89 | ||
91 | KAddressBookMain::~KAddressBookMain() | 90 | KAddressBookMain::~KAddressBookMain() |
92 | { | 91 | { |
93 | // mCore->saveSettings(); | 92 | // mCore->saveSettings(); |
94 | } | 93 | } |
95 | 94 | ||
96 | void KAddressBookMain::showMinimized () | 95 | void KAddressBookMain::showMinimized () |
97 | { | 96 | { |
98 | QWidget::showMinimized () ; | 97 | QWidget::showMinimized () ; |
99 | } | 98 | } |
100 | void KAddressBookMain::addEmail( QString addr ) | 99 | void KAddressBookMain::addEmail( QString addr ) |
101 | { | 100 | { |
102 | mCore->addEmail( addr ); | 101 | mCore->addEmail( addr ); |
103 | } | 102 | } |
104 | 103 | ||
105 | #ifndef KAB_EMBEDDED | 104 | #ifndef KAB_EMBEDDED |
106 | ASYNC KAddressBookMain::showContactEditor( QString uid ) | 105 | ASYNC KAddressBookMain::showContactEditor( QString uid ) |
107 | { | 106 | { |
108 | mCore->editContact( uid ); | 107 | mCore->editContact( uid ); |
109 | } | 108 | } |
110 | #endif //KAB_EMBEDDED | 109 | #endif //KAB_EMBEDDED |
111 | void KAddressBookMain::newContact() | 110 | void KAddressBookMain::newContact() |
112 | { | 111 | { |
113 | mCore->newContact(); | 112 | mCore->newContact(); |
114 | } | 113 | } |
115 | 114 | ||
116 | QString KAddressBookMain::getNameByPhone( QString phone ) | 115 | QString KAddressBookMain::getNameByPhone( QString phone ) |
117 | { | 116 | { |
118 | return mCore->getNameByPhone( phone ); | 117 | return mCore->getNameByPhone( phone ); |
119 | } | 118 | } |
120 | 119 | ||
121 | void KAddressBookMain::save() | 120 | void KAddressBookMain::save() |
122 | { | 121 | { |
123 | mCore->save(); | 122 | mCore->save(); |
124 | } | 123 | } |
125 | 124 | ||
126 | void KAddressBookMain::exit() | 125 | void KAddressBookMain::exit() |
127 | { | 126 | { |
128 | close( ); | 127 | close( ); |
129 | } | 128 | } |
130 | 129 | ||
131 | void KAddressBookMain::saveProperties( KConfig* ) | 130 | void KAddressBookMain::saveProperties( KConfig* ) |
132 | { | 131 | { |
133 | } | 132 | } |
134 | 133 | ||
135 | void KAddressBookMain::readProperties( KConfig* ) | 134 | void KAddressBookMain::readProperties( KConfig* ) |
136 | { | 135 | { |
137 | } | 136 | } |
138 | 137 | ||
139 | void KAddressBookMain::initActions() | 138 | void KAddressBookMain::initActions() |
140 | { | 139 | { |
141 | #ifndef KAB_EMBEDDED | 140 | #ifndef KAB_EMBEDDED |
142 | KStdAction::quit( this, SLOT( close() ), actionCollection() ); | 141 | KStdAction::quit( this, SLOT( close() ), actionCollection() ); |
143 | KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); | 142 | KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); |
144 | #else //KAB_EMBEDDED | 143 | #else //KAB_EMBEDDED |
145 | //US: transfered the setup of the actions into KABCore | 144 | //US: transfered the setup of the actions into KABCore |
146 | #endif //KAB_EMBEDDED | 145 | #endif //KAB_EMBEDDED |
147 | 146 | ||
148 | 147 | ||
149 | } | 148 | } |
150 | 149 | ||
151 | //US new method to setup menues and toolbars on embedded systems | 150 | //US new method to setup menues and toolbars on embedded systems |
152 | #ifdef KAB_EMBEDDED | 151 | #ifdef KAB_EMBEDDED |
153 | /* | 152 | /* |
154 | QToolBar * KAddressBookMain::getIconToolBar() | 153 | QToolBar * KAddressBookMain::getIconToolBar() |
155 | { | 154 | { |
156 | return iconToolBar; | 155 | return iconToolBar; |
157 | } | 156 | } |
158 | */ | 157 | */ |
159 | 158 | ||
160 | void KAddressBookMain::createGUI() | 159 | void KAddressBookMain::createGUI() |
161 | { | 160 | { |
162 | 161 | ||
163 | 162 | ||
164 | 163 | ||
165 | } | 164 | } |
166 | #endif //KAB_EMBEDDED | 165 | #endif //KAB_EMBEDDED |
167 | 166 | ||
168 | void KAddressBookMain::configureToolbars() | 167 | void KAddressBookMain::configureToolbars() |
169 | { | 168 | { |
170 | #ifndef KAB_EMBEDDED | 169 | #ifndef KAB_EMBEDDED |
171 | saveMainWindowSettings( KGlobal::config(), "MainWindow" ); | 170 | saveMainWindowSettings( KGlobal::config(), "MainWindow" ); |
172 | 171 | ||
173 | KEditToolbar dlg( factory() ); | 172 | KEditToolbar dlg( factory() ); |
174 | connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); | 173 | connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); |
175 | 174 | ||
176 | dlg.exec(); | 175 | dlg.exec(); |
177 | #else //KAB_EMBEDDED | 176 | #else //KAB_EMBEDDED |
178 | qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); | 177 | qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); |
179 | #endif //KAB_EMBEDDED | 178 | #endif //KAB_EMBEDDED |
180 | } | 179 | } |
181 | 180 | ||
182 | void KAddressBookMain::slotNewToolbarConfig() | 181 | void KAddressBookMain::slotNewToolbarConfig() |
183 | { | 182 | { |
184 | #ifndef KAB_EMBEDDED | 183 | #ifndef KAB_EMBEDDED |
185 | applyMainWindowSettings( KGlobal::config(), "MainWindow" ); | 184 | applyMainWindowSettings( KGlobal::config(), "MainWindow" ); |
186 | #else //KAB_EMBEDDED | 185 | #else //KAB_EMBEDDED |
187 | qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); | 186 | qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); |
188 | #endif //KAB_EMBEDDED | 187 | #endif //KAB_EMBEDDED |
189 | } | 188 | } |
190 | 189 | ||
191 | void KAddressBookMain::configureKeys() | 190 | void KAddressBookMain::configureKeys() |
192 | { | 191 | { |
193 | #ifndef KAB_EMBEDDED | 192 | #ifndef KAB_EMBEDDED |
194 | KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); | 193 | KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); |
195 | #else //KAB_EMBEDDED | 194 | #else //KAB_EMBEDDED |
196 | qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); | 195 | qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); |
197 | #endif //KAB_EMBEDDED | 196 | #endif //KAB_EMBEDDED |
198 | } | 197 | } |
199 | 198 | ||
200 | void KAddressBookMain::closeEvent( QCloseEvent* ce ) | 199 | void KAddressBookMain::closeEvent( QCloseEvent* ce ) |
201 | { | 200 | { |
202 | bool mModified = mCore->modified(); | 201 | bool mModified = mCore->modified(); |
203 | bool mAskForQuit = KABPrefs::instance()->mAskForQuit; | 202 | bool mAskForQuit = KABPrefs::instance()->mAskForQuit; |
204 | 203 | ||
205 | QString mess = i18n( "Close KA/Pi?"); | 204 | QString mess = i18n( "Close KA/Pi?"); |
206 | if ( mModified == true ) | 205 | if ( mModified == true ) |
207 | mess += i18n( "\nChanges will be saved!"); | 206 | mess += i18n( "\nChanges will be saved!"); |
208 | else | 207 | else |
209 | mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); | 208 | mess += i18n( "\nNo unsaved changes detected!\nNothing will be saved!"); |
210 | 209 | ||
211 | bool mQuit = true; | 210 | bool mQuit = true; |
212 | 211 | ||
213 | 212 | ||
214 | if (mAskForQuit) | 213 | if (mAskForQuit) |
215 | { | 214 | { |
216 | 215 | ||
217 | int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); | 216 | int res = QMessageBox::information( this, "KA/Pi", mess , i18n("Yes!"), i18n("No"), 0, 0 ); |
218 | if (res == 0) | 217 | if (res == 0) |
219 | mQuit = true; | 218 | mQuit = true; |
220 | else | 219 | else |
221 | mQuit = false; | 220 | mQuit = false; |
222 | } | 221 | } |
223 | 222 | ||
224 | if (mQuit == false) | 223 | if (mQuit == false) |
225 | return; | 224 | return; |
226 | 225 | ||
227 | if (mModified == true) | 226 | if (mModified == true) |
228 | { | 227 | { |
229 | save(); | 228 | save(); |
230 | mCore->saveSettings(); | 229 | mCore->saveSettings(); |
231 | KABPrefs::instance()->writeConfig(); | 230 | KABPrefs::instance()->writeConfig(); |
232 | } | 231 | } |
233 | 232 | ||
234 | ce->accept(); | 233 | ce->accept(); |
235 | } | 234 | } |
236 | 235 | ||
237 | #ifndef KAB_EMBEDDED | 236 | #ifndef KAB_EMBEDDED |
238 | #include "kaddressbookmain.moc" | 237 | #include "kaddressbookmain.moc" |
239 | #endif //KAB_EMBEDDED | 238 | #endif //KAB_EMBEDDED |
240 | 239 | ||