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