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