-rw-r--r-- | kaddressbook/kabcore.cpp | 46 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 2 | ||||
-rw-r--r-- | kaddressbook/kaddressbookmain.cpp | 19 | ||||
-rw-r--r-- | kaddressbook/kaddressbookmain.h | 4 | ||||
-rw-r--r-- | kaddressbook/mainembedded.cpp | 8 |
5 files changed, 41 insertions, 38 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 3e578bc..70ab6b7 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,1571 +1,1599 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@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 | #include "kabcore.h" | 24 | #include "kabcore.h" |
25 | 25 | ||
26 | #include <stdaddressbook.h> | 26 | #include <stdaddressbook.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
30 | #include <qclipboard.h> | 30 | #include <qclipboard.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qapplicaton.h> | 33 | #include <qapplicaton.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | #include <qvbox.h> | 36 | #include <qvbox.h> |
37 | #include <kabc/addresseelist.h> | 37 | #include <kabc/addresseelist.h> |
38 | #include <kabc/errorhandler.h> | 38 | #include <kabc/errorhandler.h> |
39 | #include <kabc/resource.h> | 39 | #include <kabc/resource.h> |
40 | #include <kabc/vcardconverter.h> | 40 | #include <kabc/vcardconverter.h> |
41 | #include <kapplication.h> | 41 | #include <kapplication.h> |
42 | #include <kactionclasses.h> | 42 | #include <kactionclasses.h> |
43 | #include <kcmultidialog.h> | 43 | #include <kcmultidialog.h> |
44 | #include <kdebug.h> | 44 | #include <kdebug.h> |
45 | #include <kdeversion.h> | 45 | #include <kdeversion.h> |
46 | #include <kkeydialog.h> | 46 | #include <kkeydialog.h> |
47 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> |
48 | #include <kprinter.h> | 48 | #include <kprinter.h> |
49 | #include <kprotocolinfo.h> | 49 | #include <kprotocolinfo.h> |
50 | #include <kresources/selectdialog.h> | 50 | #include <kresources/selectdialog.h> |
51 | #include <kstandarddirs.h> | 51 | #include <kstandarddirs.h> |
52 | #include <ktempfile.h> | 52 | #include <ktempfile.h> |
53 | #include <kxmlguiclient.h> | 53 | #include <kxmlguiclient.h> |
54 | #include <kaboutdata.h> | 54 | #include <kaboutdata.h> |
55 | #include <libkdepim/categoryselectdialog.h> | 55 | #include <libkdepim/categoryselectdialog.h> |
56 | 56 | ||
57 | #include "addresseeutil.h" | 57 | #include "addresseeutil.h" |
58 | #include "addresseeeditordialog.h" | 58 | #include "addresseeeditordialog.h" |
59 | #include "extensionmanager.h" | 59 | #include "extensionmanager.h" |
60 | #include "kstdaction.h" | 60 | #include "kstdaction.h" |
61 | #include "kaddressbookservice.h" | 61 | #include "kaddressbookservice.h" |
62 | #include "ldapsearchdialog.h" | 62 | #include "ldapsearchdialog.h" |
63 | #include "printing/printingwizard.h" | 63 | #include "printing/printingwizard.h" |
64 | #else // KAB_EMBEDDED | 64 | #else // KAB_EMBEDDED |
65 | 65 | ||
66 | #include "KDGanttMinimizeSplitter.h" | 66 | #include "KDGanttMinimizeSplitter.h" |
67 | #include "kaddressbookmain.h" | 67 | #include "kaddressbookmain.h" |
68 | #include "kactioncollection.h" | 68 | #include "kactioncollection.h" |
69 | #include <qapp.h> | 69 | #include <qapp.h> |
70 | #include <qmenubar.h> | 70 | #include <qmenubar.h> |
71 | //#include <qtoolbar.h> | 71 | //#include <qtoolbar.h> |
72 | #include <qmessagebox.h> | 72 | #include <qmessagebox.h> |
73 | #include <kdebug.h> | 73 | #include <kdebug.h> |
74 | #include <kiconloader.h> // needed for SmallIcon | 74 | #include <kiconloader.h> // needed for SmallIcon |
75 | #include <kresources/kcmkresources.h> | 75 | #include <kresources/kcmkresources.h> |
76 | #include <ktoolbar.h> | 76 | #include <ktoolbar.h> |
77 | 77 | ||
78 | #include <kcmkabconfig.h> | 78 | #include <kcmkabconfig.h> |
79 | 79 | ||
80 | //US#include <qpe/resource.h> // needed for Resource::loadPixmap | 80 | //US#include <qpe/resource.h> // needed for Resource::loadPixmap |
81 | //#include <qlabel.h> | 81 | //#include <qlabel.h> |
82 | #endif // KAB_EMBEDDED | 82 | #endif // KAB_EMBEDDED |
83 | #include <kcmkabconfig.h> | 83 | #include <kcmkabconfig.h> |
84 | 84 | ||
85 | 85 | ||
86 | #include <kresources/selectdialog.h> | 86 | #include <kresources/selectdialog.h> |
87 | #include <kmessagebox.h> | 87 | #include <kmessagebox.h> |
88 | 88 | ||
89 | #include <picture.h> | 89 | #include <picture.h> |
90 | #include <resource.h> | 90 | #include <resource.h> |
91 | 91 | ||
92 | //US#include <qsplitter.h> | 92 | //US#include <qsplitter.h> |
93 | #include <qvbox.h> | 93 | #include <qvbox.h> |
94 | #include <qlayout.h> | 94 | #include <qlayout.h> |
95 | #include <qclipboard.h> | 95 | #include <qclipboard.h> |
96 | 96 | ||
97 | #include <libkdepim/categoryselectdialog.h> | 97 | #include <libkdepim/categoryselectdialog.h> |
98 | 98 | ||
99 | #include "addresseeutil.h" | 99 | #include "addresseeutil.h" |
100 | #include "undocmds.h" | 100 | #include "undocmds.h" |
101 | #include "addresseeeditordialog.h" | 101 | #include "addresseeeditordialog.h" |
102 | #include "viewmanager.h" | 102 | #include "viewmanager.h" |
103 | #include "details/detailsviewcontainer.h" | 103 | #include "details/detailsviewcontainer.h" |
104 | #include "kabprefs.h" | 104 | #include "kabprefs.h" |
105 | #include "xxportmanager.h" | 105 | #include "xxportmanager.h" |
106 | #include "incsearchwidget.h" | 106 | #include "incsearchwidget.h" |
107 | #include "jumpbuttonbar.h" | 107 | #include "jumpbuttonbar.h" |
108 | #include "extensionmanager.h" | 108 | #include "extensionmanager.h" |
109 | #include "addresseeconfig.h" | 109 | #include "addresseeconfig.h" |
110 | #include <kcmultidialog.h> | 110 | #include <kcmultidialog.h> |
111 | 111 | ||
112 | 112 | ||
113 | #ifdef KAB_EMBEDDED | 113 | #ifdef KAB_EMBEDDED |
114 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 114 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
115 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 115 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
116 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 116 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
117 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 117 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
118 | #else //KAB_EMBEDDED | 118 | #else //KAB_EMBEDDED |
119 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 119 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
120 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 120 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
121 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 121 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
122 | mReadWrite( readWrite ), mModified( false ) | 122 | mReadWrite( readWrite ), mModified( false ) |
123 | #endif //KAB_EMBEDDED | 123 | #endif //KAB_EMBEDDED |
124 | { | 124 | { |
125 | #ifdef KAB_EMBEDDED | 125 | #ifdef KAB_EMBEDDED |
126 | //US we define here our own global actioncollection. | 126 | //US we define here our own global actioncollection. |
127 | //mActionCollection = new KActionCollection(this); | 127 | //mActionCollection = new KActionCollection(this); |
128 | #endif //KAB_EMBEDDED | 128 | #endif //KAB_EMBEDDED |
129 | 129 | mExtensionBarSplitter = 0; | |
130 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 130 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
131 | 131 | ||
132 | mAddressBook = KABC::StdAddressBook::self(); | 132 | mAddressBook = KABC::StdAddressBook::self(); |
133 | KABC::StdAddressBook::setAutomaticSave( true ); | 133 | KABC::StdAddressBook::setAutomaticSave( true ); |
134 | 134 | ||
135 | #ifndef KAB_EMBEDDED | 135 | #ifndef KAB_EMBEDDED |
136 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 136 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
137 | #endif //KAB_EMBEDDED | 137 | #endif //KAB_EMBEDDED |
138 | 138 | ||
139 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 139 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
140 | SLOT( addressBookChanged() ) ); | 140 | SLOT( addressBookChanged() ) ); |
141 | 141 | ||
142 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 142 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
143 | "X-Department", "KADDRESSBOOK" ); | 143 | "X-Department", "KADDRESSBOOK" ); |
144 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 144 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
145 | "X-Profession", "KADDRESSBOOK" ); | 145 | "X-Profession", "KADDRESSBOOK" ); |
146 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 146 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
147 | "X-AssistantsName", "KADDRESSBOOK" ); | 147 | "X-AssistantsName", "KADDRESSBOOK" ); |
148 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 148 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
149 | "X-ManagersName", "KADDRESSBOOK" ); | 149 | "X-ManagersName", "KADDRESSBOOK" ); |
150 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 150 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
151 | "X-SpousesName", "KADDRESSBOOK" ); | 151 | "X-SpousesName", "KADDRESSBOOK" ); |
152 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 152 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
153 | "X-Office", "KADDRESSBOOK" ); | 153 | "X-Office", "KADDRESSBOOK" ); |
154 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 154 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
155 | "X-IMAddress", "KADDRESSBOOK" ); | 155 | "X-IMAddress", "KADDRESSBOOK" ); |
156 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 156 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
157 | "X-Anniversary", "KADDRESSBOOK" ); | 157 | "X-Anniversary", "KADDRESSBOOK" ); |
158 | 158 | ||
159 | initGUI(); | 159 | initGUI(); |
160 | 160 | ||
161 | mIncSearchWidget->setFocus(); | 161 | mIncSearchWidget->setFocus(); |
162 | 162 | ||
163 | 163 | ||
164 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 164 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
165 | SLOT( setContactSelected( const QString& ) ) ); | 165 | SLOT( setContactSelected( const QString& ) ) ); |
166 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 166 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
167 | SLOT( editContact( const QString& ) ) ); | 167 | SLOT( editContact( const QString& ) ) ); |
168 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 168 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
169 | SLOT( deleteContacts( ) ) ); | 169 | SLOT( deleteContacts( ) ) ); |
170 | connect( mViewManager, SIGNAL( modified() ), | 170 | connect( mViewManager, SIGNAL( modified() ), |
171 | SLOT( setModified() ) ); | 171 | SLOT( setModified() ) ); |
172 | 172 | ||
173 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 173 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
174 | 174 | ||
175 | connect( mXXPortManager, SIGNAL( modified() ), | 175 | connect( mXXPortManager, SIGNAL( modified() ), |
176 | SLOT( setModified() ) ); | 176 | SLOT( setModified() ) ); |
177 | 177 | ||
178 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 178 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
179 | SLOT( incrementalSearch( const QString& ) ) ); | 179 | SLOT( incrementalSearch( const QString& ) ) ); |
180 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 180 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
181 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 181 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
182 | 182 | ||
183 | #ifndef KAB_EMBEDDED | 183 | #ifndef KAB_EMBEDDED |
184 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 184 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
185 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 185 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
186 | 186 | ||
187 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 187 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
188 | SLOT( sendMail( const QString& ) ) ); | 188 | SLOT( sendMail( const QString& ) ) ); |
189 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 189 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
190 | SLOT( browse( const QString& ) ) ); | 190 | SLOT( browse( const QString& ) ) ); |
191 | 191 | ||
192 | mAddressBookService = new KAddressBookService( this ); | 192 | mAddressBookService = new KAddressBookService( this ); |
193 | 193 | ||
194 | #endif //KAB_EMBEDDED | 194 | #endif //KAB_EMBEDDED |
195 | 195 | ||
196 | setModified( false ); | 196 | setModified( false ); |
197 | } | 197 | } |
198 | 198 | ||
199 | KABCore::~KABCore() | 199 | KABCore::~KABCore() |
200 | { | 200 | { |
201 | // save(); | 201 | // save(); |
202 | //saveSettings(); | 202 | //saveSettings(); |
203 | //KABPrefs::instance()->writeConfig(); | 203 | //KABPrefs::instance()->writeConfig(); |
204 | delete AddresseeConfig::instance(); | 204 | delete AddresseeConfig::instance(); |
205 | mAddressBook = 0; | 205 | mAddressBook = 0; |
206 | KABC::StdAddressBook::close(); | 206 | KABC::StdAddressBook::close(); |
207 | 207 | ||
208 | #ifdef KAB_EMBEDDED | 208 | #ifdef KAB_EMBEDDED |
209 | //US we define here our own global actioncollection. | 209 | //US we define here our own global actioncollection. |
210 | // delete mActionCollection; | 210 | // delete mActionCollection; |
211 | #endif //KAB_EMBEDDED | 211 | #endif //KAB_EMBEDDED |
212 | 212 | ||
213 | } | 213 | } |
214 | 214 | ||
215 | void KABCore::restoreSettings() | 215 | void KABCore::restoreSettings() |
216 | { | 216 | { |
217 | bool state = KABPrefs::instance()->mJumpButtonBarVisible; | 217 | bool state = KABPrefs::instance()->mJumpButtonBarVisible; |
218 | 218 | ||
219 | mActionJumpBar->setChecked( state ); | 219 | mActionJumpBar->setChecked( state ); |
220 | setJumpButtonBarVisible( state ); | 220 | setJumpButtonBarVisible( state ); |
221 | 221 | ||
222 | state = KABPrefs::instance()->mDetailsPageVisible; | 222 | state = KABPrefs::instance()->mDetailsPageVisible; |
223 | 223 | ||
224 | mActionDetails->setChecked( state ); | 224 | mActionDetails->setChecked( state ); |
225 | setDetailsVisible( state ); | 225 | setDetailsVisible( state ); |
226 | QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 226 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
227 | if ( splitterSize.count() == 0 ) { | 227 | if ( splitterSize.count() == 0 ) { |
228 | splitterSize.append( width() / 2 ); | 228 | splitterSize.append( width() / 2 ); |
229 | splitterSize.append( width() / 2 ); | 229 | splitterSize.append( width() / 2 ); |
230 | } | 230 | } |
231 | mMiniSplitter->setSizes( splitterSize ); | 231 | mMiniSplitter->setSizes( splitterSize ); |
232 | if ( mExtensionBarSplitter ) { | ||
233 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | ||
234 | if ( splitterSize.count() == 0 ) { | ||
235 | splitterSize.append( width() / 2 ); | ||
236 | splitterSize.append( width() / 2 ); | ||
237 | } | ||
238 | mExtensionBarSplitter->setSizes( splitterSize ); | ||
239 | |||
240 | } | ||
232 | #ifndef KAB_EMBEDDED | 241 | #ifndef KAB_EMBEDDED |
233 | QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 242 | QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
234 | if ( splitterSize.count() == 0 ) { | 243 | if ( splitterSize.count() == 0 ) { |
235 | splitterSize.append( width() / 2 ); | 244 | splitterSize.append( width() / 2 ); |
236 | splitterSize.append( width() / 2 ); | 245 | splitterSize.append( width() / 2 ); |
237 | } | 246 | } |
238 | mExtensionBarSplitter->setSizes( splitterSize ); | 247 | mExtensionBarSplitter->setSizes( splitterSize ); |
239 | 248 | ||
240 | splitterSize = KABPrefs::instance()->mDetailsSplitter; | 249 | splitterSize = KABPrefs::instance()->mDetailsSplitter; |
241 | if ( splitterSize.count() == 0 ) { | 250 | if ( splitterSize.count() == 0 ) { |
242 | splitterSize.append( height() / 2 ); | 251 | splitterSize.append( height() / 2 ); |
243 | splitterSize.append( height() / 2 ); | 252 | splitterSize.append( height() / 2 ); |
244 | } | 253 | } |
245 | mDetailsSplitter->setSizes( splitterSize ); | 254 | mDetailsSplitter->setSizes( splitterSize ); |
246 | 255 | ||
247 | mExtensionManager->restoreSettings(); | 256 | mExtensionManager->restoreSettings(); |
248 | 257 | ||
249 | #endif //KAB_EMBEDDED | 258 | #endif //KAB_EMBEDDED |
250 | 259 | ||
251 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 260 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
252 | 261 | ||
253 | mViewManager->restoreSettings(); | 262 | mViewManager->restoreSettings(); |
254 | mExtensionManager->restoreSettings(); | 263 | mExtensionManager->restoreSettings(); |
255 | } | 264 | } |
256 | 265 | ||
257 | void KABCore::saveSettings() | 266 | void KABCore::saveSettings() |
258 | { | 267 | { |
259 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 268 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
260 | KABPrefs::instance()->mExtensionsSplitter = mMiniSplitter->sizes(); | 269 | if ( mExtensionBarSplitter ) |
270 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | ||
261 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 271 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
262 | 272 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | |
263 | #ifndef KAB_EMBEDDED | 273 | #ifndef KAB_EMBEDDED |
264 | 274 | ||
265 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 275 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
266 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 276 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
267 | #endif //KAB_EMBEDDED | 277 | #endif //KAB_EMBEDDED |
268 | mExtensionManager->saveSettings(); | 278 | mExtensionManager->saveSettings(); |
269 | mViewManager->saveSettings(); | 279 | mViewManager->saveSettings(); |
270 | 280 | ||
271 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 281 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
272 | 282 | ||
273 | } | 283 | } |
274 | 284 | ||
275 | KABC::AddressBook *KABCore::addressBook() const | 285 | KABC::AddressBook *KABCore::addressBook() const |
276 | { | 286 | { |
277 | return mAddressBook; | 287 | return mAddressBook; |
278 | } | 288 | } |
279 | 289 | ||
280 | KConfig *KABCore::config() | 290 | KConfig *KABCore::config() |
281 | { | 291 | { |
282 | #ifndef KAB_EMBEDDED | 292 | #ifndef KAB_EMBEDDED |
283 | return KABPrefs::instance()->config(); | 293 | return KABPrefs::instance()->config(); |
284 | #else //KAB_EMBEDDED | 294 | #else //KAB_EMBEDDED |
285 | return KABPrefs::instance()->getConfig(); | 295 | return KABPrefs::instance()->getConfig(); |
286 | #endif //KAB_EMBEDDED | 296 | #endif //KAB_EMBEDDED |
287 | } | 297 | } |
288 | 298 | ||
289 | KActionCollection *KABCore::actionCollection() const | 299 | KActionCollection *KABCore::actionCollection() const |
290 | { | 300 | { |
291 | return mGUIClient->actionCollection(); | 301 | return mGUIClient->actionCollection(); |
292 | } | 302 | } |
293 | 303 | ||
294 | KABC::Field *KABCore::currentSearchField() const | 304 | KABC::Field *KABCore::currentSearchField() const |
295 | { | 305 | { |
296 | if (mIncSearchWidget) | 306 | if (mIncSearchWidget) |
297 | return mIncSearchWidget->currentField(); | 307 | return mIncSearchWidget->currentField(); |
298 | else | 308 | else |
299 | return 0; | 309 | return 0; |
300 | } | 310 | } |
301 | 311 | ||
302 | QStringList KABCore::selectedUIDs() const | 312 | QStringList KABCore::selectedUIDs() const |
303 | { | 313 | { |
304 | return mViewManager->selectedUids(); | 314 | return mViewManager->selectedUids(); |
305 | } | 315 | } |
306 | 316 | ||
307 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 317 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
308 | { | 318 | { |
309 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 319 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
310 | 320 | ||
311 | QPtrList<KRES::Resource> kresResources; | 321 | QPtrList<KRES::Resource> kresResources; |
312 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 322 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
313 | KABC::Resource *resource; | 323 | KABC::Resource *resource; |
314 | while ( ( resource = resIt.current() ) != 0 ) { | 324 | while ( ( resource = resIt.current() ) != 0 ) { |
315 | ++resIt; | 325 | ++resIt; |
316 | if ( !resource->readOnly() ) { | 326 | if ( !resource->readOnly() ) { |
317 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 327 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
318 | if ( res ) | 328 | if ( res ) |
319 | kresResources.append( res ); | 329 | kresResources.append( res ); |
320 | } | 330 | } |
321 | } | 331 | } |
322 | 332 | ||
323 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 333 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
324 | return static_cast<KABC::Resource*>( res ); | 334 | return static_cast<KABC::Resource*>( res ); |
325 | } | 335 | } |
326 | 336 | ||
327 | #ifndef KAB_EMBEDDED | 337 | #ifndef KAB_EMBEDDED |
328 | KAboutData *KABCore::createAboutData() | 338 | KAboutData *KABCore::createAboutData() |
329 | #else //KAB_EMBEDDED | 339 | #else //KAB_EMBEDDED |
330 | void KABCore::createAboutData() | 340 | void KABCore::createAboutData() |
331 | #endif //KAB_EMBEDDED | 341 | #endif //KAB_EMBEDDED |
332 | { | 342 | { |
333 | #ifndef KAB_EMBEDDED | 343 | #ifndef KAB_EMBEDDED |
334 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 344 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
335 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 345 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
336 | KAboutData::License_GPL_V2, | 346 | KAboutData::License_GPL_V2, |
337 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 347 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
338 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 348 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
339 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 349 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
340 | about->addAuthor( "Cornelius Schumacher", | 350 | about->addAuthor( "Cornelius Schumacher", |
341 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 351 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
342 | "schumacher@kde.org" ); | 352 | "schumacher@kde.org" ); |
343 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 353 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
344 | "mpilone@slac.com" ); | 354 | "mpilone@slac.com" ); |
345 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 355 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
346 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 356 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
347 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 357 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
348 | "michel@klaralvdalens-datakonsult.se" ); | 358 | "michel@klaralvdalens-datakonsult.se" ); |
349 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 359 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
350 | "hansen@kde.org" ); | 360 | "hansen@kde.org" ); |
351 | 361 | ||
352 | return about; | 362 | return about; |
353 | #endif //KAB_EMBEDDED | 363 | #endif //KAB_EMBEDDED |
354 | 364 | ||
355 | QString version; | 365 | QString version; |
356 | #include <../version> | 366 | #include <../version> |
357 | QMessageBox::about( this, "About KAddressbook/Pi", | 367 | QMessageBox::about( this, "About KAddressbook/Pi", |
358 | "KAddressbook/Platform-independent\n" | 368 | "KAddressbook/Platform-independent\n" |
359 | "(KA/Pi) " +version + " - " + | 369 | "(KA/Pi) " +version + " - " + |
360 | #ifdef DESKTOP_VERSION | 370 | #ifdef DESKTOP_VERSION |
361 | "Desktop Edition\n" | 371 | "Desktop Edition\n" |
362 | #else | 372 | #else |
363 | "PDA-Edition\n" | 373 | "PDA-Edition\n" |
364 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 374 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
365 | #endif | 375 | #endif |
366 | 376 | ||
367 | "(c) 2004 Ulf Schenk\n" | 377 | "(c) 2004 Ulf Schenk\n" |
368 | "(c) 1997-2003, The KDE PIM Team\n" | 378 | "(c) 1997-2003, The KDE PIM Team\n" |
369 | "Tobias Koenig Current maintainer tokoe@kde.org\n" | 379 | "Tobias Koenig Current maintainer tokoe@kde.org\n" |
370 | "Don Sanders Original author\n" | 380 | "Don Sanders Original author\n" |
371 | "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" | 381 | "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" |
372 | "Mike Pilone GUI and framework redesign mpilone@slac.com\n" | 382 | "Mike Pilone GUI and framework redesign mpilone@slac.com\n" |
373 | "Greg Stern DCOP interface\n" | 383 | "Greg Stern DCOP interface\n" |
374 | "Mark Westcot Contact pinning\n" | 384 | "Mark Westcot Contact pinning\n" |
375 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 385 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
376 | "Steffen Hansen LDAP Lookup hansen@kde.org\n" ); | 386 | "Steffen Hansen LDAP Lookup hansen@kde.org\n" ); |
377 | } | 387 | } |
378 | 388 | ||
379 | void KABCore::setContactSelected( const QString &uid ) | 389 | void KABCore::setContactSelected( const QString &uid ) |
380 | { | 390 | { |
381 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 391 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
382 | if ( !mDetails->isHidden() ) | 392 | if ( !mDetails->isHidden() ) |
383 | mDetails->setAddressee( addr ); | 393 | mDetails->setAddressee( addr ); |
384 | 394 | ||
385 | if ( !addr.isEmpty() ) { | 395 | if ( !addr.isEmpty() ) { |
386 | emit contactSelected( addr.formattedName() ); | 396 | emit contactSelected( addr.formattedName() ); |
387 | KABC::Picture pic = addr.photo(); | 397 | KABC::Picture pic = addr.photo(); |
388 | if ( pic.isIntern() ) { | 398 | if ( pic.isIntern() ) { |
389 | //US emit contactSelected( pic.data() ); | 399 | //US emit contactSelected( pic.data() ); |
390 | //US instead use: | 400 | //US instead use: |
391 | QPixmap px; | 401 | QPixmap px; |
392 | if (pic.data().isNull() != true) | 402 | if (pic.data().isNull() != true) |
393 | { | 403 | { |
394 | px.convertFromImage(pic.data()); | 404 | px.convertFromImage(pic.data()); |
395 | } | 405 | } |
396 | 406 | ||
397 | emit contactSelected( px ); | 407 | emit contactSelected( px ); |
398 | } | 408 | } |
399 | } | 409 | } |
400 | 410 | ||
401 | 411 | ||
402 | mExtensionManager->setSelectionChanged(); | 412 | mExtensionManager->setSelectionChanged(); |
403 | 413 | ||
404 | // update the actions | 414 | // update the actions |
405 | bool selected = !uid.isEmpty(); | 415 | bool selected = !uid.isEmpty(); |
406 | 416 | ||
407 | if ( mReadWrite ) { | 417 | if ( mReadWrite ) { |
408 | mActionCut->setEnabled( selected ); | 418 | mActionCut->setEnabled( selected ); |
409 | mActionPaste->setEnabled( selected ); | 419 | mActionPaste->setEnabled( selected ); |
410 | } | 420 | } |
411 | 421 | ||
412 | mActionCopy->setEnabled( selected ); | 422 | mActionCopy->setEnabled( selected ); |
413 | mActionDelete->setEnabled( selected ); | 423 | mActionDelete->setEnabled( selected ); |
414 | mActionEditAddressee->setEnabled( selected ); | 424 | mActionEditAddressee->setEnabled( selected ); |
415 | mActionMail->setEnabled( selected ); | 425 | mActionMail->setEnabled( selected ); |
416 | mActionMailVCard->setEnabled( selected ); | 426 | mActionMailVCard->setEnabled( selected ); |
417 | mActionWhoAmI->setEnabled( selected ); | 427 | mActionWhoAmI->setEnabled( selected ); |
418 | mActionCategories->setEnabled( selected ); | 428 | mActionCategories->setEnabled( selected ); |
419 | } | 429 | } |
420 | 430 | ||
421 | void KABCore::sendMail() | 431 | void KABCore::sendMail() |
422 | { | 432 | { |
423 | #ifndef KAB_EMBEDDED | 433 | #ifndef KAB_EMBEDDED |
424 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 434 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
425 | #else //KAB_EMBEDDED | 435 | #else //KAB_EMBEDDED |
426 | qDebug("KABCore::sendMail() ust be fixed"); | 436 | qDebug("KABCore::sendMail() ust be fixed"); |
427 | #endif //KAB_EMBEDDED | 437 | #endif //KAB_EMBEDDED |
428 | } | 438 | } |
429 | 439 | ||
430 | void KABCore::sendMail( const QString& email ) | 440 | void KABCore::sendMail( const QString& email ) |
431 | { | 441 | { |
432 | #ifndef KAB_EMBEDDED | 442 | #ifndef KAB_EMBEDDED |
433 | kapp->invokeMailer( email, "" ); | 443 | kapp->invokeMailer( email, "" ); |
434 | #else //KAB_EMBEDDED | 444 | #else //KAB_EMBEDDED |
435 | qDebug("KABCore::sendMail(const QString& email) ust be fixed"); | 445 | qDebug("KABCore::sendMail(const QString& email) ust be fixed"); |
436 | #endif //KAB_EMBEDDED | 446 | #endif //KAB_EMBEDDED |
437 | } | 447 | } |
438 | 448 | ||
439 | void KABCore::mailVCard() | 449 | void KABCore::mailVCard() |
440 | { | 450 | { |
441 | #ifndef KAB_EMBEDDED | 451 | #ifndef KAB_EMBEDDED |
442 | QStringList uids = mViewManager->selectedUids(); | 452 | QStringList uids = mViewManager->selectedUids(); |
443 | if ( !uids.isEmpty() ) | 453 | if ( !uids.isEmpty() ) |
444 | mailVCard( uids ); | 454 | mailVCard( uids ); |
445 | #else //KAB_EMBEDDED | 455 | #else //KAB_EMBEDDED |
446 | qDebug("KABCore::mailVCard() must be fixed"); | 456 | qDebug("KABCore::mailVCard() must be fixed"); |
447 | #endif //KAB_EMBEDDED | 457 | #endif //KAB_EMBEDDED |
448 | } | 458 | } |
449 | 459 | ||
450 | void KABCore::mailVCard( const QStringList& uids ) | 460 | void KABCore::mailVCard( const QStringList& uids ) |
451 | { | 461 | { |
452 | #ifndef KAB_EMBEDDED | 462 | #ifndef KAB_EMBEDDED |
453 | QStringList urls; | 463 | QStringList urls; |
454 | 464 | ||
455 | // Create a temp dir, so that we can put the files in it with proper names | 465 | // Create a temp dir, so that we can put the files in it with proper names |
456 | KTempFile tempDir; | 466 | KTempFile tempDir; |
457 | if ( tempDir.status() != 0 ) { | 467 | if ( tempDir.status() != 0 ) { |
458 | kdWarning() << strerror( tempDir.status() ) << endl; | 468 | kdWarning() << strerror( tempDir.status() ) << endl; |
459 | return; | 469 | return; |
460 | } | 470 | } |
461 | 471 | ||
462 | QString dirName = tempDir.name(); | 472 | QString dirName = tempDir.name(); |
463 | tempDir.unlink(); | 473 | tempDir.unlink(); |
464 | QDir().mkdir( dirName, true ); | 474 | QDir().mkdir( dirName, true ); |
465 | 475 | ||
466 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 476 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
467 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 477 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
468 | 478 | ||
469 | if ( a.isEmpty() ) | 479 | if ( a.isEmpty() ) |
470 | continue; | 480 | continue; |
471 | 481 | ||
472 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 482 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
473 | 483 | ||
474 | QString fileName = dirName + "/" + name; | 484 | QString fileName = dirName + "/" + name; |
475 | 485 | ||
476 | QFile outFile(fileName); | 486 | QFile outFile(fileName); |
477 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 487 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
478 | KABC::VCardConverter converter; | 488 | KABC::VCardConverter converter; |
479 | QString vcard; | 489 | QString vcard; |
480 | 490 | ||
481 | converter.addresseeToVCard( a, vcard ); | 491 | converter.addresseeToVCard( a, vcard ); |
482 | 492 | ||
483 | QTextStream t( &outFile ); // use a text stream | 493 | QTextStream t( &outFile ); // use a text stream |
484 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 494 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
485 | t << vcard; | 495 | t << vcard; |
486 | 496 | ||
487 | outFile.close(); | 497 | outFile.close(); |
488 | 498 | ||
489 | urls.append( fileName ); | 499 | urls.append( fileName ); |
490 | } | 500 | } |
491 | } | 501 | } |
492 | 502 | ||
493 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 503 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
494 | QString::null, // subject | 504 | QString::null, // subject |
495 | QString::null, // body | 505 | QString::null, // body |
496 | QString::null, | 506 | QString::null, |
497 | urls ); // attachments | 507 | urls ); // attachments |
498 | #else //KAB_EMBEDDED | 508 | #else //KAB_EMBEDDED |
499 | qDebug("KABCore::mailVCard( must be fixed"); | 509 | qDebug("KABCore::mailVCard( must be fixed"); |
500 | #endif //KAB_EMBEDDED | 510 | #endif //KAB_EMBEDDED |
501 | 511 | ||
502 | } | 512 | } |
503 | 513 | ||
504 | void KABCore::browse( const QString& url ) | 514 | void KABCore::browse( const QString& url ) |
505 | { | 515 | { |
506 | #ifndef KAB_EMBEDDED | 516 | #ifndef KAB_EMBEDDED |
507 | kapp->invokeBrowser( url ); | 517 | kapp->invokeBrowser( url ); |
508 | #else //KAB_EMBEDDED | 518 | #else //KAB_EMBEDDED |
509 | qDebug("KABCore::browse must be fixed"); | 519 | qDebug("KABCore::browse must be fixed"); |
510 | #endif //KAB_EMBEDDED | 520 | #endif //KAB_EMBEDDED |
511 | } | 521 | } |
512 | 522 | ||
513 | void KABCore::selectAllContacts() | 523 | void KABCore::selectAllContacts() |
514 | { | 524 | { |
515 | mViewManager->setSelected( QString::null, true ); | 525 | mViewManager->setSelected( QString::null, true ); |
516 | } | 526 | } |
517 | 527 | ||
518 | void KABCore::deleteContacts() | 528 | void KABCore::deleteContacts() |
519 | { | 529 | { |
520 | QStringList uidList = mViewManager->selectedUids(); | 530 | QStringList uidList = mViewManager->selectedUids(); |
521 | deleteContacts( uidList ); | 531 | deleteContacts( uidList ); |
522 | } | 532 | } |
523 | 533 | ||
524 | void KABCore::deleteContacts( const QStringList &uids ) | 534 | void KABCore::deleteContacts( const QStringList &uids ) |
525 | { | 535 | { |
526 | if ( uids.count() > 0 ) { | 536 | if ( uids.count() > 0 ) { |
527 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 537 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
528 | UndoStack::instance()->push( command ); | 538 | UndoStack::instance()->push( command ); |
529 | RedoStack::instance()->clear(); | 539 | RedoStack::instance()->clear(); |
530 | 540 | ||
531 | // now if we deleted anything, refresh | 541 | // now if we deleted anything, refresh |
532 | setContactSelected( QString::null ); | 542 | setContactSelected( QString::null ); |
533 | setModified( true ); | 543 | setModified( true ); |
534 | } | 544 | } |
535 | } | 545 | } |
536 | 546 | ||
537 | void KABCore::copyContacts() | 547 | void KABCore::copyContacts() |
538 | { | 548 | { |
539 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 549 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
540 | 550 | ||
541 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 551 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
542 | 552 | ||
543 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 553 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
544 | 554 | ||
545 | QClipboard *cb = QApplication::clipboard(); | 555 | QClipboard *cb = QApplication::clipboard(); |
546 | cb->setText( clipText ); | 556 | cb->setText( clipText ); |
547 | } | 557 | } |
548 | 558 | ||
549 | void KABCore::cutContacts() | 559 | void KABCore::cutContacts() |
550 | { | 560 | { |
551 | QStringList uidList = mViewManager->selectedUids(); | 561 | QStringList uidList = mViewManager->selectedUids(); |
552 | 562 | ||
553 | //US if ( uidList.size() > 0 ) { | 563 | //US if ( uidList.size() > 0 ) { |
554 | if ( uidList.count() > 0 ) { | 564 | if ( uidList.count() > 0 ) { |
555 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 565 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
556 | UndoStack::instance()->push( command ); | 566 | UndoStack::instance()->push( command ); |
557 | RedoStack::instance()->clear(); | 567 | RedoStack::instance()->clear(); |
558 | 568 | ||
559 | setModified( true ); | 569 | setModified( true ); |
560 | } | 570 | } |
561 | } | 571 | } |
562 | 572 | ||
563 | void KABCore::pasteContacts() | 573 | void KABCore::pasteContacts() |
564 | { | 574 | { |
565 | QClipboard *cb = QApplication::clipboard(); | 575 | QClipboard *cb = QApplication::clipboard(); |
566 | 576 | ||
567 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 577 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
568 | 578 | ||
569 | pasteContacts( list ); | 579 | pasteContacts( list ); |
570 | } | 580 | } |
571 | 581 | ||
572 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 582 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
573 | { | 583 | { |
574 | KABC::Resource *resource = requestResource( this ); | 584 | KABC::Resource *resource = requestResource( this ); |
575 | KABC::Addressee::List::Iterator it; | 585 | KABC::Addressee::List::Iterator it; |
576 | for ( it = list.begin(); it != list.end(); ++it ) | 586 | for ( it = list.begin(); it != list.end(); ++it ) |
577 | (*it).setResource( resource ); | 587 | (*it).setResource( resource ); |
578 | 588 | ||
579 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 589 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
580 | UndoStack::instance()->push( command ); | 590 | UndoStack::instance()->push( command ); |
581 | RedoStack::instance()->clear(); | 591 | RedoStack::instance()->clear(); |
582 | 592 | ||
583 | setModified( true ); | 593 | setModified( true ); |
584 | } | 594 | } |
585 | 595 | ||
586 | void KABCore::setWhoAmI() | 596 | void KABCore::setWhoAmI() |
587 | { | 597 | { |
588 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 598 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
589 | 599 | ||
590 | if ( addrList.count() > 1 ) { | 600 | if ( addrList.count() > 1 ) { |
591 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 601 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
592 | return; | 602 | return; |
593 | } | 603 | } |
594 | 604 | ||
595 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 605 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
596 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 606 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
597 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 607 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
598 | } | 608 | } |
599 | 609 | ||
600 | void KABCore::setCategories() | 610 | void KABCore::setCategories() |
601 | { | 611 | { |
602 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 612 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
603 | if ( !dlg.exec() ) | 613 | if ( !dlg.exec() ) |
604 | return; | 614 | return; |
605 | 615 | ||
606 | bool merge = false; | 616 | bool merge = false; |
607 | QString msg = i18n( "Merge with existing categories?" ); | 617 | QString msg = i18n( "Merge with existing categories?" ); |
608 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 618 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
609 | merge = true; | 619 | merge = true; |
610 | 620 | ||
611 | QStringList categories = dlg.selectedCategories(); | 621 | QStringList categories = dlg.selectedCategories(); |
612 | 622 | ||
613 | QStringList uids = mViewManager->selectedUids(); | 623 | QStringList uids = mViewManager->selectedUids(); |
614 | QStringList::Iterator it; | 624 | QStringList::Iterator it; |
615 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 625 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
616 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 626 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
617 | if ( !addr.isEmpty() ) { | 627 | if ( !addr.isEmpty() ) { |
618 | if ( !merge ) | 628 | if ( !merge ) |
619 | addr.setCategories( categories ); | 629 | addr.setCategories( categories ); |
620 | else { | 630 | else { |
621 | QStringList addrCategories = addr.categories(); | 631 | QStringList addrCategories = addr.categories(); |
622 | QStringList::Iterator catIt; | 632 | QStringList::Iterator catIt; |
623 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 633 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
624 | if ( !addrCategories.contains( *catIt ) ) | 634 | if ( !addrCategories.contains( *catIt ) ) |
625 | addrCategories.append( *catIt ); | 635 | addrCategories.append( *catIt ); |
626 | } | 636 | } |
627 | addr.setCategories( addrCategories ); | 637 | addr.setCategories( addrCategories ); |
628 | } | 638 | } |
629 | 639 | ||
630 | mAddressBook->insertAddressee( addr ); | 640 | mAddressBook->insertAddressee( addr ); |
631 | } | 641 | } |
632 | } | 642 | } |
633 | 643 | ||
634 | if ( uids.count() > 0 ) | 644 | if ( uids.count() > 0 ) |
635 | setModified( true ); | 645 | setModified( true ); |
636 | } | 646 | } |
637 | 647 | ||
638 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 648 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
639 | { | 649 | { |
640 | mIncSearchWidget->setFields( fields ); | 650 | mIncSearchWidget->setFields( fields ); |
641 | } | 651 | } |
642 | 652 | ||
643 | void KABCore::incrementalSearch( const QString& text ) | 653 | void KABCore::incrementalSearch( const QString& text ) |
644 | { | 654 | { |
645 | mViewManager->setSelected( QString::null, false ); | 655 | mViewManager->setSelected( QString::null, false ); |
646 | 656 | ||
647 | if ( !text.isEmpty() ) { | 657 | if ( !text.isEmpty() ) { |
648 | KABC::Field *field = mIncSearchWidget->currentField(); | 658 | KABC::Field *field = mIncSearchWidget->currentField(); |
649 | 659 | ||
650 | QString pattern = text.lower(); | 660 | QString pattern = text.lower(); |
651 | 661 | ||
652 | #if KDE_VERSION >= 319 | 662 | #if KDE_VERSION >= 319 |
653 | KABC::AddresseeList list( mAddressBook->allAddressees() ); | 663 | KABC::AddresseeList list( mAddressBook->allAddressees() ); |
654 | if ( field ) { | 664 | if ( field ) { |
655 | list.sortByField( field ); | 665 | list.sortByField( field ); |
656 | KABC::AddresseeList::Iterator it; | 666 | KABC::AddresseeList::Iterator it; |
657 | for ( it = list.begin(); it != list.end(); ++it ) { | 667 | for ( it = list.begin(); it != list.end(); ++it ) { |
658 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | 668 | if ( field->value( *it ).lower().startsWith( pattern ) ) { |
659 | mViewManager->setSelected( (*it).uid(), true ); | 669 | mViewManager->setSelected( (*it).uid(), true ); |
660 | return; | 670 | return; |
661 | } | 671 | } |
662 | } | 672 | } |
663 | } else { | 673 | } else { |
664 | KABC::AddresseeList::Iterator it; | 674 | KABC::AddresseeList::Iterator it; |
665 | for ( it = list.begin(); it != list.end(); ++it ) { | 675 | for ( it = list.begin(); it != list.end(); ++it ) { |
666 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | 676 | KABC::Field::List fieldList = mIncSearchWidget->fields(); |
667 | KABC::Field::List::ConstIterator fieldIt; | 677 | KABC::Field::List::ConstIterator fieldIt; |
668 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 678 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
669 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | 679 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { |
670 | mViewManager->setSelected( (*it).uid(), true ); | 680 | mViewManager->setSelected( (*it).uid(), true ); |
671 | return; | 681 | return; |
672 | } | 682 | } |
673 | } | 683 | } |
674 | } | 684 | } |
675 | } | 685 | } |
676 | #else | 686 | #else |
677 | KABC::AddressBook::Iterator it; | 687 | KABC::AddressBook::Iterator it; |
678 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 688 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
679 | if ( field ) { | 689 | if ( field ) { |
680 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | 690 | if ( field->value( *it ).lower().startsWith( pattern ) ) { |
681 | mViewManager->setSelected( (*it).uid(), true ); | 691 | mViewManager->setSelected( (*it).uid(), true ); |
682 | return; | 692 | return; |
683 | } | 693 | } |
684 | } else { | 694 | } else { |
685 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | 695 | KABC::Field::List fieldList = mIncSearchWidget->fields(); |
686 | KABC::Field::List::ConstIterator fieldIt; | 696 | KABC::Field::List::ConstIterator fieldIt; |
687 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 697 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
688 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | 698 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { |
689 | mViewManager->setSelected( (*it).uid(), true ); | 699 | mViewManager->setSelected( (*it).uid(), true ); |
690 | return; | 700 | return; |
691 | } | 701 | } |
692 | } | 702 | } |
693 | } | 703 | } |
694 | } | 704 | } |
695 | #endif | 705 | #endif |
696 | } | 706 | } |
697 | } | 707 | } |
698 | 708 | ||
699 | void KABCore::setModified() | 709 | void KABCore::setModified() |
700 | { | 710 | { |
701 | setModified( true ); | 711 | setModified( true ); |
702 | } | 712 | } |
703 | 713 | ||
704 | void KABCore::setModifiedWOrefresh() | 714 | void KABCore::setModifiedWOrefresh() |
705 | { | 715 | { |
706 | // qDebug("KABCore::setModifiedWOrefresh() "); | 716 | // qDebug("KABCore::setModifiedWOrefresh() "); |
707 | mModified = true; | 717 | mModified = true; |
708 | mActionSave->setEnabled( mModified ); | 718 | mActionSave->setEnabled( mModified ); |
709 | #ifdef DESKTOP_VERSION | 719 | #ifdef DESKTOP_VERSION |
710 | mDetails->refreshView(); | 720 | mDetails->refreshView(); |
711 | #endif | 721 | #endif |
712 | 722 | ||
713 | } | 723 | } |
714 | void KABCore::setModified( bool modified ) | 724 | void KABCore::setModified( bool modified ) |
715 | { | 725 | { |
716 | mModified = modified; | 726 | mModified = modified; |
717 | mActionSave->setEnabled( mModified ); | 727 | mActionSave->setEnabled( mModified ); |
718 | 728 | ||
719 | if ( modified ) | 729 | if ( modified ) |
720 | mJumpButtonBar->recreateButtons(); | 730 | mJumpButtonBar->recreateButtons(); |
721 | 731 | ||
722 | mViewManager->refreshView(); | 732 | mViewManager->refreshView(); |
723 | mDetails->refreshView(); | 733 | mDetails->refreshView(); |
724 | 734 | ||
725 | } | 735 | } |
726 | 736 | ||
727 | bool KABCore::modified() const | 737 | bool KABCore::modified() const |
728 | { | 738 | { |
729 | return mModified; | 739 | return mModified; |
730 | } | 740 | } |
731 | 741 | ||
732 | void KABCore::contactModified( const KABC::Addressee &addr ) | 742 | void KABCore::contactModified( const KABC::Addressee &addr ) |
733 | { | 743 | { |
734 | 744 | ||
735 | Command *command = 0; | 745 | Command *command = 0; |
736 | QString uid; | 746 | QString uid; |
737 | 747 | ||
738 | // check if it exists already | 748 | // check if it exists already |
739 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 749 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
740 | if ( origAddr.isEmpty() ) | 750 | if ( origAddr.isEmpty() ) |
741 | command = new PwNewCommand( mAddressBook, addr ); | 751 | command = new PwNewCommand( mAddressBook, addr ); |
742 | else { | 752 | else { |
743 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 753 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
744 | uid = addr.uid(); | 754 | uid = addr.uid(); |
745 | } | 755 | } |
746 | 756 | ||
747 | UndoStack::instance()->push( command ); | 757 | UndoStack::instance()->push( command ); |
748 | RedoStack::instance()->clear(); | 758 | RedoStack::instance()->clear(); |
749 | 759 | ||
750 | setModified( true ); | 760 | setModified( true ); |
751 | } | 761 | } |
752 | 762 | ||
753 | void KABCore::newContact() | 763 | void KABCore::newContact() |
754 | { | 764 | { |
755 | AddresseeEditorDialog *dialog = 0; | 765 | AddresseeEditorDialog *dialog = 0; |
756 | 766 | ||
757 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 767 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
758 | 768 | ||
759 | QPtrList<KRES::Resource> kresResources; | 769 | QPtrList<KRES::Resource> kresResources; |
760 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 770 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
761 | KABC::Resource *resource; | 771 | KABC::Resource *resource; |
762 | while ( ( resource = it.current() ) != 0 ) { | 772 | while ( ( resource = it.current() ) != 0 ) { |
763 | ++it; | 773 | ++it; |
764 | if ( !resource->readOnly() ) { | 774 | if ( !resource->readOnly() ) { |
765 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 775 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
766 | if ( res ) | 776 | if ( res ) |
767 | kresResources.append( res ); | 777 | kresResources.append( res ); |
768 | } | 778 | } |
769 | } | 779 | } |
770 | 780 | ||
771 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 781 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
772 | resource = static_cast<KABC::Resource*>( res ); | 782 | resource = static_cast<KABC::Resource*>( res ); |
773 | 783 | ||
774 | if ( resource ) { | 784 | if ( resource ) { |
775 | KABC::Addressee addr; | 785 | KABC::Addressee addr; |
776 | addr.setResource( resource ); | 786 | addr.setResource( resource ); |
777 | dialog = createAddresseeEditorDialog( this ); | 787 | dialog = createAddresseeEditorDialog( this ); |
778 | dialog->setAddressee( addr ); | 788 | dialog->setAddressee( addr ); |
779 | 789 | ||
780 | } else | 790 | } else |
781 | return; | 791 | return; |
782 | 792 | ||
783 | mEditorDict.insert( dialog->addressee().uid(), dialog ); | 793 | mEditorDict.insert( dialog->addressee().uid(), dialog ); |
784 | 794 | ||
785 | dialog->show(); | 795 | dialog->show(); |
786 | 796 | ||
787 | } | 797 | } |
788 | 798 | ||
789 | void KABCore::addEmail( QString aStr ) | 799 | void KABCore::addEmail( QString aStr ) |
790 | { | 800 | { |
791 | #ifndef KAB_EMBEDDED | 801 | #ifndef KAB_EMBEDDED |
792 | QString fullName, email; | 802 | QString fullName, email; |
793 | 803 | ||
794 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 804 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
795 | 805 | ||
796 | // Try to lookup the addressee matching the email address | 806 | // Try to lookup the addressee matching the email address |
797 | bool found = false; | 807 | bool found = false; |
798 | QStringList emailList; | 808 | QStringList emailList; |
799 | KABC::AddressBook::Iterator it; | 809 | KABC::AddressBook::Iterator it; |
800 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 810 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
801 | emailList = (*it).emails(); | 811 | emailList = (*it).emails(); |
802 | if ( emailList.contains( email ) > 0 ) { | 812 | if ( emailList.contains( email ) > 0 ) { |
803 | found = true; | 813 | found = true; |
804 | (*it).setNameFromString( fullName ); | 814 | (*it).setNameFromString( fullName ); |
805 | editContact( (*it).uid() ); | 815 | editContact( (*it).uid() ); |
806 | } | 816 | } |
807 | } | 817 | } |
808 | 818 | ||
809 | if ( !found ) { | 819 | if ( !found ) { |
810 | KABC::Addressee addr; | 820 | KABC::Addressee addr; |
811 | addr.setNameFromString( fullName ); | 821 | addr.setNameFromString( fullName ); |
812 | addr.insertEmail( email, true ); | 822 | addr.insertEmail( email, true ); |
813 | 823 | ||
814 | mAddressBook->insertAddressee( addr ); | 824 | mAddressBook->insertAddressee( addr ); |
815 | mViewManager->refreshView( addr.uid() ); | 825 | mViewManager->refreshView( addr.uid() ); |
816 | editContact( addr.uid() ); | 826 | editContact( addr.uid() ); |
817 | } | 827 | } |
818 | #else //KAB_EMBEDDED | 828 | #else //KAB_EMBEDDED |
819 | qDebug("KABCore::addEmail finsih method"); | 829 | qDebug("KABCore::addEmail finsih method"); |
820 | #endif //KAB_EMBEDDED | 830 | #endif //KAB_EMBEDDED |
821 | } | 831 | } |
822 | 832 | ||
823 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 833 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
824 | { | 834 | { |
825 | mXXPortManager->importVCard( url, showPreview ); | 835 | mXXPortManager->importVCard( url, showPreview ); |
826 | } | 836 | } |
827 | 837 | ||
828 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 838 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
829 | { | 839 | { |
830 | mXXPortManager->importVCard( vCard, showPreview ); | 840 | mXXPortManager->importVCard( vCard, showPreview ); |
831 | } | 841 | } |
832 | 842 | ||
833 | //US added a second method without defaultparameter | 843 | //US added a second method without defaultparameter |
834 | void KABCore::editContact2() { | 844 | void KABCore::editContact2() { |
835 | editContact( QString::null ); | 845 | editContact( QString::null ); |
836 | } | 846 | } |
837 | 847 | ||
838 | void KABCore::editContact( const QString &uid ) | 848 | void KABCore::editContact( const QString &uid ) |
839 | { | 849 | { |
840 | 850 | ||
841 | if ( mExtensionManager->isQuickEditVisible() ) | 851 | if ( mExtensionManager->isQuickEditVisible() ) |
842 | return; | 852 | return; |
843 | 853 | ||
844 | // First, locate the contact entry | 854 | // First, locate the contact entry |
845 | QString localUID = uid; | 855 | QString localUID = uid; |
846 | if ( localUID.isNull() ) { | 856 | if ( localUID.isNull() ) { |
847 | QStringList uidList = mViewManager->selectedUids(); | 857 | QStringList uidList = mViewManager->selectedUids(); |
848 | if ( uidList.count() > 0 ) | 858 | if ( uidList.count() > 0 ) |
849 | localUID = *( uidList.at( 0 ) ); | 859 | localUID = *( uidList.at( 0 ) ); |
850 | } | 860 | } |
851 | 861 | ||
852 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 862 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
853 | if ( !addr.isEmpty() ) { | 863 | if ( !addr.isEmpty() ) { |
854 | AddresseeEditorDialog *dialog = mEditorDict.find( addr.uid() ); | 864 | AddresseeEditorDialog *dialog = mEditorDict.find( addr.uid() ); |
855 | if ( !dialog ) { | 865 | if ( !dialog ) { |
856 | dialog = createAddresseeEditorDialog( this ); | 866 | dialog = createAddresseeEditorDialog( this ); |
857 | 867 | ||
858 | mEditorDict.insert( addr.uid(), dialog ); | 868 | mEditorDict.insert( addr.uid(), dialog ); |
859 | 869 | ||
860 | dialog->setAddressee( addr ); | 870 | dialog->setAddressee( addr ); |
861 | } | 871 | } |
862 | 872 | ||
863 | dialog->raise(); | 873 | dialog->raise(); |
864 | dialog->show(); | 874 | dialog->show(); |
865 | } | 875 | } |
866 | } | 876 | } |
867 | 877 | ||
868 | void KABCore::save() | 878 | void KABCore::save() |
869 | { | 879 | { |
870 | if ( !mModified ) | 880 | if ( !mModified ) |
871 | return; | 881 | return; |
872 | QString text = i18n( "There was an error while attempting to save\n the " | 882 | QString text = i18n( "There was an error while attempting to save\n the " |
873 | "address book. Please check that some \nother application is " | 883 | "address book. Please check that some \nother application is " |
874 | "not using it. " ); | 884 | "not using it. " ); |
875 | statusMessage(i18n("Saving addressbook ... ")); | 885 | statusMessage(i18n("Saving addressbook ... ")); |
876 | #ifndef KAB_EMBEDDED | 886 | #ifndef KAB_EMBEDDED |
877 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 887 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
878 | if ( !b || !b->save() ) { | 888 | if ( !b || !b->save() ) { |
879 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 889 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
880 | } | 890 | } |
881 | #else //KAB_EMBEDDED | 891 | #else //KAB_EMBEDDED |
882 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 892 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
883 | if ( !b || !b->save() ) { | 893 | if ( !b || !b->save() ) { |
884 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 894 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
885 | } | 895 | } |
886 | #endif //KAB_EMBEDDED | 896 | #endif //KAB_EMBEDDED |
887 | 897 | ||
888 | statusMessage(i18n("Addressbook saved!")); | 898 | statusMessage(i18n("Addressbook saved!")); |
889 | setModified( false ); | 899 | setModified( false ); |
890 | } | 900 | } |
891 | 901 | ||
892 | void KABCore::statusMessage(QString mess , int time ) | 902 | void KABCore::statusMessage(QString mess , int time ) |
893 | { | 903 | { |
894 | //topLevelWidget()->setCaption( mess ); | 904 | //topLevelWidget()->setCaption( mess ); |
895 | // pending setting timer to revome message | 905 | // pending setting timer to revome message |
896 | } | 906 | } |
897 | void KABCore::undo() | 907 | void KABCore::undo() |
898 | { | 908 | { |
899 | UndoStack::instance()->undo(); | 909 | UndoStack::instance()->undo(); |
900 | 910 | ||
901 | // Refresh the view | 911 | // Refresh the view |
902 | mViewManager->refreshView(); | 912 | mViewManager->refreshView(); |
903 | } | 913 | } |
904 | 914 | ||
905 | void KABCore::redo() | 915 | void KABCore::redo() |
906 | { | 916 | { |
907 | RedoStack::instance()->redo(); | 917 | RedoStack::instance()->redo(); |
908 | 918 | ||
909 | // Refresh the view | 919 | // Refresh the view |
910 | mViewManager->refreshView(); | 920 | mViewManager->refreshView(); |
911 | } | 921 | } |
912 | 922 | ||
913 | void KABCore::setJumpButtonBarVisible( bool visible ) | 923 | void KABCore::setJumpButtonBarVisible( bool visible ) |
914 | { | 924 | { |
915 | if ( visible ) | 925 | if ( visible ) |
916 | mJumpButtonBar->show(); | 926 | mJumpButtonBar->show(); |
917 | else | 927 | else |
918 | mJumpButtonBar->hide(); | 928 | mJumpButtonBar->hide(); |
919 | } | 929 | } |
920 | void KABCore::setDetailsToState() | 930 | void KABCore::setDetailsToState() |
921 | { | 931 | { |
922 | setDetailsVisible( mActionDetails->isChecked() ); | 932 | setDetailsVisible( mActionDetails->isChecked() ); |
923 | } | 933 | } |
924 | 934 | ||
925 | void KABCore::setDetailsVisible( bool visible ) | 935 | void KABCore::setDetailsVisible( bool visible ) |
926 | { | 936 | { |
927 | if ( visible ) | 937 | if ( visible ) |
928 | mDetails->show(); | 938 | mDetails->show(); |
929 | else | 939 | else |
930 | mDetails->hide(); | 940 | mDetails->hide(); |
931 | } | 941 | } |
932 | 942 | ||
933 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 943 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
934 | { | 944 | { |
935 | 945 | ||
936 | if ( list.count() != 0 ) { | 946 | if ( list.count() != 0 ) { |
937 | KABC::Addressee::List::ConstIterator it; | 947 | KABC::Addressee::List::ConstIterator it; |
938 | for ( it = list.begin(); it != list.end(); ++it ) | 948 | for ( it = list.begin(); it != list.end(); ++it ) |
939 | mAddressBook->insertAddressee( *it ); | 949 | mAddressBook->insertAddressee( *it ); |
940 | if ( list.count() > 1 ) | 950 | if ( list.count() > 1 ) |
941 | setModified(); | 951 | setModified(); |
942 | else | 952 | else |
943 | setModifiedWOrefresh(); | 953 | setModifiedWOrefresh(); |
944 | } | 954 | } |
945 | if ( list.count() == 0 ) | 955 | if ( list.count() == 0 ) |
946 | mViewManager->refreshView(); | 956 | mViewManager->refreshView(); |
947 | else | 957 | else |
948 | mViewManager->refreshView( list[ 0 ].uid() ); | 958 | mViewManager->refreshView( list[ 0 ].uid() ); |
949 | 959 | ||
950 | 960 | ||
951 | 961 | ||
952 | } | 962 | } |
953 | 963 | ||
954 | QString KABCore::getNameByPhone( const QString &phone ) | 964 | QString KABCore::getNameByPhone( const QString &phone ) |
955 | { | 965 | { |
956 | #ifndef KAB_EMBEDDED | 966 | #ifndef KAB_EMBEDDED |
957 | QRegExp r( "[/*/-/ ]" ); | 967 | QRegExp r( "[/*/-/ ]" ); |
958 | QString localPhone( phone ); | 968 | QString localPhone( phone ); |
959 | 969 | ||
960 | bool found = false; | 970 | bool found = false; |
961 | QString ownerName = ""; | 971 | QString ownerName = ""; |
962 | KABC::AddressBook::Iterator iter; | 972 | KABC::AddressBook::Iterator iter; |
963 | KABC::PhoneNumber::List::Iterator phoneIter; | 973 | KABC::PhoneNumber::List::Iterator phoneIter; |
964 | KABC::PhoneNumber::List phoneList; | 974 | KABC::PhoneNumber::List phoneList; |
965 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 975 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
966 | phoneList = (*iter).phoneNumbers(); | 976 | phoneList = (*iter).phoneNumbers(); |
967 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 977 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
968 | ++phoneIter) { | 978 | ++phoneIter) { |
969 | // Get rid of separator chars so just the numbers are compared. | 979 | // Get rid of separator chars so just the numbers are compared. |
970 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 980 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
971 | ownerName = (*iter).formattedName(); | 981 | ownerName = (*iter).formattedName(); |
972 | found = true; | 982 | found = true; |
973 | } | 983 | } |
974 | } | 984 | } |
975 | } | 985 | } |
976 | 986 | ||
977 | return ownerName; | 987 | return ownerName; |
978 | #else //KAB_EMBEDDED | 988 | #else //KAB_EMBEDDED |
979 | qDebug("KABCore::getNameByPhone finsih method"); | 989 | qDebug("KABCore::getNameByPhone finsih method"); |
980 | return ""; | 990 | return ""; |
981 | #endif //KAB_EMBEDDED | 991 | #endif //KAB_EMBEDDED |
982 | 992 | ||
983 | } | 993 | } |
984 | 994 | ||
985 | void KABCore::openConfigDialog() | 995 | void KABCore::openConfigDialog() |
986 | { | 996 | { |
987 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 997 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
988 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 998 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
989 | ConfigureDialog->addModule(kabcfg ); | 999 | ConfigureDialog->addModule(kabcfg ); |
990 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1000 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
991 | this, SLOT( configurationChanged() ) ); | 1001 | this, SLOT( configurationChanged() ) ); |
992 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1002 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
993 | this, SLOT( configurationChanged() ) ); | 1003 | this, SLOT( configurationChanged() ) ); |
994 | saveSettings(); | 1004 | saveSettings(); |
995 | ConfigureDialog->exec(); | 1005 | ConfigureDialog->exec(); |
996 | delete ConfigureDialog; | 1006 | delete ConfigureDialog; |
997 | } | 1007 | } |
998 | 1008 | ||
999 | void KABCore::openLDAPDialog() | 1009 | void KABCore::openLDAPDialog() |
1000 | { | 1010 | { |
1001 | #ifndef KAB_EMBEDDED | 1011 | #ifndef KAB_EMBEDDED |
1002 | if ( !mLdapSearchDialog ) { | 1012 | if ( !mLdapSearchDialog ) { |
1003 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1013 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1004 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1014 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1005 | SLOT( refreshView() ) ); | 1015 | SLOT( refreshView() ) ); |
1006 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1016 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1007 | SLOT( setModified() ) ); | 1017 | SLOT( setModified() ) ); |
1008 | } else | 1018 | } else |
1009 | mLdapSearchDialog->restoreSettings(); | 1019 | mLdapSearchDialog->restoreSettings(); |
1010 | 1020 | ||
1011 | if ( mLdapSearchDialog->isOK() ) | 1021 | if ( mLdapSearchDialog->isOK() ) |
1012 | mLdapSearchDialog->exec(); | 1022 | mLdapSearchDialog->exec(); |
1013 | #else //KAB_EMBEDDED | 1023 | #else //KAB_EMBEDDED |
1014 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1024 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1015 | #endif //KAB_EMBEDDED | 1025 | #endif //KAB_EMBEDDED |
1016 | } | 1026 | } |
1017 | 1027 | ||
1018 | void KABCore::print() | 1028 | void KABCore::print() |
1019 | { | 1029 | { |
1020 | #ifndef KAB_EMBEDDED | 1030 | #ifndef KAB_EMBEDDED |
1021 | KPrinter printer; | 1031 | KPrinter printer; |
1022 | if ( !printer.setup( this ) ) | 1032 | if ( !printer.setup( this ) ) |
1023 | return; | 1033 | return; |
1024 | 1034 | ||
1025 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1035 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1026 | mViewManager->selectedUids(), this ); | 1036 | mViewManager->selectedUids(), this ); |
1027 | 1037 | ||
1028 | wizard.exec(); | 1038 | wizard.exec(); |
1029 | #else //KAB_EMBEDDED | 1039 | #else //KAB_EMBEDDED |
1030 | qDebug("KABCore::print() finsih method"); | 1040 | qDebug("KABCore::print() finsih method"); |
1031 | #endif //KAB_EMBEDDED | 1041 | #endif //KAB_EMBEDDED |
1032 | 1042 | ||
1033 | } | 1043 | } |
1034 | 1044 | ||
1035 | 1045 | ||
1036 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1046 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1037 | { | 1047 | { |
1038 | if ( mGUIClient ) | 1048 | if ( mGUIClient ) |
1039 | mGUIClient->insertChildClient( client ); | 1049 | mGUIClient->insertChildClient( client ); |
1040 | else | 1050 | else |
1041 | KMessageBox::error( this, "no KXMLGUICLient"); | 1051 | KMessageBox::error( this, "no KXMLGUICLient"); |
1042 | } | 1052 | } |
1043 | 1053 | ||
1044 | 1054 | ||
1045 | void KABCore::configurationChanged() | 1055 | void KABCore::configurationChanged() |
1046 | { | 1056 | { |
1047 | mExtensionManager->reconfigure(); | 1057 | mExtensionManager->reconfigure(); |
1048 | } | 1058 | } |
1049 | 1059 | ||
1050 | void KABCore::addressBookChanged() | 1060 | void KABCore::addressBookChanged() |
1051 | { | 1061 | { |
1052 | #ifndef KAB_EMBEDDED | 1062 | #ifndef KAB_EMBEDDED |
1053 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1063 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1054 | while ( it.current() ) { | 1064 | while ( it.current() ) { |
1055 | if ( it.current()->dirty() ) { | 1065 | if ( it.current()->dirty() ) { |
1056 | QString text = i18n( "Data has been changed externally. Unsaved " | 1066 | QString text = i18n( "Data has been changed externally. Unsaved " |
1057 | "changes will be lost." ); | 1067 | "changes will be lost." ); |
1058 | KMessageBox::information( this, text ); | 1068 | KMessageBox::information( this, text ); |
1059 | } | 1069 | } |
1060 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1070 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1061 | ++it; | 1071 | ++it; |
1062 | } | 1072 | } |
1063 | 1073 | ||
1064 | mViewManager->refreshView(); | 1074 | mViewManager->refreshView(); |
1065 | #else //KAB_EMBEDDED | 1075 | #else //KAB_EMBEDDED |
1066 | qDebug("KABCore::addressBookChanged() finsih method"); | 1076 | qDebug("KABCore::addressBookChanged() finsih method"); |
1067 | #endif //KAB_EMBEDDED | 1077 | #endif //KAB_EMBEDDED |
1068 | } | 1078 | } |
1069 | 1079 | ||
1070 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1080 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1071 | const char *name ) | 1081 | const char *name ) |
1072 | { | 1082 | { |
1073 | AddresseeEditorDialog *dialog = new AddresseeEditorDialog( this, parent, | 1083 | AddresseeEditorDialog *dialog = new AddresseeEditorDialog( this, parent, |
1074 | name ? name : "editorDialog" ); | 1084 | name ? name : "editorDialog" ); |
1075 | 1085 | ||
1076 | //US | 1086 | //US |
1077 | dialog->setMaximumSize( 640, 480 ); | 1087 | dialog->setMaximumSize( 640, 480 ); |
1078 | dialog->showMaximized(); | 1088 | dialog->showMaximized(); |
1079 | 1089 | ||
1080 | connect( dialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1090 | connect( dialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1081 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1091 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1082 | connect( dialog, SIGNAL( editorDestroyed( const QString& ) ), | 1092 | connect( dialog, SIGNAL( editorDestroyed( const QString& ) ), |
1083 | SLOT( slotEditorDestroyed( const QString& ) ) ); | 1093 | SLOT( slotEditorDestroyed( const QString& ) ) ); |
1084 | 1094 | ||
1085 | return dialog; | 1095 | return dialog; |
1086 | } | 1096 | } |
1087 | 1097 | ||
1088 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1098 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1089 | { | 1099 | { |
1090 | mEditorDict.remove( uid ); | 1100 | mEditorDict.remove( uid ); |
1091 | } | 1101 | } |
1092 | 1102 | ||
1093 | void KABCore::initGUI() | 1103 | void KABCore::initGUI() |
1094 | { | 1104 | { |
1095 | #ifndef KAB_EMBEDDED | 1105 | #ifndef KAB_EMBEDDED |
1096 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1106 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1097 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1107 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1098 | 1108 | ||
1099 | mExtensionBarSplitter = new QSplitter( this ); | 1109 | mExtensionBarSplitter = new QSplitter( this ); |
1100 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1110 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1101 | 1111 | ||
1102 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1112 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1103 | 1113 | ||
1104 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1114 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1105 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1115 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1106 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1116 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1107 | SLOT( incrementalSearch( const QString& ) ) ); | 1117 | SLOT( incrementalSearch( const QString& ) ) ); |
1108 | 1118 | ||
1109 | mViewManager = new ViewManager( this, viewSpace ); | 1119 | mViewManager = new ViewManager( this, viewSpace ); |
1110 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1120 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1111 | 1121 | ||
1112 | mDetails = new ViewContainer( mDetailsSplitter ); | 1122 | mDetails = new ViewContainer( mDetailsSplitter ); |
1113 | 1123 | ||
1114 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1124 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1115 | 1125 | ||
1116 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1126 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1117 | 1127 | ||
1118 | topLayout->addWidget( mExtensionBarSplitter ); | 1128 | topLayout->addWidget( mExtensionBarSplitter ); |
1119 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1129 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1120 | topLayout->addWidget( mJumpButtonBar ); | 1130 | topLayout->addWidget( mJumpButtonBar ); |
1121 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1131 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1122 | 1132 | ||
1123 | mXXPortManager = new XXPortManager( this, this ); | 1133 | mXXPortManager = new XXPortManager( this, this ); |
1124 | 1134 | ||
1125 | #else //KAB_EMBEDDED | 1135 | #else //KAB_EMBEDDED |
1126 | //US initialize viewMenu before settingup viewmanager. | 1136 | //US initialize viewMenu before settingup viewmanager. |
1127 | // Viewmanager needs this menu to plugin submenues. | 1137 | // Viewmanager needs this menu to plugin submenues. |
1128 | viewMenu = new QPopupMenu( this ); | 1138 | viewMenu = new QPopupMenu( this ); |
1129 | settingsMenu = new QPopupMenu( this ); | 1139 | settingsMenu = new QPopupMenu( this ); |
1130 | //filterMenu = new QPopupMenu( this ); | 1140 | //filterMenu = new QPopupMenu( this ); |
1131 | ImportMenu = new QPopupMenu( this ); | 1141 | ImportMenu = new QPopupMenu( this ); |
1132 | ExportMenu = new QPopupMenu( this ); | 1142 | ExportMenu = new QPopupMenu( this ); |
1133 | 1143 | ||
1134 | 1144 | ||
1135 | //US since we have no splitter for the embedded system, setup | 1145 | //US since we have no splitter for the embedded system, setup |
1136 | // a layout with two frames. One left and one right. | 1146 | // a layout with two frames. One left and one right. |
1137 | 1147 | ||
1138 | QBoxLayout *topLayout; | 1148 | QBoxLayout *topLayout; |
1139 | 1149 | ||
1140 | // = new QHBoxLayout( this ); | 1150 | // = new QHBoxLayout( this ); |
1141 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1151 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1142 | 1152 | ||
1143 | // QWidget *mainBox = new QWidget( this ); | 1153 | // QWidget *mainBox = new QWidget( this ); |
1144 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1154 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1145 | 1155 | ||
1146 | 1156 | #ifdef DESKTOP_VERSION | |
1157 | topLayout = new QHBoxLayout( this ); | ||
1158 | |||
1159 | |||
1160 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | ||
1161 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | ||
1162 | |||
1163 | topLayout->addWidget(mMiniSplitter ); | ||
1164 | |||
1165 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | ||
1166 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | ||
1167 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | ||
1168 | mDetails = new ViewContainer( mMiniSplitter ); | ||
1169 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | ||
1170 | #else | ||
1147 | if ( QApplication::desktop()->width() > 480 ) { | 1171 | if ( QApplication::desktop()->width() > 480 ) { |
1148 | topLayout = new QHBoxLayout( this ); | 1172 | topLayout = new QHBoxLayout( this ); |
1149 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1173 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1150 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1174 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1151 | } else { | 1175 | } else { |
1152 | 1176 | ||
1153 | topLayout = new QVBoxLayout( this ); | 1177 | topLayout = new QVBoxLayout( this ); |
1154 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1178 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1155 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1179 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1156 | } | 1180 | } |
1157 | 1181 | ||
1158 | topLayout->addWidget(mMiniSplitter ); | 1182 | topLayout->addWidget(mMiniSplitter ); |
1159 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1183 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1160 | mDetails = new ViewContainer( mMiniSplitter ); | 1184 | mDetails = new ViewContainer( mMiniSplitter ); |
1161 | 1185 | ||
1162 | 1186 | ||
1163 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1187 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1164 | 1188 | #endif | |
1165 | //eh->hide(); | 1189 | //eh->hide(); |
1166 | // topLayout->addWidget(mExtensionManager ); | 1190 | // topLayout->addWidget(mExtensionManager ); |
1167 | 1191 | ||
1168 | 1192 | ||
1169 | /*US | 1193 | /*US |
1170 | #ifndef KAB_NOSPLITTER | 1194 | #ifndef KAB_NOSPLITTER |
1171 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1195 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1172 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1196 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1173 | topLayout->setSpacing( 10 ); | 1197 | topLayout->setSpacing( 10 ); |
1174 | 1198 | ||
1175 | mDetailsSplitter = new QSplitter( this ); | 1199 | mDetailsSplitter = new QSplitter( this ); |
1176 | 1200 | ||
1177 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1201 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1178 | 1202 | ||
1179 | mViewManager = new ViewManager( this, viewSpace ); | 1203 | mViewManager = new ViewManager( this, viewSpace ); |
1180 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1204 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1181 | 1205 | ||
1182 | mDetails = new ViewContainer( mDetailsSplitter ); | 1206 | mDetails = new ViewContainer( mDetailsSplitter ); |
1183 | 1207 | ||
1184 | topLayout->addWidget( mDetailsSplitter ); | 1208 | topLayout->addWidget( mDetailsSplitter ); |
1185 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1209 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1186 | #else //KAB_NOSPLITTER | 1210 | #else //KAB_NOSPLITTER |
1187 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1211 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1188 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1212 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1189 | topLayout->setSpacing( 10 ); | 1213 | topLayout->setSpacing( 10 ); |
1190 | 1214 | ||
1191 | // mDetailsSplitter = new QSplitter( this ); | 1215 | // mDetailsSplitter = new QSplitter( this ); |
1192 | 1216 | ||
1193 | QVBox *viewSpace = new QVBox( this ); | 1217 | QVBox *viewSpace = new QVBox( this ); |
1194 | 1218 | ||
1195 | mViewManager = new ViewManager( this, viewSpace ); | 1219 | mViewManager = new ViewManager( this, viewSpace ); |
1196 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1220 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1197 | 1221 | ||
1198 | mDetails = new ViewContainer( this ); | 1222 | mDetails = new ViewContainer( this ); |
1199 | 1223 | ||
1200 | topLayout->addWidget( viewSpace ); | 1224 | topLayout->addWidget( viewSpace ); |
1201 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1225 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1202 | topLayout->addWidget( mDetails ); | 1226 | topLayout->addWidget( mDetails ); |
1203 | #endif //KAB_NOSPLITTER | 1227 | #endif //KAB_NOSPLITTER |
1204 | */ | 1228 | */ |
1205 | 1229 | ||
1206 | 1230 | ||
1207 | #endif //KAB_EMBEDDED | 1231 | #endif //KAB_EMBEDDED |
1208 | initActions(); | 1232 | initActions(); |
1209 | 1233 | ||
1210 | #ifdef KAB_EMBEDDED | 1234 | #ifdef KAB_EMBEDDED |
1211 | addActionsManually(); | 1235 | addActionsManually(); |
1212 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1236 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1213 | mXXPortManager = new XXPortManager( this, this ); | 1237 | mXXPortManager = new XXPortManager( this, this ); |
1214 | 1238 | ||
1215 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1239 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1216 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1240 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1217 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1241 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1218 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1242 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1219 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1243 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1220 | // mIncSearchWidget->hide(); | 1244 | // mIncSearchWidget->hide(); |
1221 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1245 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1222 | SLOT( incrementalSearch( const QString& ) ) ); | 1246 | SLOT( incrementalSearch( const QString& ) ) ); |
1223 | 1247 | ||
1224 | 1248 | ||
1225 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1249 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1226 | 1250 | ||
1227 | topLayout->addWidget( mJumpButtonBar ); | 1251 | topLayout->addWidget( mJumpButtonBar ); |
1228 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1252 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1229 | 1253 | ||
1230 | // mMainWindow->getIconToolBar()->raise(); | 1254 | // mMainWindow->getIconToolBar()->raise(); |
1231 | 1255 | ||
1232 | #endif //KAB_EMBEDDED | 1256 | #endif //KAB_EMBEDDED |
1233 | 1257 | ||
1234 | } | 1258 | } |
1235 | void KABCore::initActions() | 1259 | void KABCore::initActions() |
1236 | { | 1260 | { |
1237 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1261 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1238 | 1262 | ||
1239 | #ifndef KAB_EMBEDDED | 1263 | #ifndef KAB_EMBEDDED |
1240 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1264 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1241 | SLOT( clipboardDataChanged() ) ); | 1265 | SLOT( clipboardDataChanged() ) ); |
1242 | #endif //KAB_EMBEDDED | 1266 | #endif //KAB_EMBEDDED |
1243 | 1267 | ||
1244 | // file menu | 1268 | // file menu |
1245 | if ( mIsPart ) { | 1269 | if ( mIsPart ) { |
1246 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1270 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1247 | SLOT( sendMail() ), actionCollection(), | 1271 | SLOT( sendMail() ), actionCollection(), |
1248 | "kaddressbook_mail" ); | 1272 | "kaddressbook_mail" ); |
1249 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1273 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1250 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1274 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1251 | 1275 | ||
1252 | } else { | 1276 | } else { |
1253 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1277 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1254 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1278 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1255 | } | 1279 | } |
1256 | 1280 | ||
1257 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1281 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1258 | SLOT( save() ), actionCollection(), "file_sync" ); | 1282 | SLOT( save() ), actionCollection(), "file_sync" ); |
1259 | 1283 | ||
1260 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1284 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1261 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1285 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1262 | 1286 | ||
1263 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1287 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1264 | this, SLOT( mailVCard() ), | 1288 | this, SLOT( mailVCard() ), |
1265 | actionCollection(), "file_mail_vcard"); | 1289 | actionCollection(), "file_mail_vcard"); |
1266 | 1290 | ||
1267 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1291 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1268 | this, SLOT( editContact2() ), | 1292 | this, SLOT( editContact2() ), |
1269 | actionCollection(), "file_properties" ); | 1293 | actionCollection(), "file_properties" ); |
1270 | 1294 | ||
1271 | #ifdef KAB_EMBEDDED | 1295 | #ifdef KAB_EMBEDDED |
1272 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1296 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1273 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1297 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1274 | mMainWindow, SLOT( exit() ), | 1298 | mMainWindow, SLOT( exit() ), |
1275 | actionCollection(), "quit" ); | 1299 | actionCollection(), "quit" ); |
1276 | #endif //KAB_EMBEDDED | 1300 | #endif //KAB_EMBEDDED |
1277 | 1301 | ||
1278 | // edit menu | 1302 | // edit menu |
1279 | if ( mIsPart ) { | 1303 | if ( mIsPart ) { |
1280 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1304 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1281 | SLOT( copyContacts() ), actionCollection(), | 1305 | SLOT( copyContacts() ), actionCollection(), |
1282 | "kaddressbook_copy" ); | 1306 | "kaddressbook_copy" ); |
1283 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1307 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1284 | SLOT( cutContacts() ), actionCollection(), | 1308 | SLOT( cutContacts() ), actionCollection(), |
1285 | "kaddressbook_cut" ); | 1309 | "kaddressbook_cut" ); |
1286 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1310 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1287 | SLOT( pasteContacts() ), actionCollection(), | 1311 | SLOT( pasteContacts() ), actionCollection(), |
1288 | "kaddressbook_paste" ); | 1312 | "kaddressbook_paste" ); |
1289 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1313 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1290 | SLOT( selectAllContacts() ), actionCollection(), | 1314 | SLOT( selectAllContacts() ), actionCollection(), |
1291 | "kaddressbook_select_all" ); | 1315 | "kaddressbook_select_all" ); |
1292 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1316 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1293 | SLOT( undo() ), actionCollection(), | 1317 | SLOT( undo() ), actionCollection(), |
1294 | "kaddressbook_undo" ); | 1318 | "kaddressbook_undo" ); |
1295 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1319 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1296 | this, SLOT( redo() ), actionCollection(), | 1320 | this, SLOT( redo() ), actionCollection(), |
1297 | "kaddressbook_redo" ); | 1321 | "kaddressbook_redo" ); |
1298 | } else { | 1322 | } else { |
1299 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1323 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1300 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1324 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1301 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1325 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1302 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1326 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1303 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1327 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1304 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1328 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1305 | } | 1329 | } |
1306 | 1330 | ||
1307 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1331 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1308 | Key_Delete, this, SLOT( deleteContacts() ), | 1332 | Key_Delete, this, SLOT( deleteContacts() ), |
1309 | actionCollection(), "edit_delete" ); | 1333 | actionCollection(), "edit_delete" ); |
1310 | 1334 | ||
1311 | mActionUndo->setEnabled( false ); | 1335 | mActionUndo->setEnabled( false ); |
1312 | mActionRedo->setEnabled( false ); | 1336 | mActionRedo->setEnabled( false ); |
1313 | 1337 | ||
1314 | // settings menu | 1338 | // settings menu |
1315 | #ifdef KAB_EMBEDDED | 1339 | #ifdef KAB_EMBEDDED |
1316 | //US special menuentry to configure the addressbook resources. On KDE | 1340 | //US special menuentry to configure the addressbook resources. On KDE |
1317 | // you do that through the control center !!! | 1341 | // you do that through the control center !!! |
1318 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1342 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1319 | SLOT( configureResources() ), actionCollection(), | 1343 | SLOT( configureResources() ), actionCollection(), |
1320 | "kaddressbook_configure_resources" ); | 1344 | "kaddressbook_configure_resources" ); |
1321 | #endif //KAB_EMBEDDED | 1345 | #endif //KAB_EMBEDDED |
1322 | 1346 | ||
1323 | if ( mIsPart ) { | 1347 | if ( mIsPart ) { |
1324 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1348 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1325 | SLOT( openConfigDialog() ), actionCollection(), | 1349 | SLOT( openConfigDialog() ), actionCollection(), |
1326 | "kaddressbook_configure" ); | 1350 | "kaddressbook_configure" ); |
1327 | 1351 | ||
1328 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1352 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1329 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1353 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1330 | "kaddressbook_configure_shortcuts" ); | 1354 | "kaddressbook_configure_shortcuts" ); |
1331 | #ifdef KAB_EMBEDDED | 1355 | #ifdef KAB_EMBEDDED |
1332 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1356 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1333 | #endif //KAB_EMBEDDED | 1357 | #endif //KAB_EMBEDDED |
1334 | 1358 | ||
1335 | } else { | 1359 | } else { |
1336 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1360 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1337 | 1361 | ||
1338 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1362 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1339 | } | 1363 | } |
1340 | 1364 | ||
1341 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1365 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1342 | actionCollection(), "options_show_jump_bar" ); | 1366 | actionCollection(), "options_show_jump_bar" ); |
1343 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1367 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1344 | 1368 | ||
1345 | mActionDetails = new KToggleAction( i18n( "Show Details" ), 0, 0, | 1369 | mActionDetails = new KToggleAction( i18n( "Show Details" ), 0, 0, |
1346 | actionCollection(), "options_show_details" ); | 1370 | actionCollection(), "options_show_details" ); |
1347 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1371 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1348 | 1372 | ||
1349 | // misc | 1373 | // misc |
1350 | // only enable LDAP lookup if we can handle the protocol | 1374 | // only enable LDAP lookup if we can handle the protocol |
1351 | #ifndef KAB_EMBEDDED | 1375 | #ifndef KAB_EMBEDDED |
1352 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1376 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1353 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1377 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1354 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1378 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1355 | "ldap_lookup" ); | 1379 | "ldap_lookup" ); |
1356 | } | 1380 | } |
1357 | #else //KAB_EMBEDDED | 1381 | #else //KAB_EMBEDDED |
1358 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1382 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1359 | #endif //KAB_EMBEDDED | 1383 | #endif //KAB_EMBEDDED |
1360 | 1384 | ||
1361 | 1385 | ||
1362 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1386 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1363 | SLOT( setWhoAmI() ), actionCollection(), | 1387 | SLOT( setWhoAmI() ), actionCollection(), |
1364 | "set_personal" ); | 1388 | "set_personal" ); |
1365 | 1389 | ||
1366 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1390 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1367 | SLOT( setCategories() ), actionCollection(), | 1391 | SLOT( setCategories() ), actionCollection(), |
1368 | "edit_set_categories" ); | 1392 | "edit_set_categories" ); |
1369 | 1393 | ||
1370 | #ifdef KAB_EMBEDDED | 1394 | #ifdef KAB_EMBEDDED |
1371 | 1395 | ||
1372 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1396 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1373 | this, SLOT( createAboutData() ), actionCollection(), | 1397 | this, SLOT( createAboutData() ), actionCollection(), |
1374 | "kaddressbook_about_data" ); | 1398 | "kaddressbook_about_data" ); |
1375 | #endif //KAB_EMBEDDED | 1399 | #endif //KAB_EMBEDDED |
1376 | 1400 | ||
1377 | clipboardDataChanged(); | 1401 | clipboardDataChanged(); |
1378 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1402 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1379 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1403 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1380 | } | 1404 | } |
1381 | 1405 | ||
1382 | //US we need this function, to plug all actions into the correct menues. | 1406 | //US we need this function, to plug all actions into the correct menues. |
1383 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1407 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1384 | void KABCore::addActionsManually() | 1408 | void KABCore::addActionsManually() |
1385 | { | 1409 | { |
1386 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1410 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1387 | 1411 | ||
1388 | #ifdef KAB_EMBEDDED | 1412 | #ifdef KAB_EMBEDDED |
1389 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1413 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1390 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1414 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1391 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1415 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1392 | 1416 | ||
1393 | KToolBar* tb = mMainWindow->toolBar(); | 1417 | KToolBar* tb = mMainWindow->toolBar(); |
1394 | 1418 | ||
1395 | #ifdef DESKTOP_VERSION | 1419 | #ifdef DESKTOP_VERSION |
1396 | QMenuBar* mb = mMainWindow->menuBar(); | 1420 | QMenuBar* mb = mMainWindow->menuBar(); |
1397 | 1421 | ||
1398 | //US setup menubar. | 1422 | //US setup menubar. |
1399 | //Disable the following block if you do not want to have a menubar. | 1423 | //Disable the following block if you do not want to have a menubar. |
1400 | mb->insertItem( "&File", fileMenu ); | 1424 | mb->insertItem( "&File", fileMenu ); |
1401 | mb->insertItem( "&Edit", editMenu ); | 1425 | mb->insertItem( "&Edit", editMenu ); |
1402 | mb->insertItem( "&View", viewMenu ); | 1426 | mb->insertItem( "&View", viewMenu ); |
1403 | mb->insertItem( "&Settings", settingsMenu ); | 1427 | mb->insertItem( "&Settings", settingsMenu ); |
1404 | mb->insertItem( "&Help", helpMenu ); | 1428 | mb->insertItem( "&Help", helpMenu ); |
1405 | mIncSearchWidget = new IncSearchWidget( tb ); | 1429 | mIncSearchWidget = new IncSearchWidget( tb ); |
1406 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1430 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1407 | 1431 | ||
1408 | #else | 1432 | #else |
1409 | //US setup toolbar | 1433 | //US setup toolbar |
1410 | QMenuBar *menuBarTB = new QMenuBar( tb ); | 1434 | QMenuBar *menuBarTB = new QMenuBar( tb ); |
1411 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1435 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1412 | menuBarTB->insertItem( "ME", popupBarTB); | 1436 | menuBarTB->insertItem( "ME", popupBarTB); |
1413 | tb->insertWidget(-1, 0, menuBarTB); | 1437 | tb->insertWidget(-1, 0, menuBarTB); |
1414 | mIncSearchWidget = new IncSearchWidget( tb ); | 1438 | mIncSearchWidget = new IncSearchWidget( tb ); |
1415 | 1439 | ||
1416 | tb->enableMoving(false); | 1440 | tb->enableMoving(false); |
1417 | popupBarTB->insertItem( "&File", fileMenu ); | 1441 | popupBarTB->insertItem( "&File", fileMenu ); |
1418 | popupBarTB->insertItem( "&Edit", editMenu ); | 1442 | popupBarTB->insertItem( "&Edit", editMenu ); |
1419 | popupBarTB->insertItem( "&View", viewMenu ); | 1443 | popupBarTB->insertItem( "&View", viewMenu ); |
1420 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1444 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1421 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1445 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1422 | popupBarTB->insertItem( "&Help", helpMenu ); | 1446 | popupBarTB->insertItem( "&Help", helpMenu ); |
1423 | if (QApplication::desktop()->width() > 320 ) { | 1447 | if (QApplication::desktop()->width() > 320 ) { |
1424 | // mViewManager->getFilterAction()->plug ( tb); | 1448 | // mViewManager->getFilterAction()->plug ( tb); |
1425 | } | 1449 | } |
1426 | #endif | 1450 | #endif |
1427 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1451 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1428 | 1452 | ||
1429 | 1453 | ||
1430 | 1454 | ||
1431 | //US Now connect the actions with the menue entries. | 1455 | //US Now connect the actions with the menue entries. |
1432 | mActionPrint->plug( fileMenu ); | 1456 | mActionPrint->plug( fileMenu ); |
1433 | mActionMail->plug( fileMenu ); | 1457 | mActionMail->plug( fileMenu ); |
1434 | fileMenu->insertSeparator(); | 1458 | fileMenu->insertSeparator(); |
1435 | 1459 | ||
1436 | mActionNewContact->plug( fileMenu ); | 1460 | mActionNewContact->plug( fileMenu ); |
1437 | mActionNewContact->plug( tb ); | 1461 | mActionNewContact->plug( tb ); |
1438 | 1462 | ||
1439 | mActionEditAddressee->plug( fileMenu ); | 1463 | mActionEditAddressee->plug( fileMenu ); |
1440 | fileMenu->insertSeparator(); | 1464 | fileMenu->insertSeparator(); |
1441 | mActionSave->plug( fileMenu ); | 1465 | mActionSave->plug( fileMenu ); |
1442 | fileMenu->insertItem( "&Import", ImportMenu ); | 1466 | fileMenu->insertItem( "&Import", ImportMenu ); |
1443 | fileMenu->insertItem( "&Emport", ExportMenu ); | 1467 | fileMenu->insertItem( "&Emport", ExportMenu ); |
1444 | fileMenu->insertSeparator(); | 1468 | fileMenu->insertSeparator(); |
1445 | mActionMailVCard->plug( fileMenu ); | 1469 | mActionMailVCard->plug( fileMenu ); |
1446 | fileMenu->insertSeparator(); | 1470 | fileMenu->insertSeparator(); |
1447 | mActionQuit->plug( fileMenu ); | 1471 | mActionQuit->plug( fileMenu ); |
1448 | 1472 | ||
1449 | 1473 | ||
1450 | // edit menu | 1474 | // edit menu |
1451 | mActionUndo->plug( editMenu ); | 1475 | mActionUndo->plug( editMenu ); |
1452 | mActionRedo->plug( editMenu ); | 1476 | mActionRedo->plug( editMenu ); |
1453 | editMenu->insertSeparator(); | 1477 | editMenu->insertSeparator(); |
1454 | mActionCut->plug( editMenu ); | 1478 | mActionCut->plug( editMenu ); |
1455 | mActionCopy->plug( editMenu ); | 1479 | mActionCopy->plug( editMenu ); |
1456 | mActionPaste->plug( editMenu ); | 1480 | mActionPaste->plug( editMenu ); |
1457 | mActionDelete->plug( editMenu ); | 1481 | mActionDelete->plug( editMenu ); |
1458 | editMenu->insertSeparator(); | 1482 | editMenu->insertSeparator(); |
1459 | mActionSelectAll->plug( editMenu ); | 1483 | mActionSelectAll->plug( editMenu ); |
1460 | 1484 | ||
1461 | 1485 | ||
1462 | // settings menu | 1486 | // settings menu |
1463 | //US special menuentry to configure the addressbook resources. On KDE | 1487 | //US special menuentry to configure the addressbook resources. On KDE |
1464 | // you do that through the control center !!! | 1488 | // you do that through the control center !!! |
1465 | mActionConfigResources->plug( settingsMenu ); | 1489 | mActionConfigResources->plug( settingsMenu ); |
1466 | settingsMenu->insertSeparator(); | 1490 | settingsMenu->insertSeparator(); |
1467 | 1491 | ||
1468 | mActionConfigKAddressbook->plug( settingsMenu ); | 1492 | mActionConfigKAddressbook->plug( settingsMenu ); |
1469 | 1493 | ||
1470 | if ( mIsPart ) { | 1494 | if ( mIsPart ) { |
1471 | mActionConfigShortcuts->plug( settingsMenu ); | 1495 | mActionConfigShortcuts->plug( settingsMenu ); |
1472 | mActionConfigureToolbars->plug( settingsMenu ); | 1496 | mActionConfigureToolbars->plug( settingsMenu ); |
1473 | 1497 | ||
1474 | } else { | 1498 | } else { |
1475 | mActionKeyBindings->plug( settingsMenu ); | 1499 | mActionKeyBindings->plug( settingsMenu ); |
1476 | } | 1500 | } |
1477 | 1501 | ||
1478 | settingsMenu->insertSeparator(); | 1502 | settingsMenu->insertSeparator(); |
1479 | 1503 | ||
1480 | mActionJumpBar->plug( settingsMenu ); | 1504 | mActionJumpBar->plug( settingsMenu ); |
1481 | mActionDetails->plug( settingsMenu ); | 1505 | mActionDetails->plug( settingsMenu ); |
1482 | settingsMenu->insertSeparator(); | 1506 | settingsMenu->insertSeparator(); |
1483 | 1507 | ||
1484 | mActionWhoAmI->plug( settingsMenu ); | 1508 | mActionWhoAmI->plug( settingsMenu ); |
1485 | mActionCategories->plug( settingsMenu ); | 1509 | mActionCategories->plug( settingsMenu ); |
1486 | 1510 | ||
1487 | mActionAboutKAddressbook->plug( helpMenu ); | 1511 | mActionAboutKAddressbook->plug( helpMenu ); |
1488 | 1512 | ||
1513 | |||
1489 | if (QApplication::desktop()->width() > 320 ) { | 1514 | if (QApplication::desktop()->width() > 320 ) { |
1490 | 1515 | ||
1491 | mActionEditAddressee->plug( tb ); | 1516 | mActionEditAddressee->plug( tb ); |
1492 | mActionSave->plug( tb ); | 1517 | mActionSave->plug( tb ); |
1493 | mViewManager->getFilterAction()->plug ( tb); | 1518 | mViewManager->getFilterAction()->plug ( tb); |
1494 | if (QApplication::desktop()->width() > 480 ) | 1519 | if (QApplication::desktop()->width() > 480 ) { |
1495 | mActionDelete->plug( tb ); | 1520 | mActionUndo->plug( tb ); |
1521 | mActionDelete->plug( tb ); | ||
1522 | mActionRedo->plug( tb ); | ||
1523 | } | ||
1496 | } | 1524 | } |
1497 | mActionQuit->plug ( tb ); | 1525 | //mActionQuit->plug ( tb ); |
1498 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 1526 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
1499 | 1527 | ||
1500 | //US link the searchwidget first to this. | 1528 | //US link the searchwidget first to this. |
1501 | // The real linkage to the toolbar happens later. | 1529 | // The real linkage to the toolbar happens later. |
1502 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 1530 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
1503 | //US tb->insertItem( mIncSearchWidget ); | 1531 | //US tb->insertItem( mIncSearchWidget ); |
1504 | /*US | 1532 | /*US |
1505 | mIncSearchWidget = new IncSearchWidget( tb ); | 1533 | mIncSearchWidget = new IncSearchWidget( tb ); |
1506 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1534 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1507 | SLOT( incrementalSearch( const QString& ) ) ); | 1535 | SLOT( incrementalSearch( const QString& ) ) ); |
1508 | 1536 | ||
1509 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1537 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1510 | 1538 | ||
1511 | //US topLayout->addWidget( mJumpButtonBar ); | 1539 | //US topLayout->addWidget( mJumpButtonBar ); |
1512 | this->layout()->add( mJumpButtonBar ); | 1540 | this->layout()->add( mJumpButtonBar ); |
1513 | */ | 1541 | */ |
1514 | 1542 | ||
1515 | #endif //KAB_EMBEDDED | 1543 | #endif //KAB_EMBEDDED |
1516 | } | 1544 | } |
1517 | 1545 | ||
1518 | 1546 | ||
1519 | 1547 | ||
1520 | void KABCore::clipboardDataChanged() | 1548 | void KABCore::clipboardDataChanged() |
1521 | { | 1549 | { |
1522 | 1550 | ||
1523 | if ( mReadWrite ) | 1551 | if ( mReadWrite ) |
1524 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 1552 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
1525 | 1553 | ||
1526 | } | 1554 | } |
1527 | 1555 | ||
1528 | void KABCore::updateActionMenu() | 1556 | void KABCore::updateActionMenu() |
1529 | { | 1557 | { |
1530 | UndoStack *undo = UndoStack::instance(); | 1558 | UndoStack *undo = UndoStack::instance(); |
1531 | RedoStack *redo = RedoStack::instance(); | 1559 | RedoStack *redo = RedoStack::instance(); |
1532 | 1560 | ||
1533 | if ( undo->isEmpty() ) | 1561 | if ( undo->isEmpty() ) |
1534 | mActionUndo->setText( i18n( "Undo" ) ); | 1562 | mActionUndo->setText( i18n( "Undo" ) ); |
1535 | else | 1563 | else |
1536 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 1564 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
1537 | 1565 | ||
1538 | mActionUndo->setEnabled( !undo->isEmpty() ); | 1566 | mActionUndo->setEnabled( !undo->isEmpty() ); |
1539 | 1567 | ||
1540 | if ( !redo->top() ) | 1568 | if ( !redo->top() ) |
1541 | mActionRedo->setText( i18n( "Redo" ) ); | 1569 | mActionRedo->setText( i18n( "Redo" ) ); |
1542 | else | 1570 | else |
1543 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 1571 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
1544 | 1572 | ||
1545 | mActionRedo->setEnabled( !redo->isEmpty() ); | 1573 | mActionRedo->setEnabled( !redo->isEmpty() ); |
1546 | } | 1574 | } |
1547 | 1575 | ||
1548 | void KABCore::configureKeyBindings() | 1576 | void KABCore::configureKeyBindings() |
1549 | { | 1577 | { |
1550 | #ifndef KAB_EMBEDDED | 1578 | #ifndef KAB_EMBEDDED |
1551 | KKeyDialog::configure( actionCollection(), true ); | 1579 | KKeyDialog::configure( actionCollection(), true ); |
1552 | #else //KAB_EMBEDDED | 1580 | #else //KAB_EMBEDDED |
1553 | qDebug("KABCore::configureKeyBindings() not implemented"); | 1581 | qDebug("KABCore::configureKeyBindings() not implemented"); |
1554 | #endif //KAB_EMBEDDED | 1582 | #endif //KAB_EMBEDDED |
1555 | } | 1583 | } |
1556 | 1584 | ||
1557 | #ifdef KAB_EMBEDDED | 1585 | #ifdef KAB_EMBEDDED |
1558 | void KABCore::configureResources() | 1586 | void KABCore::configureResources() |
1559 | { | 1587 | { |
1560 | KRES::KCMKResources dlg( this, "" , 0 ); | 1588 | KRES::KCMKResources dlg( this, "" , 0 ); |
1561 | 1589 | ||
1562 | if ( !dlg.exec() ) | 1590 | if ( !dlg.exec() ) |
1563 | return; | 1591 | return; |
1564 | } | 1592 | } |
1565 | #endif //KAB_EMBEDDED | 1593 | #endif //KAB_EMBEDDED |
1566 | 1594 | ||
1567 | 1595 | ||
1568 | 1596 | ||
1569 | #ifndef KAB_EMBEDDED | 1597 | #ifndef KAB_EMBEDDED |
1570 | #include "kabcore.moc" | 1598 | #include "kabcore.moc" |
1571 | #endif //KAB_EMBEDDED | 1599 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index edf98c2..b84ec22 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -1,421 +1,421 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@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 | #ifndef KABCORE_H | 24 | #ifndef KABCORE_H |
25 | #define KABCORE_H | 25 | #define KABCORE_H |
26 | 26 | ||
27 | #include <kabc/field.h> | 27 | #include <kabc/field.h> |
28 | 28 | ||
29 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
30 | #endif //KAB_EMBEDDED | 30 | #endif //KAB_EMBEDDED |
31 | #include <qdict.h> | 31 | #include <qdict.h> |
32 | 32 | ||
33 | #include <qwidget.h> | 33 | #include <qwidget.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | 35 | ||
36 | namespace KABC { | 36 | namespace KABC { |
37 | class AddressBook; | 37 | class AddressBook; |
38 | } | 38 | } |
39 | 39 | ||
40 | #ifndef KAB_EMBEDDED | 40 | #ifndef KAB_EMBEDDED |
41 | class KAboutData; | 41 | class KAboutData; |
42 | class KConfig; | 42 | class KConfig; |
43 | 43 | ||
44 | class KAddressBookService; | 44 | class KAddressBookService; |
45 | class LDAPSearchDialog; | 45 | class LDAPSearchDialog; |
46 | #else //KAB_EMBEDDED | 46 | #else //KAB_EMBEDDED |
47 | class KAddressBookMain; | 47 | class KAddressBookMain; |
48 | //US class QAction; | 48 | //US class QAction; |
49 | #endif //KAB_EMBEDDED | 49 | #endif //KAB_EMBEDDED |
50 | class KCMultiDialog; | 50 | class KCMultiDialog; |
51 | class KXMLGUIClient; | 51 | class KXMLGUIClient; |
52 | class ExtensionManager; | 52 | class ExtensionManager; |
53 | class XXPortManager; | 53 | class XXPortManager; |
54 | class JumpButtonBar; | 54 | class JumpButtonBar; |
55 | class IncSearchWidget; | 55 | class IncSearchWidget; |
56 | class KDGanttMinimizeSplitter; | 56 | class KDGanttMinimizeSplitter; |
57 | class KAction; | 57 | class KAction; |
58 | class KActionCollection; | 58 | class KActionCollection; |
59 | class KToggleAction; | 59 | class KToggleAction; |
60 | 60 | ||
61 | class QAction; | 61 | class QAction; |
62 | class QMenuBar; | 62 | class QMenuBar; |
63 | class QSplitter; | 63 | class QSplitter; |
64 | class ViewContainer; | 64 | class ViewContainer; |
65 | class ViewManager; | 65 | class ViewManager; |
66 | class AddresseeEditorDialog; | 66 | class AddresseeEditorDialog; |
67 | 67 | ||
68 | class KABCore : public QWidget | 68 | class KABCore : public QWidget |
69 | { | 69 | { |
70 | Q_OBJECT | 70 | Q_OBJECT |
71 | 71 | ||
72 | public: | 72 | public: |
73 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); | 73 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); |
74 | 74 | ||
75 | 75 | ||
76 | ~KABCore(); | 76 | ~KABCore(); |
77 | 77 | ||
78 | 78 | ||
79 | #ifdef KAB_EMBEDDED | 79 | #ifdef KAB_EMBEDDED |
80 | //US added functionality | 80 | //US added functionality |
81 | QPopupMenu* getViewMenu() {return viewMenu;} | 81 | QPopupMenu* getViewMenu() {return viewMenu;} |
82 | QPopupMenu* getFilterMenu() {return filterMenu;} | 82 | QPopupMenu* getFilterMenu() {return filterMenu;} |
83 | QPopupMenu* getSettingsMenu() {return settingsMenu;} | 83 | QPopupMenu* getSettingsMenu() {return settingsMenu;} |
84 | void addActionsManually(); | 84 | void addActionsManually(); |
85 | #endif //KAB_EMBEDDED | 85 | #endif //KAB_EMBEDDED |
86 | /** | 86 | /** |
87 | Restores the global settings. | 87 | Restores the global settings. |
88 | */ | 88 | */ |
89 | void restoreSettings(); | 89 | void restoreSettings(); |
90 | 90 | ||
91 | /** | 91 | /** |
92 | Saves the global settings. | 92 | Saves the global settings. |
93 | */ | 93 | */ |
94 | void saveSettings(); | 94 | void saveSettings(); |
95 | 95 | ||
96 | /** | 96 | /** |
97 | Returns a pointer to the StdAddressBook of the application. | 97 | Returns a pointer to the StdAddressBook of the application. |
98 | */ | 98 | */ |
99 | KABC::AddressBook *addressBook() const; | 99 | KABC::AddressBook *addressBook() const; |
100 | 100 | ||
101 | /** | 101 | /** |
102 | Returns a pointer to the KConfig object of the application. | 102 | Returns a pointer to the KConfig object of the application. |
103 | */ | 103 | */ |
104 | static KConfig *config(); | 104 | static KConfig *config(); |
105 | 105 | ||
106 | /** | 106 | /** |
107 | Returns a pointer to the global KActionCollection object. So | 107 | Returns a pointer to the global KActionCollection object. So |
108 | other classes can register their actions easily. | 108 | other classes can register their actions easily. |
109 | */ | 109 | */ |
110 | KActionCollection *actionCollection() const; | 110 | KActionCollection *actionCollection() const; |
111 | 111 | ||
112 | /** | 112 | /** |
113 | Returns the current search field of the Incremental Search Widget. | 113 | Returns the current search field of the Incremental Search Widget. |
114 | */ | 114 | */ |
115 | KABC::Field *currentSearchField() const; | 115 | KABC::Field *currentSearchField() const; |
116 | 116 | ||
117 | /** | 117 | /** |
118 | Returns the uid list of the currently selected contacts. | 118 | Returns the uid list of the currently selected contacts. |
119 | */ | 119 | */ |
120 | QStringList selectedUIDs() const; | 120 | QStringList selectedUIDs() const; |
121 | 121 | ||
122 | /** | 122 | /** |
123 | Displays the ResourceSelectDialog and returns the selected | 123 | Displays the ResourceSelectDialog and returns the selected |
124 | resource or a null pointer if no resource was selected by | 124 | resource or a null pointer if no resource was selected by |
125 | the user. | 125 | the user. |
126 | */ | 126 | */ |
127 | KABC::Resource *requestResource( QWidget *parent ); | 127 | KABC::Resource *requestResource( QWidget *parent ); |
128 | 128 | ||
129 | #ifndef KAB_EMBEDDED | 129 | #ifndef KAB_EMBEDDED |
130 | static KAboutData *createAboutData(); | 130 | static KAboutData *createAboutData(); |
131 | #endif //KAB_EMBEDDED | 131 | #endif //KAB_EMBEDDED |
132 | 132 | ||
133 | #ifdef KAB_EMBEDDED | 133 | #ifdef KAB_EMBEDDED |
134 | inline QPopupMenu* getImportMenu() { return ImportMenu;} | 134 | inline QPopupMenu* getImportMenu() { return ImportMenu;} |
135 | inline QPopupMenu* getExportMenu() { return ExportMenu;} | 135 | inline QPopupMenu* getExportMenu() { return ExportMenu;} |
136 | #endif //KAB_EMBEDDED | 136 | #endif //KAB_EMBEDDED |
137 | 137 | ||
138 | public slots: | 138 | public slots: |
139 | #ifdef KAB_EMBEDDED | 139 | #ifdef KAB_EMBEDDED |
140 | void createAboutData(); | 140 | void createAboutData(); |
141 | #endif //KAB_EMBEDDED | 141 | #endif //KAB_EMBEDDED |
142 | 142 | ||
143 | void statusMessage(QString, int time = 0 ); | 143 | void statusMessage(QString, int time = 0 ); |
144 | /** | 144 | /** |
145 | Is called whenever a contact is selected in the view. | 145 | Is called whenever a contact is selected in the view. |
146 | */ | 146 | */ |
147 | void setContactSelected( const QString &uid ); | 147 | void setContactSelected( const QString &uid ); |
148 | 148 | ||
149 | /** | 149 | /** |
150 | Opens the preferred mail composer with all selected contacts as | 150 | Opens the preferred mail composer with all selected contacts as |
151 | arguments. | 151 | arguments. |
152 | */ | 152 | */ |
153 | void sendMail(); | 153 | void sendMail(); |
154 | 154 | ||
155 | /** | 155 | /** |
156 | Opens the preferred mail composer with the given contacts as | 156 | Opens the preferred mail composer with the given contacts as |
157 | arguments. | 157 | arguments. |
158 | */ | 158 | */ |
159 | void sendMail( const QString& email ); | 159 | void sendMail( const QString& email ); |
160 | 160 | ||
161 | 161 | ||
162 | void mailVCard(); | 162 | void mailVCard(); |
163 | void mailVCard(const QStringList& uids); | 163 | void mailVCard(const QStringList& uids); |
164 | 164 | ||
165 | /** | 165 | /** |
166 | Starts the preferred web browser with the given URL as argument. | 166 | Starts the preferred web browser with the given URL as argument. |
167 | */ | 167 | */ |
168 | void browse( const QString& url ); | 168 | void browse( const QString& url ); |
169 | 169 | ||
170 | /** | 170 | /** |
171 | Select all contacts in the view. | 171 | Select all contacts in the view. |
172 | */ | 172 | */ |
173 | void selectAllContacts(); | 173 | void selectAllContacts(); |
174 | 174 | ||
175 | /** | 175 | /** |
176 | Deletes all selected contacts from the address book. | 176 | Deletes all selected contacts from the address book. |
177 | */ | 177 | */ |
178 | void deleteContacts(); | 178 | void deleteContacts(); |
179 | 179 | ||
180 | /** | 180 | /** |
181 | Deletes given contacts from the address book. | 181 | Deletes given contacts from the address book. |
182 | 182 | ||
183 | @param uids The uids of the contacts, which shall be deleted. | 183 | @param uids The uids of the contacts, which shall be deleted. |
184 | */ | 184 | */ |
185 | void deleteContacts( const QStringList &uids ); | 185 | void deleteContacts( const QStringList &uids ); |
186 | 186 | ||
187 | /** | 187 | /** |
188 | Copys the selected contacts into clipboard for later pasting. | 188 | Copys the selected contacts into clipboard for later pasting. |
189 | */ | 189 | */ |
190 | void copyContacts(); | 190 | void copyContacts(); |
191 | 191 | ||
192 | /** | 192 | /** |
193 | Cuts the selected contacts and stores them for later pasting. | 193 | Cuts the selected contacts and stores them for later pasting. |
194 | */ | 194 | */ |
195 | void cutContacts(); | 195 | void cutContacts(); |
196 | 196 | ||
197 | /** | 197 | /** |
198 | Paste contacts from clipboard into the address book. | 198 | Paste contacts from clipboard into the address book. |
199 | */ | 199 | */ |
200 | void pasteContacts(); | 200 | void pasteContacts(); |
201 | 201 | ||
202 | /** | 202 | /** |
203 | Paste given contacts into the address book. | 203 | Paste given contacts into the address book. |
204 | 204 | ||
205 | @param list The list of addressee, which shall be pasted. | 205 | @param list The list of addressee, which shall be pasted. |
206 | */ | 206 | */ |
207 | void pasteContacts( KABC::Addressee::List &list ); | 207 | void pasteContacts( KABC::Addressee::List &list ); |
208 | 208 | ||
209 | /** | 209 | /** |
210 | Sets the whoAmI contact, that is used by many other programs to | 210 | Sets the whoAmI contact, that is used by many other programs to |
211 | get personal information about the current user. | 211 | get personal information about the current user. |
212 | */ | 212 | */ |
213 | void setWhoAmI(); | 213 | void setWhoAmI(); |
214 | 214 | ||
215 | /** | 215 | /** |
216 | Displays the category dialog and applies the result to all | 216 | Displays the category dialog and applies the result to all |
217 | selected contacts. | 217 | selected contacts. |
218 | */ | 218 | */ |
219 | void setCategories(); | 219 | void setCategories(); |
220 | 220 | ||
221 | /** | 221 | /** |
222 | Sets the field list of the Incremental Search Widget. | 222 | Sets the field list of the Incremental Search Widget. |
223 | */ | 223 | */ |
224 | void setSearchFields( const KABC::Field::List &fields ); | 224 | void setSearchFields( const KABC::Field::List &fields ); |
225 | 225 | ||
226 | /** | 226 | /** |
227 | Search with the current search field for a contact, that matches | 227 | Search with the current search field for a contact, that matches |
228 | the given text, and selects it in the view. | 228 | the given text, and selects it in the view. |
229 | */ | 229 | */ |
230 | void incrementalSearch( const QString& text ); | 230 | void incrementalSearch( const QString& text ); |
231 | 231 | ||
232 | /** | 232 | /** |
233 | Marks the address book as modified. | 233 | Marks the address book as modified. |
234 | */ | 234 | */ |
235 | void setModified(); | 235 | void setModified(); |
236 | /** | 236 | /** |
237 | Marks the address book as modified without refreshing the view. | 237 | Marks the address book as modified without refreshing the view. |
238 | */ | 238 | */ |
239 | void setModifiedWOrefresh(); | 239 | void setModifiedWOrefresh(); |
240 | 240 | ||
241 | /** | 241 | /** |
242 | Marks the address book as modified concerning the argument. | 242 | Marks the address book as modified concerning the argument. |
243 | */ | 243 | */ |
244 | void setModified( bool modified ); | 244 | void setModified( bool modified ); |
245 | 245 | ||
246 | /** | 246 | /** |
247 | Returns whether the address book is modified. | 247 | Returns whether the address book is modified. |
248 | */ | 248 | */ |
249 | bool modified() const; | 249 | bool modified() const; |
250 | 250 | ||
251 | /** | 251 | /** |
252 | Called whenever an contact is modified in the contact editor | 252 | Called whenever an contact is modified in the contact editor |
253 | dialog or the quick edit. | 253 | dialog or the quick edit. |
254 | */ | 254 | */ |
255 | void contactModified( const KABC::Addressee &addr ); | 255 | void contactModified( const KABC::Addressee &addr ); |
256 | 256 | ||
257 | /** | 257 | /** |
258 | DCOP METHODS. | 258 | DCOP METHODS. |
259 | */ | 259 | */ |
260 | void addEmail( QString addr ); | 260 | void addEmail( QString addr ); |
261 | void importVCard( const KURL& url, bool showPreview ); | 261 | void importVCard( const KURL& url, bool showPreview ); |
262 | void importVCard( const QString& vCard, bool showPreview ); | 262 | void importVCard( const QString& vCard, bool showPreview ); |
263 | void newContact(); | 263 | void newContact(); |
264 | QString getNameByPhone( const QString& phone ); | 264 | QString getNameByPhone( const QString& phone ); |
265 | /** | 265 | /** |
266 | END DCOP METHODS | 266 | END DCOP METHODS |
267 | */ | 267 | */ |
268 | 268 | ||
269 | /** | 269 | /** |
270 | Saves the contents of the AddressBook back to disk. | 270 | Saves the contents of the AddressBook back to disk. |
271 | */ | 271 | */ |
272 | void save(); | 272 | void save(); |
273 | 273 | ||
274 | /** | 274 | /** |
275 | Undos the last command using the undo stack. | 275 | Undos the last command using the undo stack. |
276 | */ | 276 | */ |
277 | void undo(); | 277 | void undo(); |
278 | 278 | ||
279 | /** | 279 | /** |
280 | Redos the last command that was undone, using the redo stack. | 280 | Redos the last command that was undone, using the redo stack. |
281 | */ | 281 | */ |
282 | void redo(); | 282 | void redo(); |
283 | 283 | ||
284 | /** | 284 | /** |
285 | Shows the edit dialog for the given uid. If the uid is QString::null, | 285 | Shows the edit dialog for the given uid. If the uid is QString::null, |
286 | the method will try to find a selected addressee in the view. | 286 | the method will try to find a selected addressee in the view. |
287 | */ | 287 | */ |
288 | void editContact( const QString &uid /*US = QString::null*/ ); | 288 | void editContact( const QString &uid /*US = QString::null*/ ); |
289 | //US added a second method without defaultparameter | 289 | //US added a second method without defaultparameter |
290 | void editContact2(); | 290 | void editContact2(); |
291 | 291 | ||
292 | /** | 292 | /** |
293 | Launches the configuration dialog. | 293 | Launches the configuration dialog. |
294 | */ | 294 | */ |
295 | void openConfigDialog(); | 295 | void openConfigDialog(); |
296 | 296 | ||
297 | /** | 297 | /** |
298 | Launches the ldap search dialog. | 298 | Launches the ldap search dialog. |
299 | */ | 299 | */ |
300 | void openLDAPDialog(); | 300 | void openLDAPDialog(); |
301 | 301 | ||
302 | /** | 302 | /** |
303 | Creates a KAddressBookPrinter, which will display the print | 303 | Creates a KAddressBookPrinter, which will display the print |
304 | dialog and do the printing. | 304 | dialog and do the printing. |
305 | */ | 305 | */ |
306 | void print(); | 306 | void print(); |
307 | 307 | ||
308 | /** | 308 | /** |
309 | Registers a new GUI client, so plugins can register its actions. | 309 | Registers a new GUI client, so plugins can register its actions. |
310 | */ | 310 | */ |
311 | void addGUIClient( KXMLGUIClient *client ); | 311 | void addGUIClient( KXMLGUIClient *client ); |
312 | 312 | ||
313 | signals: | 313 | signals: |
314 | void contactSelected( const QString &name ); | 314 | void contactSelected( const QString &name ); |
315 | void contactSelected( const QPixmap &pixmap ); | 315 | void contactSelected( const QPixmap &pixmap ); |
316 | public slots: | 316 | public slots: |
317 | void setDetailsVisible( bool visible ); | 317 | void setDetailsVisible( bool visible ); |
318 | void setDetailsToState(); | 318 | void setDetailsToState(); |
319 | private slots: | 319 | private slots: |
320 | void setJumpButtonBarVisible( bool visible ); | 320 | void setJumpButtonBarVisible( bool visible ); |
321 | 321 | ||
322 | void extensionModified( const KABC::Addressee::List &list ); | 322 | void extensionModified( const KABC::Addressee::List &list ); |
323 | void clipboardDataChanged(); | 323 | void clipboardDataChanged(); |
324 | void updateActionMenu(); | 324 | void updateActionMenu(); |
325 | void configureKeyBindings(); | 325 | void configureKeyBindings(); |
326 | #ifdef KAB_EMBEDDED | 326 | #ifdef KAB_EMBEDDED |
327 | void configureResources(); | 327 | void configureResources(); |
328 | #endif //KAB_EMBEDDED | 328 | #endif //KAB_EMBEDDED |
329 | 329 | ||
330 | void slotEditorDestroyed( const QString &uid ); | 330 | void slotEditorDestroyed( const QString &uid ); |
331 | void configurationChanged(); | 331 | void configurationChanged(); |
332 | void addressBookChanged(); | 332 | void addressBookChanged(); |
333 | 333 | ||
334 | private: | 334 | private: |
335 | void initGUI(); | 335 | void initGUI(); |
336 | void initActions(); | 336 | void initActions(); |
337 | 337 | ||
338 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 338 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
339 | const char *name = 0 ); | 339 | const char *name = 0 ); |
340 | 340 | ||
341 | KXMLGUIClient *mGUIClient; | 341 | KXMLGUIClient *mGUIClient; |
342 | 342 | ||
343 | KABC::AddressBook *mAddressBook; | 343 | KABC::AddressBook *mAddressBook; |
344 | 344 | ||
345 | ViewManager *mViewManager; | 345 | ViewManager *mViewManager; |
346 | // QSplitter *mDetailsSplitter; | 346 | // QSplitter *mDetailsSplitter; |
347 | //QSplitter *mExtensionBarSplitter; | 347 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
348 | ViewContainer *mDetails; | 348 | ViewContainer *mDetails; |
349 | KDGanttMinimizeSplitter* mMiniSplitter; | 349 | KDGanttMinimizeSplitter* mMiniSplitter; |
350 | XXPortManager *mXXPortManager; | 350 | XXPortManager *mXXPortManager; |
351 | JumpButtonBar *mJumpButtonBar; | 351 | JumpButtonBar *mJumpButtonBar; |
352 | IncSearchWidget *mIncSearchWidget; | 352 | IncSearchWidget *mIncSearchWidget; |
353 | ExtensionManager *mExtensionManager; | 353 | ExtensionManager *mExtensionManager; |
354 | 354 | ||
355 | KCMultiDialog *mConfigureDialog; | 355 | KCMultiDialog *mConfigureDialog; |
356 | 356 | ||
357 | #ifndef KAB_EMBEDDED | 357 | #ifndef KAB_EMBEDDED |
358 | 358 | ||
359 | KCMultiDialog *mConfigureDialog; | 359 | KCMultiDialog *mConfigureDialog; |
360 | LDAPSearchDialog *mLdapSearchDialog; | 360 | LDAPSearchDialog *mLdapSearchDialog; |
361 | #endif //KAB_EMBEDDED | 361 | #endif //KAB_EMBEDDED |
362 | QDict<AddresseeEditorDialog> mEditorDict; | 362 | QDict<AddresseeEditorDialog> mEditorDict; |
363 | 363 | ||
364 | bool mReadWrite; | 364 | bool mReadWrite; |
365 | bool mModified; | 365 | bool mModified; |
366 | bool mIsPart; | 366 | bool mIsPart; |
367 | 367 | ||
368 | //US file menu | 368 | //US file menu |
369 | KAction *mActionMail; | 369 | KAction *mActionMail; |
370 | KAction* mActionPrint; | 370 | KAction* mActionPrint; |
371 | KAction* mActionNewContact; | 371 | KAction* mActionNewContact; |
372 | KAction *mActionSave; | 372 | KAction *mActionSave; |
373 | KAction *mActionEditAddressee; | 373 | KAction *mActionEditAddressee; |
374 | KAction *mActionMailVCard; | 374 | KAction *mActionMailVCard; |
375 | KAction *mActionQuit; | 375 | KAction *mActionQuit; |
376 | 376 | ||
377 | //US edit menu | 377 | //US edit menu |
378 | KAction *mActionCopy; | 378 | KAction *mActionCopy; |
379 | KAction *mActionCut; | 379 | KAction *mActionCut; |
380 | KAction *mActionPaste; | 380 | KAction *mActionPaste; |
381 | KAction *mActionSelectAll; | 381 | KAction *mActionSelectAll; |
382 | KAction *mActionUndo; | 382 | KAction *mActionUndo; |
383 | KAction *mActionRedo; | 383 | KAction *mActionRedo; |
384 | KAction *mActionDelete; | 384 | KAction *mActionDelete; |
385 | 385 | ||
386 | //US settings menu | 386 | //US settings menu |
387 | KAction *mActionConfigResources; | 387 | KAction *mActionConfigResources; |
388 | KAction *mActionConfigKAddressbook; | 388 | KAction *mActionConfigKAddressbook; |
389 | KAction *mActionConfigShortcuts; | 389 | KAction *mActionConfigShortcuts; |
390 | KAction *mActionConfigureToolbars; | 390 | KAction *mActionConfigureToolbars; |
391 | KAction *mActionKeyBindings; | 391 | KAction *mActionKeyBindings; |
392 | KToggleAction *mActionJumpBar; | 392 | KToggleAction *mActionJumpBar; |
393 | KToggleAction *mActionDetails; | 393 | KToggleAction *mActionDetails; |
394 | KAction *mActionWhoAmI; | 394 | KAction *mActionWhoAmI; |
395 | KAction *mActionCategories; | 395 | KAction *mActionCategories; |
396 | KAction *mActionAboutKAddressbook; | 396 | KAction *mActionAboutKAddressbook; |
397 | 397 | ||
398 | KAction *mActionDeleteView; | 398 | KAction *mActionDeleteView; |
399 | 399 | ||
400 | QPopupMenu *viewMenu; | 400 | QPopupMenu *viewMenu; |
401 | QPopupMenu *filterMenu; | 401 | QPopupMenu *filterMenu; |
402 | QPopupMenu *settingsMenu; | 402 | QPopupMenu *settingsMenu; |
403 | 403 | ||
404 | //US QAction *mActionSave; | 404 | //US QAction *mActionSave; |
405 | QPopupMenu *ImportMenu; | 405 | QPopupMenu *ImportMenu; |
406 | QPopupMenu *ExportMenu; | 406 | QPopupMenu *ExportMenu; |
407 | 407 | ||
408 | #ifndef KAB_EMBEDDED | 408 | #ifndef KAB_EMBEDDED |
409 | KAddressBookService *mAddressBookService; | 409 | KAddressBookService *mAddressBookService; |
410 | #endif //KAB_EMBEDDED | 410 | #endif //KAB_EMBEDDED |
411 | 411 | ||
412 | class KABCorePrivate; | 412 | class KABCorePrivate; |
413 | KABCorePrivate *d; | 413 | KABCorePrivate *d; |
414 | 414 | ||
415 | #ifdef KAB_EMBEDDED | 415 | #ifdef KAB_EMBEDDED |
416 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 416 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
417 | #endif //KAB_EMBEDDED | 417 | #endif //KAB_EMBEDDED |
418 | 418 | ||
419 | }; | 419 | }; |
420 | 420 | ||
421 | #endif | 421 | #endif |
diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp index 92c32ca..8ebb93a 100644 --- a/kaddressbook/kaddressbookmain.cpp +++ b/kaddressbook/kaddressbookmain.cpp | |||
@@ -1,293 +1,276 @@ | |||
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 | #ifndef DESKTOP_VERSION | 95 | |
96 | void KAddressBookMain::show () | ||
97 | { | ||
98 | static bool block = false; | ||
99 | if( block ) { | ||
100 | QWidget::show(); | ||
101 | return; | ||
102 | } else { | ||
103 | block = true ; | ||
104 | QWidget::showFullScreen(); | ||
105 | } | ||
106 | int min = 20; | ||
107 | if ( QApplication::desktop()->width() > 320 ) | ||
108 | min += 20; | ||
109 | setGeometry( 0,0,QApplication::desktop()->width(), QApplication::desktop()->height() - min ); | ||
110 | block = false; | ||
111 | } | ||
112 | #endif | ||
113 | void KAddressBookMain::showMinimized () | 96 | void KAddressBookMain::showMinimized () |
114 | { | 97 | { |
115 | QWidget::showMinimized () ; | 98 | QWidget::showMinimized () ; |
116 | } | 99 | } |
117 | void KAddressBookMain::addEmail( QString addr ) | 100 | void KAddressBookMain::addEmail( QString addr ) |
118 | { | 101 | { |
119 | mCore->addEmail( addr ); | 102 | mCore->addEmail( addr ); |
120 | } | 103 | } |
121 | 104 | ||
122 | #ifndef KAB_EMBEDDED | 105 | #ifndef KAB_EMBEDDED |
123 | ASYNC KAddressBookMain::showContactEditor( QString uid ) | 106 | ASYNC KAddressBookMain::showContactEditor( QString uid ) |
124 | { | 107 | { |
125 | mCore->editContact( uid ); | 108 | mCore->editContact( uid ); |
126 | } | 109 | } |
127 | #endif //KAB_EMBEDDED | 110 | #endif //KAB_EMBEDDED |
128 | void KAddressBookMain::newContact() | 111 | void KAddressBookMain::newContact() |
129 | { | 112 | { |
130 | mCore->newContact(); | 113 | mCore->newContact(); |
131 | } | 114 | } |
132 | 115 | ||
133 | QString KAddressBookMain::getNameByPhone( QString phone ) | 116 | QString KAddressBookMain::getNameByPhone( QString phone ) |
134 | { | 117 | { |
135 | return mCore->getNameByPhone( phone ); | 118 | return mCore->getNameByPhone( phone ); |
136 | } | 119 | } |
137 | 120 | ||
138 | void KAddressBookMain::save() | 121 | void KAddressBookMain::save() |
139 | { | 122 | { |
140 | mCore->save(); | 123 | mCore->save(); |
141 | } | 124 | } |
142 | 125 | ||
143 | void KAddressBookMain::exit() | 126 | void KAddressBookMain::exit() |
144 | { | 127 | { |
145 | close( ); | 128 | close( ); |
146 | } | 129 | } |
147 | 130 | ||
148 | void KAddressBookMain::saveProperties( KConfig* ) | 131 | void KAddressBookMain::saveProperties( KConfig* ) |
149 | { | 132 | { |
150 | } | 133 | } |
151 | 134 | ||
152 | void KAddressBookMain::readProperties( KConfig* ) | 135 | void KAddressBookMain::readProperties( KConfig* ) |
153 | { | 136 | { |
154 | } | 137 | } |
155 | 138 | ||
156 | void KAddressBookMain::initActions() | 139 | void KAddressBookMain::initActions() |
157 | { | 140 | { |
158 | #ifndef KAB_EMBEDDED | 141 | #ifndef KAB_EMBEDDED |
159 | KStdAction::quit( this, SLOT( close() ), actionCollection() ); | 142 | KStdAction::quit( this, SLOT( close() ), actionCollection() ); |
160 | KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); | 143 | KStdAction::configureToolbars( this, SLOT( configureToolbars() ), actionCollection() ); |
161 | #else //KAB_EMBEDDED | 144 | #else //KAB_EMBEDDED |
162 | //US: transfered the setup of the actions into KABCore | 145 | //US: transfered the setup of the actions into KABCore |
163 | #endif //KAB_EMBEDDED | 146 | #endif //KAB_EMBEDDED |
164 | 147 | ||
165 | 148 | ||
166 | } | 149 | } |
167 | 150 | ||
168 | //US new method to setup menues and toolbars on embedded systems | 151 | //US new method to setup menues and toolbars on embedded systems |
169 | #ifdef KAB_EMBEDDED | 152 | #ifdef KAB_EMBEDDED |
170 | /* | 153 | /* |
171 | QToolBar * KAddressBookMain::getIconToolBar() | 154 | QToolBar * KAddressBookMain::getIconToolBar() |
172 | { | 155 | { |
173 | return iconToolBar; | 156 | return iconToolBar; |
174 | } | 157 | } |
175 | */ | 158 | */ |
176 | 159 | ||
177 | void KAddressBookMain::createGUI() | 160 | void KAddressBookMain::createGUI() |
178 | { | 161 | { |
179 | 162 | ||
180 | 163 | ||
181 | 164 | ||
182 | } | 165 | } |
183 | #endif //KAB_EMBEDDED | 166 | #endif //KAB_EMBEDDED |
184 | 167 | ||
185 | void KAddressBookMain::configureToolbars() | 168 | void KAddressBookMain::configureToolbars() |
186 | { | 169 | { |
187 | #ifndef KAB_EMBEDDED | 170 | #ifndef KAB_EMBEDDED |
188 | saveMainWindowSettings( KGlobal::config(), "MainWindow" ); | 171 | saveMainWindowSettings( KGlobal::config(), "MainWindow" ); |
189 | 172 | ||
190 | KEditToolbar dlg( factory() ); | 173 | KEditToolbar dlg( factory() ); |
191 | connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); | 174 | connect( &dlg, SIGNAL( newToolbarConfig() ), SLOT( slotNewToolbarConfig() ) ); |
192 | 175 | ||
193 | dlg.exec(); | 176 | dlg.exec(); |
194 | #else //KAB_EMBEDDED | 177 | #else //KAB_EMBEDDED |
195 | qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); | 178 | qDebug("KAddressBookMain::configureToolbars() not implemented by ulf" ); |
196 | #endif //KAB_EMBEDDED | 179 | #endif //KAB_EMBEDDED |
197 | } | 180 | } |
198 | 181 | ||
199 | void KAddressBookMain::slotNewToolbarConfig() | 182 | void KAddressBookMain::slotNewToolbarConfig() |
200 | { | 183 | { |
201 | #ifndef KAB_EMBEDDED | 184 | #ifndef KAB_EMBEDDED |
202 | applyMainWindowSettings( KGlobal::config(), "MainWindow" ); | 185 | applyMainWindowSettings( KGlobal::config(), "MainWindow" ); |
203 | #else //KAB_EMBEDDED | 186 | #else //KAB_EMBEDDED |
204 | qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); | 187 | qDebug("KAddressBookMain::slotNewToolbarConfig() not implemented by ulf" ); |
205 | #endif //KAB_EMBEDDED | 188 | #endif //KAB_EMBEDDED |
206 | } | 189 | } |
207 | 190 | ||
208 | void KAddressBookMain::configureKeys() | 191 | void KAddressBookMain::configureKeys() |
209 | { | 192 | { |
210 | #ifndef KAB_EMBEDDED | 193 | #ifndef KAB_EMBEDDED |
211 | KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); | 194 | KKeyDialog::configureKeys( actionCollection(), xmlFile(), true, this ); |
212 | #else //KAB_EMBEDDED | 195 | #else //KAB_EMBEDDED |
213 | qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); | 196 | qDebug("KAddressBookMain::configureKeys() not implemented by ulf" ); |
214 | #endif //KAB_EMBEDDED | 197 | #endif //KAB_EMBEDDED |
215 | } | 198 | } |
216 | 199 | ||
217 | void KAddressBookMain::closeEvent( QCloseEvent* ce ) | 200 | void KAddressBookMain::closeEvent( QCloseEvent* ce ) |
218 | { | 201 | { |
219 | QString mess = i18n( "Close KA/Pi?"); | 202 | QString mess = i18n( "Close KA/Pi?"); |
220 | if ( mCore->modified() ) | 203 | if ( mCore->modified() ) |
221 | mess += i18n( "\n\nChanges will be saved!"); | 204 | mess += i18n( "\n\nChanges will be saved!"); |
222 | else | 205 | else |
223 | mess += i18n( "\n\nNo unsaved changes detected!\nNothing will be saved!"); | 206 | mess += i18n( "\n\nNo unsaved changes detected!\nNothing will be saved!"); |
224 | 207 | ||
225 | switch( QMessageBox::information( this, "KA/Pi", mess , | 208 | switch( QMessageBox::information( this, "KA/Pi", mess , |
226 | i18n("Yes!"), i18n("No"), 0, 0 ) ) { | 209 | i18n("Yes!"), i18n("No"), 0, 0 ) ) { |
227 | case 0: | 210 | case 0: |
228 | 211 | ||
229 | break; | 212 | break; |
230 | case 1: | 213 | case 1: |
231 | return; | 214 | return; |
232 | break; | 215 | break; |
233 | case 2: | 216 | case 2: |
234 | return; | 217 | return; |
235 | break; | 218 | break; |
236 | 219 | ||
237 | default: | 220 | default: |
238 | return; | 221 | return; |
239 | break; | 222 | break; |
240 | } | 223 | } |
241 | 224 | ||
242 | #if 0 | 225 | #if 0 |
243 | 226 | ||
244 | if ( mCore->modified() ) { | 227 | if ( mCore->modified() ) { |
245 | QString text = i18n( "The address book has been modified.\nDo you want to save your changes?" ); | 228 | QString text = i18n( "The address book has been modified.\nDo you want to save your changes?" ); |
246 | 229 | ||
247 | #ifndef KAB_EMBEDDED | 230 | #ifndef KAB_EMBEDDED |
248 | int ret = KMessageBox::warningYesNoCancel( this, text, "", | 231 | int ret = KMessageBox::warningYesNoCancel( this, text, "", |
249 | KStdGuiItem::yes(), | 232 | KStdGuiItem::yes(), |
250 | KStdGuiItem::no(), "AskForSave" ); | 233 | KStdGuiItem::no(), "AskForSave" ); |
251 | switch ( ret ) { | 234 | switch ( ret ) { |
252 | case KMessageBox::Yes: | 235 | case KMessageBox::Yes: |
253 | save(); | 236 | save(); |
254 | break; | 237 | break; |
255 | case KMessageBox::No: | 238 | case KMessageBox::No: |
256 | return true; | 239 | return true; |
257 | break; | 240 | break; |
258 | default: //cancel | 241 | default: //cancel |
259 | return ; | 242 | return ; |
260 | break; | 243 | break; |
261 | } | 244 | } |
262 | 245 | ||
263 | #else //KAB_EMBEDDED | 246 | #else //KAB_EMBEDDED |
264 | switch( QMessageBox::information( this, "KA/Pi", | 247 | switch( QMessageBox::information( this, "KA/Pi", |
265 | text, | 248 | text, |
266 | i18n("Yes!"), i18n("No"), 0, 0 ) ) { | 249 | i18n("Yes!"), i18n("No"), 0, 0 ) ) { |
267 | case 0: | 250 | case 0: |
268 | save(); | 251 | save(); |
269 | break; | 252 | break; |
270 | case 1: | 253 | case 1: |
271 | break; | 254 | break; |
272 | case 2: | 255 | case 2: |
273 | return; | 256 | return; |
274 | default: | 257 | default: |
275 | return; | 258 | return; |
276 | break; | 259 | break; |
277 | } | 260 | } |
278 | #endif //KAB_EMBEDDED | 261 | #endif //KAB_EMBEDDED |
279 | } | 262 | } |
280 | 263 | ||
281 | #endif | 264 | #endif |
282 | 265 | ||
283 | save(); | 266 | save(); |
284 | mCore->saveSettings(); | 267 | mCore->saveSettings(); |
285 | KABPrefs::instance()->writeConfig(); | 268 | KABPrefs::instance()->writeConfig(); |
286 | ce->accept(); | 269 | ce->accept(); |
287 | 270 | ||
288 | } | 271 | } |
289 | 272 | ||
290 | #ifndef KAB_EMBEDDED | 273 | #ifndef KAB_EMBEDDED |
291 | #include "kaddressbookmain.moc" | 274 | #include "kaddressbookmain.moc" |
292 | #endif //KAB_EMBEDDED | 275 | #endif //KAB_EMBEDDED |
293 | 276 | ||
diff --git a/kaddressbook/kaddressbookmain.h b/kaddressbook/kaddressbookmain.h index 81ae09c..cf6f899 100644 --- a/kaddressbook/kaddressbookmain.h +++ b/kaddressbook/kaddressbookmain.h | |||
@@ -1,126 +1,122 @@ | |||
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 | #ifndef KADDRESSBOOKMAIN_H | 24 | #ifndef KADDRESSBOOKMAIN_H |
25 | #define KADDRESSBOOKMAIN_H | 25 | #define KADDRESSBOOKMAIN_H |
26 | 26 | ||
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | 28 | ||
29 | #ifdef KAB_EMBEDDED | 29 | #ifdef KAB_EMBEDDED |
30 | class QToolBar; | 30 | class QToolBar; |
31 | #include <qaction.h> | 31 | #include <qaction.h> |
32 | //#include <qmainwindow.h> | 32 | //#include <qmainwindow.h> |
33 | #include <kmainwindow.h> | 33 | #include <kmainwindow.h> |
34 | #else //KAB_EMBEDDED | 34 | #else //KAB_EMBEDDED |
35 | #include <kaction.h> | 35 | #include <kaction.h> |
36 | #include <kapplication.h> | 36 | #include <kapplication.h> |
37 | #include <kmainwindow.h> | 37 | #include <kmainwindow.h> |
38 | #include "kaddressbookiface.h" | 38 | #include "kaddressbookiface.h" |
39 | #endif //KAB_EMBEDDED | 39 | #endif //KAB_EMBEDDED |
40 | 40 | ||
41 | class KABCore; | 41 | class KABCore; |
42 | class KConfig; | 42 | class KConfig; |
43 | 43 | ||
44 | /** | 44 | /** |
45 | This class serves as the main window for KAddressBook. It handles the | 45 | This class serves as the main window for KAddressBook. It handles the |
46 | menus, toolbars, and status bars. | 46 | menus, toolbars, and status bars. |
47 | 47 | ||
48 | @short Main window class | 48 | @short Main window class |
49 | @author Don Sanders <dsanders@kde.org> | 49 | @author Don Sanders <dsanders@kde.org> |
50 | @version 0.1 | 50 | @version 0.1 |
51 | */ | 51 | */ |
52 | #ifdef KAB_EMBEDDED | 52 | #ifdef KAB_EMBEDDED |
53 | class KAddressBookMain : public KMainWindow | 53 | class KAddressBookMain : public KMainWindow |
54 | #else //KAB_EMBEDDED | 54 | #else //KAB_EMBEDDED |
55 | //MOC_SKIP_BEGIN | 55 | //MOC_SKIP_BEGIN |
56 | class KAddressBookMain : public KMainWindow, virtual public KAddressBookIface | 56 | class KAddressBookMain : public KMainWindow, virtual public KAddressBookIface |
57 | //MOC_SKIP_END | 57 | //MOC_SKIP_END |
58 | #endif //KAB_EMBEDDED | 58 | #endif //KAB_EMBEDDED |
59 | { | 59 | { |
60 | Q_OBJECT | 60 | Q_OBJECT |
61 | 61 | ||
62 | public: | 62 | public: |
63 | KAddressBookMain(); | 63 | KAddressBookMain(); |
64 | virtual ~KAddressBookMain(); | 64 | virtual ~KAddressBookMain(); |
65 | 65 | ||
66 | #ifdef KAB_EMBEDDED | 66 | #ifdef KAB_EMBEDDED |
67 | // QPEToolBar * getIconToolBar(); | 67 | // QPEToolBar * getIconToolBar(); |
68 | // QToolBar * getIconToolBar(); | 68 | // QToolBar * getIconToolBar(); |
69 | #endif //KAB_EMBEDDED | 69 | #endif //KAB_EMBEDDED |
70 | 70 | ||
71 | 71 | ||
72 | public slots: | 72 | public slots: |
73 | #ifndef DESKTOP_VERSION | ||
74 | void show(); | ||
75 | #endif | ||
76 | |||
77 | void showMinimized () ; | 73 | void showMinimized () ; |
78 | virtual void addEmail( QString addr ); | 74 | virtual void addEmail( QString addr ); |
79 | #ifndef KAB_EMBEDDED | 75 | #ifndef KAB_EMBEDDED |
80 | //MOC_SKIP_BEGIN | 76 | //MOC_SKIP_BEGIN |
81 | virtual ASYNC showContactEditor( QString uid ); | 77 | virtual ASYNC showContactEditor( QString uid ); |
82 | //MOC_SKIP_END | 78 | //MOC_SKIP_END |
83 | #endif //KAB_EMBEDDED | 79 | #endif //KAB_EMBEDDED |
84 | virtual void newContact(); | 80 | virtual void newContact(); |
85 | virtual QString getNameByPhone( QString phone ); | 81 | virtual QString getNameByPhone( QString phone ); |
86 | virtual void save(); | 82 | virtual void save(); |
87 | virtual void exit(); | 83 | virtual void exit(); |
88 | 84 | ||
89 | protected: | 85 | protected: |
90 | void initActions(); | 86 | void initActions(); |
91 | #ifdef KAB_EMBEDDED | 87 | #ifdef KAB_EMBEDDED |
92 | //US new method to setup menues and toolbars on embedded systems | 88 | //US new method to setup menues and toolbars on embedded systems |
93 | void createGUI(); | 89 | void createGUI(); |
94 | #endif //KAB_EMBEDDED | 90 | #endif //KAB_EMBEDDED |
95 | 91 | ||
96 | /** | 92 | /** |
97 | This function is called when it is time for the app to save its | 93 | This function is called when it is time for the app to save its |
98 | properties for session management purposes. | 94 | properties for session management purposes. |
99 | */ | 95 | */ |
100 | void saveProperties( KConfig* ); | 96 | void saveProperties( KConfig* ); |
101 | 97 | ||
102 | /** | 98 | /** |
103 | This function is called when this app is restored. The KConfig | 99 | This function is called when this app is restored. The KConfig |
104 | object points to the session management config file that was saved | 100 | object points to the session management config file that was saved |
105 | with @ref saveProperties | 101 | with @ref saveProperties |
106 | */ | 102 | */ |
107 | void readProperties( KConfig* ); | 103 | void readProperties( KConfig* ); |
108 | 104 | ||
109 | void closeEvent( QCloseEvent* ce ); | 105 | void closeEvent( QCloseEvent* ce ); |
110 | 106 | ||
111 | protected slots: | 107 | protected slots: |
112 | void configureToolbars(); | 108 | void configureToolbars(); |
113 | void configureKeys(); | 109 | void configureKeys(); |
114 | 110 | ||
115 | void slotNewToolbarConfig(); | 111 | void slotNewToolbarConfig(); |
116 | 112 | ||
117 | private: | 113 | private: |
118 | KABCore *mCore; | 114 | KABCore *mCore; |
119 | 115 | ||
120 | #ifdef KAB_EMBEDDED | 116 | #ifdef KAB_EMBEDDED |
121 | // QToolBar *iconToolBar; | 117 | // QToolBar *iconToolBar; |
122 | #endif //KAB_EMBEDDED | 118 | #endif //KAB_EMBEDDED |
123 | 119 | ||
124 | }; | 120 | }; |
125 | 121 | ||
126 | #endif | 122 | #endif |
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index ffa37a5..3f6f69d 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp | |||
@@ -1,208 +1,204 @@ | |||
1 | #ifndef DESKTOP_VERSION | 1 | #ifndef DESKTOP_VERSION |
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include <qpe/global.h> | 3 | #include <qpe/global.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | #else | 5 | #else |
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | #include <qwindowsstyle.h> | 7 | #include <qwindowsstyle.h> |
8 | #include <qplatinumstyle.h> | 8 | #include <qplatinumstyle.h> |
9 | #include <qmainwindow.h> | 9 | #include <qmainwindow.h> |
10 | #endif | 10 | #endif |
11 | 11 | ||
12 | #include <kstandarddirs.h> | 12 | #include <kstandarddirs.h> |
13 | #include <kglobal.h> | 13 | #include <kglobal.h> |
14 | #include <stdio.h> | 14 | #include <stdio.h> |
15 | #include <qdir.h> | 15 | #include <qdir.h> |
16 | #include "kaddressbookmain.h" | 16 | #include "kaddressbookmain.h" |
17 | 17 | ||
18 | int main( int argc, char **argv ) | 18 | int main( int argc, char **argv ) |
19 | { | 19 | { |
20 | #ifndef DESKTOP_VERSION | 20 | #ifndef DESKTOP_VERSION |
21 | QPEApplication a( argc, argv ); | 21 | QPEApplication a( argc, argv ); |
22 | a.setKeepRunning (); | 22 | a.setKeepRunning (); |
23 | #else | 23 | #else |
24 | QApplication a( argc, argv ); | 24 | QApplication a( argc, argv ); |
25 | QApplication::setStyle( new QPlatinumStyle ()); | 25 | QApplication::setStyle( new QPlatinumStyle ()); |
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | bool exitHelp = false; | 28 | bool exitHelp = false; |
29 | if ( argc > 1 ) { | 29 | if ( argc > 1 ) { |
30 | QString command = argv[1]; | 30 | QString command = argv[1]; |
31 | if ( command == "-help" ){ | 31 | if ( command == "-help" ){ |
32 | printf("KA/E command line commands:\n"); | 32 | printf("KA/E command line commands:\n"); |
33 | printf(" no command: Start KA/E in usual way\n"); | 33 | printf(" no command: Start KA/E in usual way\n"); |
34 | printf(" -help: This output\n"); | 34 | printf(" -help: This output\n"); |
35 | printf(" KA/E is exiting now. Bye!\n"); | 35 | printf(" KA/E is exiting now. Bye!\n"); |
36 | exitHelp = true; | 36 | exitHelp = true; |
37 | } | 37 | } |
38 | } | 38 | } |
39 | if ( ! exitHelp ) { | 39 | if ( ! exitHelp ) { |
40 | 40 | ||
41 | KGlobal::setAppName( "kaddressbook" ); | 41 | KGlobal::setAppName( "kaddressbook" ); |
42 | #ifndef DESKTOP_VERSION | 42 | #ifndef DESKTOP_VERSION |
43 | KStandardDirs::setAppDir( Global::applicationFileName( "kaddressbook", "" ) ); | 43 | KStandardDirs::setAppDir( Global::applicationFileName( "kaddressbook", "" ) ); |
44 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); | 44 | KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); |
45 | #else | 45 | #else |
46 | QString fileName ; | 46 | QString fileName ; |
47 | #ifndef _WIN32_ | 47 | #ifndef _WIN32_ |
48 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons16/"; | 48 | fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons16/"; |
49 | #else | 49 | #else |
50 | fileName = qApp->applicationDirPath () + "\\kdepim\\kaddressbook\\icons16\\"; | 50 | fileName = qApp->applicationDirPath () + "\\kdepim\\kaddressbook\\icons16\\"; |
51 | #endif | 51 | #endif |
52 | KGlobal::iconLoader()->setIconPath(fileName); | 52 | KGlobal::iconLoader()->setIconPath(fileName); |
53 | QString appdir = QDir::homeDirPath(); | 53 | QString appdir = QDir::homeDirPath(); |
54 | if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) | 54 | if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) |
55 | appdir += "kaddressbook"; | 55 | appdir += "kaddressbook"; |
56 | else | 56 | else |
57 | appdir += "/kaddressbook"; | 57 | appdir += "/kaddressbook"; |
58 | KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); | 58 | KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); |
59 | // qDebug(" %s ",KStandardDirs::appDir().latin1() ); | 59 | // qDebug(" %s ",KStandardDirs::appDir().latin1() ); |
60 | #endif // desktop | 60 | #endif // desktop |
61 | QDir app_dir; | 61 | QDir app_dir; |
62 | if ( !app_dir.exists(KStandardDirs::appDir()) ) | 62 | if ( !app_dir.exists(KStandardDirs::appDir()) ) |
63 | app_dir.mkdir (KStandardDirs::appDir()); | 63 | app_dir.mkdir (KStandardDirs::appDir()); |
64 | 64 | ||
65 | KAddressBookMain* m = new KAddressBookMain(); | 65 | KAddressBookMain* m = new KAddressBookMain(); |
66 | //US MainWindow m; | 66 | //US MainWindow m; |
67 | //US QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); | 67 | //US QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); |
68 | 68 | ||
69 | #ifndef DESKTOP_VERSION | 69 | #ifndef DESKTOP_VERSION |
70 | a.showMainWidget(m ); | 70 | a.showMainWidget(m ); |
71 | m->showFullScreen(); | 71 | m->showMaximized(); |
72 | int min = 20; | 72 | |
73 | if ( QApplication::desktop()->width() > 320 ) | ||
74 | min += 20; | ||
75 | m->setGeometry( 0,0,QApplication::desktop()->width(), QApplication::desktop()->height() - min ); | ||
76 | |||
77 | #else | 73 | #else |
78 | a.setMainWidget(m ); | 74 | a.setMainWidget(m ); |
79 | m->show(); | 75 | m->show(); |
80 | //m->resize( 640, 480 ); | 76 | //m->resize( 640, 480 ); |
81 | #endif | 77 | #endif |
82 | a.exec(); | 78 | a.exec(); |
83 | 79 | ||
84 | } | 80 | } |
85 | qDebug("KA: Bye! "); | 81 | qDebug("KA: Bye! "); |
86 | } | 82 | } |
87 | 83 | ||
88 | /* | 84 | /* |
89 | #include <stdlib.h> | 85 | #include <stdlib.h> |
90 | 86 | ||
91 | #include <qstring.h> | 87 | #include <qstring.h> |
92 | 88 | ||
93 | #include <kabc/stdaddressbook.h> | 89 | #include <kabc/stdaddressbook.h> |
94 | #include <kaboutdata.h> | 90 | #include <kaboutdata.h> |
95 | #include <kcmdlineargs.h> | 91 | #include <kcmdlineargs.h> |
96 | #include <kcrash.h> | 92 | #include <kcrash.h> |
97 | #include <kdebug.h> | 93 | #include <kdebug.h> |
98 | #include <klocale.h> | 94 | #include <klocale.h> |
99 | #include <kstartupinfo.h> | 95 | #include <kstartupinfo.h> |
100 | #include <kuniqueapplication.h> | 96 | #include <kuniqueapplication.h> |
101 | #include <kwin.h> | 97 | #include <kwin.h> |
102 | 98 | ||
103 | #include "kaddressbookmain.h" | 99 | #include "kaddressbookmain.h" |
104 | #include "kabcore.h" | 100 | #include "kabcore.h" |
105 | 101 | ||
106 | extern "C" { | 102 | extern "C" { |
107 | 103 | ||
108 | void crashHandler( int ) | 104 | void crashHandler( int ) |
109 | { | 105 | { |
110 | KABC::StdAddressBook::handleCrash(); | 106 | KABC::StdAddressBook::handleCrash(); |
111 | ::exit( 0 ); | 107 | ::exit( 0 ); |
112 | } | 108 | } |
113 | 109 | ||
114 | } | 110 | } |
115 | 111 | ||
116 | class KAddressBookApp : public KUniqueApplication { | 112 | class KAddressBookApp : public KUniqueApplication { |
117 | public: | 113 | public: |
118 | KAddressBookApp() : mMainWin( 0 ) {} | 114 | KAddressBookApp() : mMainWin( 0 ) {} |
119 | ~KAddressBookApp() {} | 115 | ~KAddressBookApp() {} |
120 | 116 | ||
121 | int newInstance(); | 117 | int newInstance(); |
122 | 118 | ||
123 | private: | 119 | private: |
124 | KAddressBookMain *mMainWin; | 120 | KAddressBookMain *mMainWin; |
125 | }; | 121 | }; |
126 | 122 | ||
127 | int KAddressBookApp::newInstance() | 123 | int KAddressBookApp::newInstance() |
128 | { | 124 | { |
129 | if ( isRestored() ) { | 125 | if ( isRestored() ) { |
130 | // There can only be one main window | 126 | // There can only be one main window |
131 | if ( KMainWindow::canBeRestored( 1 ) ) { | 127 | if ( KMainWindow::canBeRestored( 1 ) ) { |
132 | mMainWin = new KAddressBookMain; | 128 | mMainWin = new KAddressBookMain; |
133 | mMainWin->show(); | 129 | mMainWin->show(); |
134 | mMainWin->restore( 1 ); | 130 | mMainWin->restore( 1 ); |
135 | } | 131 | } |
136 | } else { | 132 | } else { |
137 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); | 133 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
138 | 134 | ||
139 | QCString addrStr = args->getOption( "addr" ); | 135 | QCString addrStr = args->getOption( "addr" ); |
140 | QCString uidStr = args->getOption( "uid" ); | 136 | QCString uidStr = args->getOption( "uid" ); |
141 | QString addr; | 137 | QString addr; |
142 | QString uid; | 138 | QString uid; |
143 | if ( !addrStr.isEmpty() ) | 139 | if ( !addrStr.isEmpty() ) |
144 | addr = QString::fromLocal8Bit( addrStr ); | 140 | addr = QString::fromLocal8Bit( addrStr ); |
145 | if ( !uidStr.isEmpty() ) | 141 | if ( !uidStr.isEmpty() ) |
146 | uid = QString::fromLocal8Bit( uidStr ); | 142 | uid = QString::fromLocal8Bit( uidStr ); |
147 | 143 | ||
148 | 144 | ||
149 | if ( args->isSet( "editor-only" ) ) { | 145 | if ( args->isSet( "editor-only" ) ) { |
150 | if ( !mMainWin ) | 146 | if ( !mMainWin ) |
151 | mMainWin = new KAddressBookMain; | 147 | mMainWin = new KAddressBookMain; |
152 | KStartupInfo::appStarted(); | 148 | KStartupInfo::appStarted(); |
153 | mMainWin->hide(); | 149 | mMainWin->hide(); |
154 | } else { | 150 | } else { |
155 | if ( mMainWin ) { | 151 | if ( mMainWin ) { |
156 | mMainWin->show(); | 152 | mMainWin->show(); |
157 | KWin::setActiveWindow( mMainWin->winId() ); | 153 | KWin::setActiveWindow( mMainWin->winId() ); |
158 | } else { | 154 | } else { |
159 | mMainWin = new KAddressBookMain; | 155 | mMainWin = new KAddressBookMain; |
160 | mMainWin->show(); | 156 | mMainWin->show(); |
161 | } | 157 | } |
162 | } | 158 | } |
163 | // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do | 159 | // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do |
164 | if ( !addr.isEmpty() ) | 160 | if ( !addr.isEmpty() ) |
165 | mMainWin->addEmail( addr ); | 161 | mMainWin->addEmail( addr ); |
166 | 162 | ||
167 | if ( !uid.isEmpty() ) | 163 | if ( !uid.isEmpty() ) |
168 | mMainWin->showContactEditor( uid ); | 164 | mMainWin->showContactEditor( uid ); |
169 | if ( args->isSet( "new-contact" ) ) { | 165 | if ( args->isSet( "new-contact" ) ) { |
170 | mMainWin->newContact(); | 166 | mMainWin->newContact(); |
171 | } | 167 | } |
172 | } | 168 | } |
173 | 169 | ||
174 | KCrash::setEmergencySaveFunction( crashHandler ); | 170 | KCrash::setEmergencySaveFunction( crashHandler ); |
175 | 171 | ||
176 | return 0; | 172 | return 0; |
177 | } | 173 | } |
178 | 174 | ||
179 | // the dummy argument is required, because KMail apparently sends an empty | 175 | // the dummy argument is required, because KMail apparently sends an empty |
180 | // argument. | 176 | // argument. |
181 | static KCmdLineOptions kmoptions[] = | 177 | static KCmdLineOptions kmoptions[] = |
182 | { | 178 | { |
183 | { "a", 0 , 0 }, | 179 | { "a", 0 , 0 }, |
184 | { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, | 180 | { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, |
185 | { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, | 181 | { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, |
186 | { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, | 182 | { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, |
187 | { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, | 183 | { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, |
188 | { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, | 184 | { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, |
189 | { 0, 0, 0} | 185 | { 0, 0, 0} |
190 | }; | 186 | }; |
191 | 187 | ||
192 | int main( int argc, char *argv[] ) | 188 | int main( int argc, char *argv[] ) |
193 | { | 189 | { |
194 | KLocale::setMainCatalogue( "kaddressbook" ); | 190 | KLocale::setMainCatalogue( "kaddressbook" ); |
195 | 191 | ||
196 | KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); | 192 | KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); |
197 | KCmdLineArgs::addCmdLineOptions( kmoptions ); | 193 | KCmdLineArgs::addCmdLineOptions( kmoptions ); |
198 | KUniqueApplication::addCmdLineOptions(); | 194 | KUniqueApplication::addCmdLineOptions(); |
199 | 195 | ||
200 | if ( !KAddressBookApp::start() ) | 196 | if ( !KAddressBookApp::start() ) |
201 | exit( 0 ); | 197 | exit( 0 ); |
202 | 198 | ||
203 | KAddressBookApp app; | 199 | KAddressBookApp app; |
204 | KGlobal::locale()->insertCatalogue( "libkdepim" ); | 200 | KGlobal::locale()->insertCatalogue( "libkdepim" ); |
205 | 201 | ||
206 | return app.exec(); | 202 | return app.exec(); |
207 | } | 203 | } |
208 | */ | 204 | */ |