-rw-r--r-- | kaddressbook/kabcore.cpp | 75 | ||||
-rw-r--r-- | kaddressbook/kaddressbookview.h | 1 | ||||
-rw-r--r-- | kaddressbook/viewmanager.cpp | 5 | ||||
-rw-r--r-- | kaddressbook/viewmanager.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 53 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.h | 2 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.cpp | 47 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 49 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.h | 1 |
10 files changed, 159 insertions, 76 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 1a1bcff..2a2f904 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,2162 +1,2089 @@ | |||
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 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "kabcore.h" | 31 | #include "kabcore.h" |
32 | 32 | ||
33 | #include <stdaddressbook.h> | 33 | #include <stdaddressbook.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | 35 | ||
36 | #ifndef KAB_EMBEDDED | 36 | #ifndef KAB_EMBEDDED |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qdir.h> | 38 | #include <qdir.h> |
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qapplicaton.h> | 40 | #include <qapplicaton.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qregexp.h> | 42 | #include <qregexp.h> |
43 | #include <qvbox.h> | 43 | #include <qvbox.h> |
44 | #include <kabc/addresseelist.h> | 44 | #include <kabc/addresseelist.h> |
45 | #include <kabc/errorhandler.h> | 45 | #include <kabc/errorhandler.h> |
46 | #include <kabc/resource.h> | 46 | #include <kabc/resource.h> |
47 | #include <kabc/vcardconverter.h> | 47 | #include <kabc/vcardconverter.h> |
48 | #include <kapplication.h> | 48 | #include <kapplication.h> |
49 | #include <kactionclasses.h> | 49 | #include <kactionclasses.h> |
50 | #include <kcmultidialog.h> | 50 | #include <kcmultidialog.h> |
51 | #include <kdebug.h> | 51 | #include <kdebug.h> |
52 | #include <kdeversion.h> | 52 | #include <kdeversion.h> |
53 | #include <kkeydialog.h> | 53 | #include <kkeydialog.h> |
54 | #include <kmessagebox.h> | 54 | #include <kmessagebox.h> |
55 | #include <kprinter.h> | 55 | #include <kprinter.h> |
56 | #include <kprotocolinfo.h> | 56 | #include <kprotocolinfo.h> |
57 | #include <kresources/selectdialog.h> | 57 | #include <kresources/selectdialog.h> |
58 | #include <kstandarddirs.h> | 58 | #include <kstandarddirs.h> |
59 | #include <ktempfile.h> | 59 | #include <ktempfile.h> |
60 | #include <kxmlguiclient.h> | 60 | #include <kxmlguiclient.h> |
61 | #include <kaboutdata.h> | 61 | #include <kaboutdata.h> |
62 | #include <libkdepim/categoryselectdialog.h> | 62 | #include <libkdepim/categoryselectdialog.h> |
63 | 63 | ||
64 | #include "addresseeutil.h" | 64 | #include "addresseeutil.h" |
65 | #include "addresseeeditordialog.h" | 65 | #include "addresseeeditordialog.h" |
66 | #include "extensionmanager.h" | 66 | #include "extensionmanager.h" |
67 | #include "kstdaction.h" | 67 | #include "kstdaction.h" |
68 | #include "kaddressbookservice.h" | 68 | #include "kaddressbookservice.h" |
69 | #include "ldapsearchdialog.h" | 69 | #include "ldapsearchdialog.h" |
70 | #include "printing/printingwizard.h" | 70 | #include "printing/printingwizard.h" |
71 | #else // KAB_EMBEDDED | 71 | #else // KAB_EMBEDDED |
72 | 72 | ||
73 | #include <kapplication.h> | 73 | #include <kapplication.h> |
74 | #include "KDGanttMinimizeSplitter.h" | 74 | #include "KDGanttMinimizeSplitter.h" |
75 | #include "kaddressbookmain.h" | 75 | #include "kaddressbookmain.h" |
76 | #include "kactioncollection.h" | 76 | #include "kactioncollection.h" |
77 | #include "addresseedialog.h" | 77 | #include "addresseedialog.h" |
78 | //US | 78 | //US |
79 | #include <libkdepim/addresseeview.h> | 79 | #include <libkdepim/addresseeview.h> |
80 | 80 | ||
81 | #include <qapp.h> | 81 | #include <qapp.h> |
82 | #include <qmenubar.h> | 82 | #include <qmenubar.h> |
83 | //#include <qtoolbar.h> | 83 | //#include <qtoolbar.h> |
84 | #include <qmessagebox.h> | 84 | #include <qmessagebox.h> |
85 | #include <kdebug.h> | 85 | #include <kdebug.h> |
86 | #include <kiconloader.h> // needed for SmallIcon | 86 | #include <kiconloader.h> // needed for SmallIcon |
87 | #include <kresources/kcmkresources.h> | 87 | #include <kresources/kcmkresources.h> |
88 | #include <ktoolbar.h> | 88 | #include <ktoolbar.h> |
89 | 89 | ||
90 | 90 | ||
91 | //#include <qlabel.h> | 91 | //#include <qlabel.h> |
92 | 92 | ||
93 | 93 | ||
94 | #ifndef DESKTOP_VERSION | 94 | #ifndef DESKTOP_VERSION |
95 | #include <qpe/ir.h> | 95 | #include <qpe/ir.h> |
96 | #include <qtopia/qcopenvelope_qws.h> | 96 | #include <qtopia/qcopenvelope_qws.h> |
97 | #else | 97 | #else |
98 | 98 | ||
99 | #endif | 99 | #endif |
100 | 100 | ||
101 | #endif // KAB_EMBEDDED | 101 | #endif // KAB_EMBEDDED |
102 | #include "kcmconfigs/kcmkabconfig.h" | 102 | #include "kcmconfigs/kcmkabconfig.h" |
103 | #include "kcmconfigs/kcmkdepimconfig.h" | 103 | #include "kcmconfigs/kcmkdepimconfig.h" |
104 | #include "kpimglobalprefs.h" | 104 | #include "kpimglobalprefs.h" |
105 | #include "externalapphandler.h" | 105 | #include "externalapphandler.h" |
106 | 106 | ||
107 | 107 | ||
108 | #include <kresources/selectdialog.h> | 108 | #include <kresources/selectdialog.h> |
109 | #include <kmessagebox.h> | 109 | #include <kmessagebox.h> |
110 | 110 | ||
111 | #include <picture.h> | 111 | #include <picture.h> |
112 | #include <resource.h> | 112 | #include <resource.h> |
113 | 113 | ||
114 | //US#include <qsplitter.h> | 114 | //US#include <qsplitter.h> |
115 | #include <qmap.h> | 115 | #include <qmap.h> |
116 | #include <qdir.h> | 116 | #include <qdir.h> |
117 | #include <qfile.h> | 117 | #include <qfile.h> |
118 | #include <qvbox.h> | 118 | #include <qvbox.h> |
119 | #include <qlayout.h> | 119 | #include <qlayout.h> |
120 | #include <qclipboard.h> | 120 | #include <qclipboard.h> |
121 | #include <qtextstream.h> | 121 | #include <qtextstream.h> |
122 | 122 | ||
123 | #include <libkdepim/categoryselectdialog.h> | 123 | #include <libkdepim/categoryselectdialog.h> |
124 | #include <kabc/vcardconverter.h> | 124 | #include <kabc/vcardconverter.h> |
125 | 125 | ||
126 | 126 | ||
127 | #include "addresseeutil.h" | 127 | #include "addresseeutil.h" |
128 | #include "undocmds.h" | 128 | #include "undocmds.h" |
129 | #include "addresseeeditordialog.h" | 129 | #include "addresseeeditordialog.h" |
130 | #include "viewmanager.h" | 130 | #include "viewmanager.h" |
131 | #include "details/detailsviewcontainer.h" | 131 | #include "details/detailsviewcontainer.h" |
132 | #include "kabprefs.h" | 132 | #include "kabprefs.h" |
133 | #include "xxportmanager.h" | 133 | #include "xxportmanager.h" |
134 | #include "incsearchwidget.h" | 134 | #include "incsearchwidget.h" |
135 | #include "jumpbuttonbar.h" | 135 | #include "jumpbuttonbar.h" |
136 | #include "extensionmanager.h" | 136 | #include "extensionmanager.h" |
137 | #include "addresseeconfig.h" | 137 | #include "addresseeconfig.h" |
138 | #include <kcmultidialog.h> | 138 | #include <kcmultidialog.h> |
139 | 139 | ||
140 | #ifdef _WIN32_ | 140 | #ifdef _WIN32_ |
141 | 141 | ||
142 | #include "kaimportoldialog.h" | 142 | #include "kaimportoldialog.h" |
143 | #endif | 143 | #endif |
144 | 144 | ||
145 | bool pasteWithNewUid = true; | 145 | bool pasteWithNewUid = true; |
146 | 146 | ||
147 | #ifdef KAB_EMBEDDED | 147 | #ifdef KAB_EMBEDDED |
148 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 148 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
149 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 149 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
150 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 150 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
151 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 151 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
152 | #else //KAB_EMBEDDED | 152 | #else //KAB_EMBEDDED |
153 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 153 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
154 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 154 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
155 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 155 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
156 | mReadWrite( readWrite ), mModified( false ) | 156 | mReadWrite( readWrite ), mModified( false ) |
157 | #endif //KAB_EMBEDDED | 157 | #endif //KAB_EMBEDDED |
158 | { | 158 | { |
159 | 159 | ||
160 | mExtensionBarSplitter = 0; | 160 | mExtensionBarSplitter = 0; |
161 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 161 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
162 | 162 | ||
163 | mAddressBook = KABC::StdAddressBook::self(); | 163 | mAddressBook = KABC::StdAddressBook::self(); |
164 | KABC::StdAddressBook::setAutomaticSave( false ); | 164 | KABC::StdAddressBook::setAutomaticSave( false ); |
165 | 165 | ||
166 | #ifndef KAB_EMBEDDED | 166 | #ifndef KAB_EMBEDDED |
167 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 167 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
168 | #endif //KAB_EMBEDDED | 168 | #endif //KAB_EMBEDDED |
169 | 169 | ||
170 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 170 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
171 | SLOT( addressBookChanged() ) ); | 171 | SLOT( addressBookChanged() ) ); |
172 | 172 | ||
173 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 173 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
174 | "X-Department", "KADDRESSBOOK" ); | 174 | "X-Department", "KADDRESSBOOK" ); |
175 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 175 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
176 | "X-Profession", "KADDRESSBOOK" ); | 176 | "X-Profession", "KADDRESSBOOK" ); |
177 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 177 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
178 | "X-AssistantsName", "KADDRESSBOOK" ); | 178 | "X-AssistantsName", "KADDRESSBOOK" ); |
179 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 179 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
180 | "X-ManagersName", "KADDRESSBOOK" ); | 180 | "X-ManagersName", "KADDRESSBOOK" ); |
181 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 181 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
182 | "X-SpousesName", "KADDRESSBOOK" ); | 182 | "X-SpousesName", "KADDRESSBOOK" ); |
183 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 183 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
184 | "X-Office", "KADDRESSBOOK" ); | 184 | "X-Office", "KADDRESSBOOK" ); |
185 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 185 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
186 | "X-IMAddress", "KADDRESSBOOK" ); | 186 | "X-IMAddress", "KADDRESSBOOK" ); |
187 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 187 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
188 | "X-Anniversary", "KADDRESSBOOK" ); | 188 | "X-Anniversary", "KADDRESSBOOK" ); |
189 | 189 | ||
190 | //US added this field to become compatible with Opie/qtopia addressbook | 190 | //US added this field to become compatible with Opie/qtopia addressbook |
191 | // values can be "female" or "male" or "". An empty field represents undefined. | 191 | // values can be "female" or "male" or "". An empty field represents undefined. |
192 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 192 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
193 | "X-Gender", "KADDRESSBOOK" ); | 193 | "X-Gender", "KADDRESSBOOK" ); |
194 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 194 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
195 | "X-Children", "KADDRESSBOOK" ); | 195 | "X-Children", "KADDRESSBOOK" ); |
196 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 196 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
197 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 197 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
198 | 198 | ||
199 | initGUI(); | 199 | initGUI(); |
200 | 200 | ||
201 | mIncSearchWidget->setFocus(); | 201 | mIncSearchWidget->setFocus(); |
202 | 202 | ||
203 | 203 | ||
204 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 204 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
205 | SLOT( setContactSelected( const QString& ) ) ); | 205 | SLOT( setContactSelected( const QString& ) ) ); |
206 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 206 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
207 | SLOT( executeContact( const QString& ) ) ); | 207 | SLOT( executeContact( const QString& ) ) ); |
208 | 208 | ||
209 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 209 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
210 | SLOT( deleteContacts( ) ) ); | 210 | SLOT( deleteContacts( ) ) ); |
211 | connect( mViewManager, SIGNAL( modified() ), | 211 | connect( mViewManager, SIGNAL( modified() ), |
212 | SLOT( setModified() ) ); | 212 | SLOT( setModified() ) ); |
213 | 213 | ||
214 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 214 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
215 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 215 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
216 | 216 | ||
217 | connect( mXXPortManager, SIGNAL( modified() ), | 217 | connect( mXXPortManager, SIGNAL( modified() ), |
218 | SLOT( setModified() ) ); | 218 | SLOT( setModified() ) ); |
219 | 219 | ||
220 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 220 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
221 | SLOT( incrementalSearch( const QString& ) ) ); | 221 | SLOT( incrementalSearch( const QString& ) ) ); |
222 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 222 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
223 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 223 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
224 | 224 | ||
225 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 225 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
226 | SLOT( sendMail( const QString& ) ) ); | 226 | SLOT( sendMail( const QString& ) ) ); |
227 | 227 | ||
228 | 228 | ||
229 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 229 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
230 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 230 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
231 | 231 | ||
232 | 232 | ||
233 | #ifndef KAB_EMBEDDED | 233 | #ifndef KAB_EMBEDDED |
234 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 234 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
235 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 235 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
236 | 236 | ||
237 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 237 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
238 | SLOT( browse( const QString& ) ) ); | 238 | SLOT( browse( const QString& ) ) ); |
239 | 239 | ||
240 | 240 | ||
241 | mAddressBookService = new KAddressBookService( this ); | 241 | mAddressBookService = new KAddressBookService( this ); |
242 | 242 | ||
243 | #endif //KAB_EMBEDDED | 243 | #endif //KAB_EMBEDDED |
244 | mEditorDialog = 0; | 244 | mEditorDialog = 0; |
245 | createAddresseeEditorDialog( this ); | 245 | createAddresseeEditorDialog( this ); |
246 | setModified( false ); | 246 | setModified( false ); |
247 | } | 247 | } |
248 | 248 | ||
249 | KABCore::~KABCore() | 249 | KABCore::~KABCore() |
250 | { | 250 | { |
251 | // save(); | 251 | // save(); |
252 | //saveSettings(); | 252 | //saveSettings(); |
253 | //KABPrefs::instance()->writeConfig(); | 253 | //KABPrefs::instance()->writeConfig(); |
254 | delete AddresseeConfig::instance(); | 254 | delete AddresseeConfig::instance(); |
255 | mAddressBook = 0; | 255 | mAddressBook = 0; |
256 | KABC::StdAddressBook::close(); | 256 | KABC::StdAddressBook::close(); |
257 | } | 257 | } |
258 | 258 | ||
259 | void KABCore::restoreSettings() | 259 | void KABCore::restoreSettings() |
260 | { | 260 | { |
261 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 261 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
262 | 262 | ||
263 | bool state; | 263 | bool state; |
264 | 264 | ||
265 | if (mMultipleViewsAtOnce) | 265 | if (mMultipleViewsAtOnce) |
266 | state = KABPrefs::instance()->mDetailsPageVisible; | 266 | state = KABPrefs::instance()->mDetailsPageVisible; |
267 | else | 267 | else |
268 | state = false; | 268 | state = false; |
269 | 269 | ||
270 | mActionDetails->setChecked( state ); | 270 | mActionDetails->setChecked( state ); |
271 | setDetailsVisible( state ); | 271 | setDetailsVisible( state ); |
272 | 272 | ||
273 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 273 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
274 | 274 | ||
275 | mActionJumpBar->setChecked( state ); | 275 | mActionJumpBar->setChecked( state ); |
276 | setJumpButtonBarVisible( state ); | 276 | setJumpButtonBarVisible( state ); |
277 | /*US | 277 | /*US |
278 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 278 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
279 | if ( splitterSize.count() == 0 ) { | 279 | if ( splitterSize.count() == 0 ) { |
280 | splitterSize.append( width() / 2 ); | 280 | splitterSize.append( width() / 2 ); |
281 | splitterSize.append( width() / 2 ); | 281 | splitterSize.append( width() / 2 ); |
282 | } | 282 | } |
283 | mMiniSplitter->setSizes( splitterSize ); | 283 | mMiniSplitter->setSizes( splitterSize ); |
284 | if ( mExtensionBarSplitter ) { | 284 | if ( mExtensionBarSplitter ) { |
285 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 285 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
286 | if ( splitterSize.count() == 0 ) { | 286 | if ( splitterSize.count() == 0 ) { |
287 | splitterSize.append( width() / 2 ); | 287 | splitterSize.append( width() / 2 ); |
288 | splitterSize.append( width() / 2 ); | 288 | splitterSize.append( width() / 2 ); |
289 | } | 289 | } |
290 | mExtensionBarSplitter->setSizes( splitterSize ); | 290 | mExtensionBarSplitter->setSizes( splitterSize ); |
291 | 291 | ||
292 | } | 292 | } |
293 | */ | 293 | */ |
294 | mViewManager->restoreSettings(); | 294 | mViewManager->restoreSettings(); |
295 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 295 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
296 | mExtensionManager->restoreSettings(); | 296 | mExtensionManager->restoreSettings(); |
297 | #ifdef DESKTOP_VERSION | 297 | #ifdef DESKTOP_VERSION |
298 | int wid = width(); | 298 | int wid = width(); |
299 | if ( wid < 10 ) | 299 | if ( wid < 10 ) |
300 | wid = 400; | 300 | wid = 400; |
301 | #else | 301 | #else |
302 | int wid = QApplication::desktop()->width(); | 302 | int wid = QApplication::desktop()->width(); |
303 | if ( wid < 640 ) | 303 | if ( wid < 640 ) |
304 | wid = QApplication::desktop()->height(); | 304 | wid = QApplication::desktop()->height(); |
305 | #endif | 305 | #endif |
306 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 306 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
307 | if ( true /*splitterSize.count() == 0*/ ) { | 307 | if ( true /*splitterSize.count() == 0*/ ) { |
308 | splitterSize.append( wid / 2 ); | 308 | splitterSize.append( wid / 2 ); |
309 | splitterSize.append( wid / 2 ); | 309 | splitterSize.append( wid / 2 ); |
310 | } | 310 | } |
311 | mMiniSplitter->setSizes( splitterSize ); | 311 | mMiniSplitter->setSizes( splitterSize ); |
312 | if ( mExtensionBarSplitter ) { | 312 | if ( mExtensionBarSplitter ) { |
313 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 313 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
314 | if ( true /*splitterSize.count() == 0*/ ) { | 314 | if ( true /*splitterSize.count() == 0*/ ) { |
315 | splitterSize.append( wid / 2 ); | 315 | splitterSize.append( wid / 2 ); |
316 | splitterSize.append( wid / 2 ); | 316 | splitterSize.append( wid / 2 ); |
317 | } | 317 | } |
318 | mExtensionBarSplitter->setSizes( splitterSize ); | 318 | mExtensionBarSplitter->setSizes( splitterSize ); |
319 | 319 | ||
320 | } | 320 | } |
321 | 321 | ||
322 | 322 | ||
323 | } | 323 | } |
324 | 324 | ||
325 | void KABCore::saveSettings() | 325 | void KABCore::saveSettings() |
326 | { | 326 | { |
327 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 327 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
328 | if ( mExtensionBarSplitter ) | 328 | if ( mExtensionBarSplitter ) |
329 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 329 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
330 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 330 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
331 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 331 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
332 | #ifndef KAB_EMBEDDED | 332 | #ifndef KAB_EMBEDDED |
333 | 333 | ||
334 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 334 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
335 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 335 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
336 | #endif //KAB_EMBEDDED | 336 | #endif //KAB_EMBEDDED |
337 | mExtensionManager->saveSettings(); | 337 | mExtensionManager->saveSettings(); |
338 | mViewManager->saveSettings(); | 338 | mViewManager->saveSettings(); |
339 | 339 | ||
340 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 340 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
341 | } | 341 | } |
342 | 342 | ||
343 | KABC::AddressBook *KABCore::addressBook() const | 343 | KABC::AddressBook *KABCore::addressBook() const |
344 | { | 344 | { |
345 | return mAddressBook; | 345 | return mAddressBook; |
346 | } | 346 | } |
347 | 347 | ||
348 | KConfig *KABCore::config() | 348 | KConfig *KABCore::config() |
349 | { | 349 | { |
350 | #ifndef KAB_EMBEDDED | 350 | #ifndef KAB_EMBEDDED |
351 | return KABPrefs::instance()->config(); | 351 | return KABPrefs::instance()->config(); |
352 | #else //KAB_EMBEDDED | 352 | #else //KAB_EMBEDDED |
353 | return KABPrefs::instance()->getConfig(); | 353 | return KABPrefs::instance()->getConfig(); |
354 | #endif //KAB_EMBEDDED | 354 | #endif //KAB_EMBEDDED |
355 | } | 355 | } |
356 | 356 | ||
357 | KActionCollection *KABCore::actionCollection() const | 357 | KActionCollection *KABCore::actionCollection() const |
358 | { | 358 | { |
359 | return mGUIClient->actionCollection(); | 359 | return mGUIClient->actionCollection(); |
360 | } | 360 | } |
361 | 361 | ||
362 | KABC::Field *KABCore::currentSearchField() const | 362 | KABC::Field *KABCore::currentSearchField() const |
363 | { | 363 | { |
364 | if (mIncSearchWidget) | 364 | if (mIncSearchWidget) |
365 | return mIncSearchWidget->currentField(); | 365 | return mIncSearchWidget->currentField(); |
366 | else | 366 | else |
367 | return 0; | 367 | return 0; |
368 | } | 368 | } |
369 | 369 | ||
370 | QStringList KABCore::selectedUIDs() const | 370 | QStringList KABCore::selectedUIDs() const |
371 | { | 371 | { |
372 | return mViewManager->selectedUids(); | 372 | return mViewManager->selectedUids(); |
373 | } | 373 | } |
374 | 374 | ||
375 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 375 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
376 | { | 376 | { |
377 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 377 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
378 | 378 | ||
379 | QPtrList<KRES::Resource> kresResources; | 379 | QPtrList<KRES::Resource> kresResources; |
380 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 380 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
381 | KABC::Resource *resource; | 381 | KABC::Resource *resource; |
382 | while ( ( resource = resIt.current() ) != 0 ) { | 382 | while ( ( resource = resIt.current() ) != 0 ) { |
383 | ++resIt; | 383 | ++resIt; |
384 | if ( !resource->readOnly() ) { | 384 | if ( !resource->readOnly() ) { |
385 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 385 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
386 | if ( res ) | 386 | if ( res ) |
387 | kresResources.append( res ); | 387 | kresResources.append( res ); |
388 | } | 388 | } |
389 | } | 389 | } |
390 | 390 | ||
391 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 391 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
392 | return static_cast<KABC::Resource*>( res ); | 392 | return static_cast<KABC::Resource*>( res ); |
393 | } | 393 | } |
394 | 394 | ||
395 | #ifndef KAB_EMBEDDED | 395 | #ifndef KAB_EMBEDDED |
396 | KAboutData *KABCore::createAboutData() | 396 | KAboutData *KABCore::createAboutData() |
397 | #else //KAB_EMBEDDED | 397 | #else //KAB_EMBEDDED |
398 | void KABCore::createAboutData() | 398 | void KABCore::createAboutData() |
399 | #endif //KAB_EMBEDDED | 399 | #endif //KAB_EMBEDDED |
400 | { | 400 | { |
401 | #ifndef KAB_EMBEDDED | 401 | #ifndef KAB_EMBEDDED |
402 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 402 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
403 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 403 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
404 | KAboutData::License_GPL_V2, | 404 | KAboutData::License_GPL_V2, |
405 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 405 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
406 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 406 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
407 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 407 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
408 | about->addAuthor( "Cornelius Schumacher", | 408 | about->addAuthor( "Cornelius Schumacher", |
409 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 409 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
410 | "schumacher@kde.org" ); | 410 | "schumacher@kde.org" ); |
411 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 411 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
412 | "mpilone@slac.com" ); | 412 | "mpilone@slac.com" ); |
413 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 413 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
414 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 414 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
415 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 415 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
416 | "michel@klaralvdalens-datakonsult.se" ); | 416 | "michel@klaralvdalens-datakonsult.se" ); |
417 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 417 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
418 | "hansen@kde.org" ); | 418 | "hansen@kde.org" ); |
419 | 419 | ||
420 | return about; | 420 | return about; |
421 | #endif //KAB_EMBEDDED | 421 | #endif //KAB_EMBEDDED |
422 | 422 | ||
423 | QString version; | 423 | QString version; |
424 | #include <../version> | 424 | #include <../version> |
425 | QMessageBox::about( this, "About KAddressbook/Pi", | 425 | QMessageBox::about( this, "About KAddressbook/Pi", |
426 | "KAddressbook/Platform-independent\n" | 426 | "KAddressbook/Platform-independent\n" |
427 | "(KA/Pi) " +version + " - " + | 427 | "(KA/Pi) " +version + " - " + |
428 | #ifdef DESKTOP_VERSION | 428 | #ifdef DESKTOP_VERSION |
429 | "Desktop Edition\n" | 429 | "Desktop Edition\n" |
430 | #else | 430 | #else |
431 | "PDA-Edition\n" | 431 | "PDA-Edition\n" |
432 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 432 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
433 | #endif | 433 | #endif |
434 | 434 | ||
435 | "(c) 2004 Ulf Schenk\n" | 435 | "(c) 2004 Ulf Schenk\n" |
436 | "(c) 2004 Lutz Rogowski\n" | 436 | "(c) 2004 Lutz Rogowski\n" |
437 | "(c) 1997-2003, The KDE PIM Team\n" | 437 | "(c) 1997-2003, The KDE PIM Team\n" |
438 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 438 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
439 | "Don Sanders Original author\n" | 439 | "Don Sanders Original author\n" |
440 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 440 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
441 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 441 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
442 | "Greg Stern DCOP interface\n" | 442 | "Greg Stern DCOP interface\n" |
443 | "Mark Westcot Contact pinning\n" | 443 | "Mark Westcot Contact pinning\n" |
444 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 444 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
445 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 445 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
446 | #ifdef _WIN32_ | 446 | #ifdef _WIN32_ |
447 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 447 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
448 | #endif | 448 | #endif |
449 | ); | 449 | ); |
450 | } | 450 | } |
451 | 451 | ||
452 | void KABCore::setContactSelected( const QString &uid ) | 452 | void KABCore::setContactSelected( const QString &uid ) |
453 | { | 453 | { |
454 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 454 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
455 | if ( !mDetails->isHidden() ) | 455 | if ( !mDetails->isHidden() ) |
456 | mDetails->setAddressee( addr ); | 456 | mDetails->setAddressee( addr ); |
457 | 457 | ||
458 | if ( !addr.isEmpty() ) { | 458 | if ( !addr.isEmpty() ) { |
459 | emit contactSelected( addr.formattedName() ); | 459 | emit contactSelected( addr.formattedName() ); |
460 | KABC::Picture pic = addr.photo(); | 460 | KABC::Picture pic = addr.photo(); |
461 | if ( pic.isIntern() ) { | 461 | if ( pic.isIntern() ) { |
462 | //US emit contactSelected( pic.data() ); | 462 | //US emit contactSelected( pic.data() ); |
463 | //US instead use: | 463 | //US instead use: |
464 | QPixmap px; | 464 | QPixmap px; |
465 | if (pic.data().isNull() != true) | 465 | if (pic.data().isNull() != true) |
466 | { | 466 | { |
467 | px.convertFromImage(pic.data()); | 467 | px.convertFromImage(pic.data()); |
468 | } | 468 | } |
469 | 469 | ||
470 | emit contactSelected( px ); | 470 | emit contactSelected( px ); |
471 | } | 471 | } |
472 | } | 472 | } |
473 | 473 | ||
474 | 474 | ||
475 | mExtensionManager->setSelectionChanged(); | 475 | mExtensionManager->setSelectionChanged(); |
476 | 476 | ||
477 | // update the actions | 477 | // update the actions |
478 | bool selected = !uid.isEmpty(); | 478 | bool selected = !uid.isEmpty(); |
479 | 479 | ||
480 | if ( mReadWrite ) { | 480 | if ( mReadWrite ) { |
481 | mActionCut->setEnabled( selected ); | 481 | mActionCut->setEnabled( selected ); |
482 | mActionPaste->setEnabled( selected ); | 482 | mActionPaste->setEnabled( selected ); |
483 | } | 483 | } |
484 | 484 | ||
485 | mActionCopy->setEnabled( selected ); | 485 | mActionCopy->setEnabled( selected ); |
486 | mActionDelete->setEnabled( selected ); | 486 | mActionDelete->setEnabled( selected ); |
487 | mActionEditAddressee->setEnabled( selected ); | 487 | mActionEditAddressee->setEnabled( selected ); |
488 | mActionMail->setEnabled( selected ); | 488 | mActionMail->setEnabled( selected ); |
489 | mActionMailVCard->setEnabled( selected ); | 489 | mActionMailVCard->setEnabled( selected ); |
490 | //if (mActionBeam) | 490 | //if (mActionBeam) |
491 | //mActionBeam->setEnabled( selected ); | 491 | //mActionBeam->setEnabled( selected ); |
492 | 492 | ||
493 | if (mActionBeamVCard) | 493 | if (mActionBeamVCard) |
494 | mActionBeamVCard->setEnabled( selected ); | 494 | mActionBeamVCard->setEnabled( selected ); |
495 | 495 | ||
496 | mActionWhoAmI->setEnabled( selected ); | 496 | mActionWhoAmI->setEnabled( selected ); |
497 | mActionCategories->setEnabled( selected ); | 497 | mActionCategories->setEnabled( selected ); |
498 | } | 498 | } |
499 | 499 | ||
500 | void KABCore::sendMail() | 500 | void KABCore::sendMail() |
501 | { | 501 | { |
502 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 502 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
503 | } | 503 | } |
504 | 504 | ||
505 | void KABCore::sendMail( const QString& emaillist ) | 505 | void KABCore::sendMail( const QString& emaillist ) |
506 | { | 506 | { |
507 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 507 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
508 | if (emaillist.contains(",") > 0) | 508 | if (emaillist.contains(",") > 0) |
509 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 509 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
510 | else | 510 | else |
511 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 511 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
512 | } | 512 | } |
513 | 513 | ||
514 | 514 | ||
515 | 515 | ||
516 | void KABCore::mailVCard() | 516 | void KABCore::mailVCard() |
517 | { | 517 | { |
518 | QStringList uids = mViewManager->selectedUids(); | 518 | QStringList uids = mViewManager->selectedUids(); |
519 | if ( !uids.isEmpty() ) | 519 | if ( !uids.isEmpty() ) |
520 | mailVCard( uids ); | 520 | mailVCard( uids ); |
521 | } | 521 | } |
522 | 522 | ||
523 | void KABCore::mailVCard( const QStringList& uids ) | 523 | void KABCore::mailVCard( const QStringList& uids ) |
524 | { | 524 | { |
525 | QStringList urls; | 525 | QStringList urls; |
526 | 526 | ||
527 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 527 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
528 | 528 | ||
529 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 529 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
530 | 530 | ||
531 | 531 | ||
532 | 532 | ||
533 | QDir().mkdir( dirName, true ); | 533 | QDir().mkdir( dirName, true ); |
534 | 534 | ||
535 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 535 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
536 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 536 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
537 | 537 | ||
538 | if ( a.isEmpty() ) | 538 | if ( a.isEmpty() ) |
539 | continue; | 539 | continue; |
540 | 540 | ||
541 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 541 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
542 | 542 | ||
543 | QString fileName = dirName + "/" + name; | 543 | QString fileName = dirName + "/" + name; |
544 | 544 | ||
545 | QFile outFile(fileName); | 545 | QFile outFile(fileName); |
546 | 546 | ||
547 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 547 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
548 | KABC::VCardConverter converter; | 548 | KABC::VCardConverter converter; |
549 | QString vcard; | 549 | QString vcard; |
550 | 550 | ||
551 | converter.addresseeToVCard( a, vcard ); | 551 | converter.addresseeToVCard( a, vcard ); |
552 | 552 | ||
553 | QTextStream t( &outFile ); // use a text stream | 553 | QTextStream t( &outFile ); // use a text stream |
554 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 554 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
555 | t << vcard; | 555 | t << vcard; |
556 | 556 | ||
557 | outFile.close(); | 557 | outFile.close(); |
558 | 558 | ||
559 | urls.append( fileName ); | 559 | urls.append( fileName ); |
560 | } | 560 | } |
561 | } | 561 | } |
562 | 562 | ||
563 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 563 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
564 | 564 | ||
565 | 565 | ||
566 | /*US | 566 | /*US |
567 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 567 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
568 | QString::null, // subject | 568 | QString::null, // subject |
569 | QString::null, // body | 569 | QString::null, // body |
570 | QString::null, | 570 | QString::null, |
571 | urls ); // attachments | 571 | urls ); // attachments |
572 | */ | 572 | */ |
573 | 573 | ||
574 | } | 574 | } |
575 | 575 | ||
576 | /** | 576 | /** |
577 | Beams the "WhoAmI contact. | 577 | Beams the "WhoAmI contact. |
578 | */ | 578 | */ |
579 | void KABCore::beamMySelf() | 579 | void KABCore::beamMySelf() |
580 | { | 580 | { |
581 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 581 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
582 | if (!a.isEmpty()) | 582 | if (!a.isEmpty()) |
583 | { | 583 | { |
584 | QStringList uids; | 584 | QStringList uids; |
585 | uids << a.uid(); | 585 | uids << a.uid(); |
586 | 586 | ||
587 | beamVCard(uids); | 587 | beamVCard(uids); |
588 | } else { | 588 | } else { |
589 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 589 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
590 | 590 | ||
591 | 591 | ||
592 | } | 592 | } |
593 | } | 593 | } |
594 | 594 | ||
595 | void KABCore::beamVCard() | 595 | void KABCore::beamVCard() |
596 | { | 596 | { |
597 | QStringList uids = mViewManager->selectedUids(); | 597 | QStringList uids = mViewManager->selectedUids(); |
598 | if ( !uids.isEmpty() ) | 598 | if ( !uids.isEmpty() ) |
599 | beamVCard( uids ); | 599 | beamVCard( uids ); |
600 | } | 600 | } |
601 | 601 | ||
602 | 602 | ||
603 | void KABCore::beamVCard(const QStringList& uids) | 603 | void KABCore::beamVCard(const QStringList& uids) |
604 | { | 604 | { |
605 | /*US | 605 | /*US |
606 | QString beamFilename; | 606 | QString beamFilename; |
607 | Opie::OPimContact c; | 607 | Opie::OPimContact c; |
608 | if ( actionPersonal->isOn() ) { | 608 | if ( actionPersonal->isOn() ) { |
609 | beamFilename = addressbookPersonalVCardName(); | 609 | beamFilename = addressbookPersonalVCardName(); |
610 | if ( !QFile::exists( beamFilename ) ) | 610 | if ( !QFile::exists( beamFilename ) ) |
611 | return; // can't beam a non-existent file | 611 | return; // can't beam a non-existent file |
612 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 612 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
613 | beamFilename ); | 613 | beamFilename ); |
614 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 614 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
615 | Opie::OPimContactAccess::List allList = access->allRecords(); | 615 | Opie::OPimContactAccess::List allList = access->allRecords(); |
616 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 616 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
617 | c = *it; | 617 | c = *it; |
618 | 618 | ||
619 | delete access; | 619 | delete access; |
620 | } else { | 620 | } else { |
621 | unlink( beamfile ); // delete if exists | 621 | unlink( beamfile ); // delete if exists |
622 | mkdir("/tmp/obex/", 0755); | 622 | mkdir("/tmp/obex/", 0755); |
623 | c = m_abView -> currentEntry(); | 623 | c = m_abView -> currentEntry(); |
624 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 624 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
625 | beamfile ); | 625 | beamfile ); |
626 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 626 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
627 | access->add( c ); | 627 | access->add( c ); |
628 | access->save(); | 628 | access->save(); |
629 | delete access; | 629 | delete access; |
630 | 630 | ||
631 | beamFilename = beamfile; | 631 | beamFilename = beamfile; |
632 | } | 632 | } |
633 | 633 | ||
634 | owarn << "Beaming: " << beamFilename << oendl; | 634 | owarn << "Beaming: " << beamFilename << oendl; |
635 | */ | 635 | */ |
636 | 636 | ||
637 | #if 0 | 637 | #if 0 |
638 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 638 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
639 | 639 | ||
640 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 640 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
641 | 641 | ||
642 | QString name = "contact.vcf"; | 642 | QString name = "contact.vcf"; |
643 | 643 | ||
644 | QString fileName = dirName + "/" + name; | 644 | QString fileName = dirName + "/" + name; |
645 | #endif | 645 | #endif |
646 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 646 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
647 | // | 647 | // |
648 | QString fileName = "/tmp/kapibeamfile.vcf"; | 648 | QString fileName = "/tmp/kapibeamfile.vcf"; |
649 | 649 | ||
650 | 650 | ||
651 | //QDir().mkdir( dirName, true ); | 651 | //QDir().mkdir( dirName, true ); |
652 | 652 | ||
653 | 653 | ||
654 | KABC::VCardConverter converter; | 654 | KABC::VCardConverter converter; |
655 | QString description; | 655 | QString description; |
656 | QString datastream; | 656 | QString datastream; |
657 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 657 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
658 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 658 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
659 | 659 | ||
660 | if ( a.isEmpty() ) | 660 | if ( a.isEmpty() ) |
661 | continue; | 661 | continue; |
662 | 662 | ||
663 | if (description.isEmpty()) | 663 | if (description.isEmpty()) |
664 | description = a.formattedName(); | 664 | description = a.formattedName(); |
665 | 665 | ||
666 | QString vcard; | 666 | QString vcard; |
667 | converter.addresseeToVCard( a, vcard ); | 667 | converter.addresseeToVCard( a, vcard ); |
668 | int start = 0; | 668 | int start = 0; |
669 | int next; | 669 | int next; |
670 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 670 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
671 | int semi = vcard.find(";", next); | 671 | int semi = vcard.find(";", next); |
672 | int dopp = vcard.find(":", next); | 672 | int dopp = vcard.find(":", next); |
673 | int sep; | 673 | int sep; |
674 | if ( semi < dopp && semi >= 0 ) | 674 | if ( semi < dopp && semi >= 0 ) |
675 | sep = semi ; | 675 | sep = semi ; |
676 | else | 676 | else |
677 | sep = dopp; | 677 | sep = dopp; |
678 | datastream +=vcard.mid( start, next - start); | 678 | datastream +=vcard.mid( start, next - start); |
679 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 679 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
680 | start = sep; | 680 | start = sep; |
681 | } | 681 | } |
682 | datastream += vcard.mid( start,vcard.length() ); | 682 | datastream += vcard.mid( start,vcard.length() ); |
683 | } | 683 | } |
684 | #ifndef DESKTOP_VERSION | 684 | #ifndef DESKTOP_VERSION |
685 | QFile outFile(fileName); | 685 | QFile outFile(fileName); |
686 | if ( outFile.open(IO_WriteOnly) ) { | 686 | if ( outFile.open(IO_WriteOnly) ) { |
687 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 687 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
688 | QTextStream t( &outFile ); // use a text stream | 688 | QTextStream t( &outFile ); // use a text stream |
689 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 689 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
690 | t <<datastream; | 690 | t <<datastream; |
691 | outFile.close(); | 691 | outFile.close(); |
692 | Ir *ir = new Ir( this ); | 692 | Ir *ir = new Ir( this ); |
693 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 693 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
694 | ir->send( fileName, description, "text/x-vCard" ); | 694 | ir->send( fileName, description, "text/x-vCard" ); |
695 | } else { | 695 | } else { |
696 | qDebug("Error open temp beam file "); | 696 | qDebug("Error open temp beam file "); |
697 | return; | 697 | return; |
698 | } | 698 | } |
699 | #endif | 699 | #endif |
700 | 700 | ||
701 | } | 701 | } |
702 | 702 | ||
703 | void KABCore::beamDone( Ir *ir ) | 703 | void KABCore::beamDone( Ir *ir ) |
704 | { | 704 | { |
705 | #ifndef DESKTOP_VERSION | 705 | #ifndef DESKTOP_VERSION |
706 | delete ir; | 706 | delete ir; |
707 | #endif | 707 | #endif |
708 | } | 708 | } |
709 | 709 | ||
710 | 710 | ||
711 | void KABCore::browse( const QString& url ) | 711 | void KABCore::browse( const QString& url ) |
712 | { | 712 | { |
713 | #ifndef KAB_EMBEDDED | 713 | #ifndef KAB_EMBEDDED |
714 | kapp->invokeBrowser( url ); | 714 | kapp->invokeBrowser( url ); |
715 | #else //KAB_EMBEDDED | 715 | #else //KAB_EMBEDDED |
716 | qDebug("KABCore::browse must be fixed"); | 716 | qDebug("KABCore::browse must be fixed"); |
717 | #endif //KAB_EMBEDDED | 717 | #endif //KAB_EMBEDDED |
718 | } | 718 | } |
719 | 719 | ||
720 | void KABCore::selectAllContacts() | 720 | void KABCore::selectAllContacts() |
721 | { | 721 | { |
722 | mViewManager->setSelected( QString::null, true ); | 722 | mViewManager->setSelected( QString::null, true ); |
723 | } | 723 | } |
724 | 724 | ||
725 | void KABCore::deleteContacts() | 725 | void KABCore::deleteContacts() |
726 | { | 726 | { |
727 | QStringList uidList = mViewManager->selectedUids(); | 727 | QStringList uidList = mViewManager->selectedUids(); |
728 | deleteContacts( uidList ); | 728 | deleteContacts( uidList ); |
729 | } | 729 | } |
730 | 730 | ||
731 | void KABCore::deleteContacts( const QStringList &uids ) | 731 | void KABCore::deleteContacts( const QStringList &uids ) |
732 | { | 732 | { |
733 | if ( uids.count() > 0 ) { | 733 | if ( uids.count() > 0 ) { |
734 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 734 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
735 | UndoStack::instance()->push( command ); | 735 | UndoStack::instance()->push( command ); |
736 | RedoStack::instance()->clear(); | 736 | RedoStack::instance()->clear(); |
737 | 737 | ||
738 | // now if we deleted anything, refresh | 738 | // now if we deleted anything, refresh |
739 | setContactSelected( QString::null ); | 739 | setContactSelected( QString::null ); |
740 | setModified( true ); | 740 | setModified( true ); |
741 | } | 741 | } |
742 | } | 742 | } |
743 | 743 | ||
744 | void KABCore::copyContacts() | 744 | void KABCore::copyContacts() |
745 | { | 745 | { |
746 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 746 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
747 | 747 | ||
748 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 748 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
749 | 749 | ||
750 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 750 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
751 | 751 | ||
752 | QClipboard *cb = QApplication::clipboard(); | 752 | QClipboard *cb = QApplication::clipboard(); |
753 | cb->setText( clipText ); | 753 | cb->setText( clipText ); |
754 | } | 754 | } |
755 | 755 | ||
756 | void KABCore::cutContacts() | 756 | void KABCore::cutContacts() |
757 | { | 757 | { |
758 | QStringList uidList = mViewManager->selectedUids(); | 758 | QStringList uidList = mViewManager->selectedUids(); |
759 | 759 | ||
760 | //US if ( uidList.size() > 0 ) { | 760 | //US if ( uidList.size() > 0 ) { |
761 | if ( uidList.count() > 0 ) { | 761 | if ( uidList.count() > 0 ) { |
762 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 762 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
763 | UndoStack::instance()->push( command ); | 763 | UndoStack::instance()->push( command ); |
764 | RedoStack::instance()->clear(); | 764 | RedoStack::instance()->clear(); |
765 | 765 | ||
766 | setModified( true ); | 766 | setModified( true ); |
767 | } | 767 | } |
768 | } | 768 | } |
769 | 769 | ||
770 | void KABCore::pasteContacts() | 770 | void KABCore::pasteContacts() |
771 | { | 771 | { |
772 | QClipboard *cb = QApplication::clipboard(); | 772 | QClipboard *cb = QApplication::clipboard(); |
773 | 773 | ||
774 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 774 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
775 | 775 | ||
776 | pasteContacts( list ); | 776 | pasteContacts( list ); |
777 | } | 777 | } |
778 | 778 | ||
779 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 779 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
780 | { | 780 | { |
781 | KABC::Resource *resource = requestResource( this ); | 781 | KABC::Resource *resource = requestResource( this ); |
782 | KABC::Addressee::List::Iterator it; | 782 | KABC::Addressee::List::Iterator it; |
783 | for ( it = list.begin(); it != list.end(); ++it ) | 783 | for ( it = list.begin(); it != list.end(); ++it ) |
784 | (*it).setResource( resource ); | 784 | (*it).setResource( resource ); |
785 | 785 | ||
786 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 786 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
787 | UndoStack::instance()->push( command ); | 787 | UndoStack::instance()->push( command ); |
788 | RedoStack::instance()->clear(); | 788 | RedoStack::instance()->clear(); |
789 | 789 | ||
790 | setModified( true ); | 790 | setModified( true ); |
791 | } | 791 | } |
792 | 792 | ||
793 | void KABCore::setWhoAmI() | 793 | void KABCore::setWhoAmI() |
794 | { | 794 | { |
795 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 795 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
796 | 796 | ||
797 | if ( addrList.count() > 1 ) { | 797 | if ( addrList.count() > 1 ) { |
798 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 798 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
799 | return; | 799 | return; |
800 | } | 800 | } |
801 | 801 | ||
802 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 802 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
803 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 803 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
804 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 804 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
805 | } | 805 | } |
806 | 806 | ||
807 | void KABCore::setCategories() | 807 | void KABCore::setCategories() |
808 | { | 808 | { |
809 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 809 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
810 | if ( !dlg.exec() ) | 810 | if ( !dlg.exec() ) |
811 | return; | 811 | return; |
812 | 812 | ||
813 | bool merge = false; | 813 | bool merge = false; |
814 | QString msg = i18n( "Merge with existing categories?" ); | 814 | QString msg = i18n( "Merge with existing categories?" ); |
815 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 815 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
816 | merge = true; | 816 | merge = true; |
817 | 817 | ||
818 | QStringList categories = dlg.selectedCategories(); | 818 | QStringList categories = dlg.selectedCategories(); |
819 | 819 | ||
820 | QStringList uids = mViewManager->selectedUids(); | 820 | QStringList uids = mViewManager->selectedUids(); |
821 | QStringList::Iterator it; | 821 | QStringList::Iterator it; |
822 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 822 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
823 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 823 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
824 | if ( !addr.isEmpty() ) { | 824 | if ( !addr.isEmpty() ) { |
825 | if ( !merge ) | 825 | if ( !merge ) |
826 | addr.setCategories( categories ); | 826 | addr.setCategories( categories ); |
827 | else { | 827 | else { |
828 | QStringList addrCategories = addr.categories(); | 828 | QStringList addrCategories = addr.categories(); |
829 | QStringList::Iterator catIt; | 829 | QStringList::Iterator catIt; |
830 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 830 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
831 | if ( !addrCategories.contains( *catIt ) ) | 831 | if ( !addrCategories.contains( *catIt ) ) |
832 | addrCategories.append( *catIt ); | 832 | addrCategories.append( *catIt ); |
833 | } | 833 | } |
834 | addr.setCategories( addrCategories ); | 834 | addr.setCategories( addrCategories ); |
835 | } | 835 | } |
836 | 836 | ||
837 | mAddressBook->insertAddressee( addr ); | 837 | mAddressBook->insertAddressee( addr ); |
838 | } | 838 | } |
839 | } | 839 | } |
840 | 840 | ||
841 | if ( uids.count() > 0 ) | 841 | if ( uids.count() > 0 ) |
842 | setModified( true ); | 842 | setModified( true ); |
843 | } | 843 | } |
844 | 844 | ||
845 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 845 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
846 | { | 846 | { |
847 | mIncSearchWidget->setFields( fields ); | 847 | mIncSearchWidget->setFields( fields ); |
848 | } | 848 | } |
849 | 849 | ||
850 | void KABCore::incrementalSearch( const QString& text ) | 850 | void KABCore::incrementalSearch( const QString& text ) |
851 | { | 851 | { |
852 | mViewManager->setSelected( QString::null, false ); | 852 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
853 | |||
854 | if ( !text.isEmpty() ) { | ||
855 | KABC::Field *field = mIncSearchWidget->currentField(); | ||
856 | QString pattern = text.lower()+"*"; | ||
857 | QRegExp re; | ||
858 | re.setWildcard(true); // most people understand these better. | ||
859 | re.setCaseSensitive(false); | ||
860 | re.setPattern( pattern ); | ||
861 | QStringList foundUids; | ||
862 | if (!re.isValid()) | ||
863 | return; | ||
864 | #if 1 //KDE_VERSION >= 319 | ||
865 | KABC::AddresseeList list( mAddressBook->allAddressees() ); | ||
866 | if ( field ) { | ||
867 | list.sortByField( field ); | ||
868 | KABC::AddresseeList::Iterator it; | ||
869 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
870 | |||
871 | #if QT_VERSION >= 300 | ||
872 | if (re.search(field->value( *it ).lower()) != -1) | ||
873 | #else | ||
874 | if (re.match(field->value( *it ).lower()) != -1) | ||
875 | #endif | ||
876 | { | ||
877 | // if ( field->value( *it ).lower().startsWith( pattern ) ) { | ||
878 | //mViewManager->setSelected( (*it).uid(), true ); | ||
879 | foundUids.append( (*it).uid() ); | ||
880 | //return; | ||
881 | } | ||
882 | } | ||
883 | } else { | ||
884 | KABC::AddresseeList::Iterator it; | ||
885 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
886 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | ||
887 | KABC::Field::List::ConstIterator fieldIt; | ||
888 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | ||
889 | #if QT_VERSION >= 300 | ||
890 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | ||
891 | #else | ||
892 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | ||
893 | #endif | ||
894 | { | ||
895 | // if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | ||
896 | //mViewManager->setSelected( (*it).uid(), true ); | ||
897 | foundUids.append( (*it).uid() ); | ||
898 | //return; | ||
899 | } | ||
900 | } | ||
901 | } | ||
902 | } | ||
903 | if ( foundUids.count() > 0 ) | ||
904 | mViewManager->setListSelected( foundUids ); | ||
905 | #else | ||
906 | KABC::AddressBook::Iterator it; | ||
907 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | ||
908 | if ( field ) { | ||
909 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | ||
910 | mViewManager->setSelected( (*it).uid(), true ); | ||
911 | return; | ||
912 | } | ||
913 | } else { | ||
914 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | ||
915 | KABC::Field::List::ConstIterator fieldIt; | ||
916 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | ||
917 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | ||
918 | mViewManager->setSelected( (*it).uid(), true ); | ||
919 | return; | ||
920 | } | ||
921 | } | ||
922 | } | ||
923 | } | ||
924 | #endif | ||
925 | } | ||
926 | } | 853 | } |
927 | 854 | ||
928 | void KABCore::setModified() | 855 | void KABCore::setModified() |
929 | { | 856 | { |
930 | setModified( true ); | 857 | setModified( true ); |
931 | } | 858 | } |
932 | 859 | ||
933 | void KABCore::setModifiedWOrefresh() | 860 | void KABCore::setModifiedWOrefresh() |
934 | { | 861 | { |
935 | // qDebug("KABCore::setModifiedWOrefresh() "); | 862 | // qDebug("KABCore::setModifiedWOrefresh() "); |
936 | mModified = true; | 863 | mModified = true; |
937 | mActionSave->setEnabled( mModified ); | 864 | mActionSave->setEnabled( mModified ); |
938 | #ifdef DESKTOP_VERSION | 865 | #ifdef DESKTOP_VERSION |
939 | mDetails->refreshView(); | 866 | mDetails->refreshView(); |
940 | #endif | 867 | #endif |
941 | 868 | ||
942 | } | 869 | } |
943 | void KABCore::setModified( bool modified ) | 870 | void KABCore::setModified( bool modified ) |
944 | { | 871 | { |
945 | mModified = modified; | 872 | mModified = modified; |
946 | mActionSave->setEnabled( mModified ); | 873 | mActionSave->setEnabled( mModified ); |
947 | 874 | ||
948 | if ( modified ) | 875 | if ( modified ) |
949 | mJumpButtonBar->recreateButtons(); | 876 | mJumpButtonBar->recreateButtons(); |
950 | 877 | ||
951 | mViewManager->refreshView(); | 878 | mViewManager->refreshView(); |
952 | mDetails->refreshView(); | 879 | mDetails->refreshView(); |
953 | 880 | ||
954 | } | 881 | } |
955 | 882 | ||
956 | bool KABCore::modified() const | 883 | bool KABCore::modified() const |
957 | { | 884 | { |
958 | return mModified; | 885 | return mModified; |
959 | } | 886 | } |
960 | 887 | ||
961 | void KABCore::contactModified( const KABC::Addressee &addr ) | 888 | void KABCore::contactModified( const KABC::Addressee &addr ) |
962 | { | 889 | { |
963 | 890 | ||
964 | Command *command = 0; | 891 | Command *command = 0; |
965 | QString uid; | 892 | QString uid; |
966 | 893 | ||
967 | // check if it exists already | 894 | // check if it exists already |
968 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 895 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
969 | if ( origAddr.isEmpty() ) | 896 | if ( origAddr.isEmpty() ) |
970 | command = new PwNewCommand( mAddressBook, addr ); | 897 | command = new PwNewCommand( mAddressBook, addr ); |
971 | else { | 898 | else { |
972 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 899 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
973 | uid = addr.uid(); | 900 | uid = addr.uid(); |
974 | } | 901 | } |
975 | 902 | ||
976 | UndoStack::instance()->push( command ); | 903 | UndoStack::instance()->push( command ); |
977 | RedoStack::instance()->clear(); | 904 | RedoStack::instance()->clear(); |
978 | 905 | ||
979 | setModified( true ); | 906 | setModified( true ); |
980 | } | 907 | } |
981 | 908 | ||
982 | void KABCore::newContact() | 909 | void KABCore::newContact() |
983 | { | 910 | { |
984 | 911 | ||
985 | 912 | ||
986 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 913 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
987 | 914 | ||
988 | QPtrList<KRES::Resource> kresResources; | 915 | QPtrList<KRES::Resource> kresResources; |
989 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 916 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
990 | KABC::Resource *resource; | 917 | KABC::Resource *resource; |
991 | while ( ( resource = it.current() ) != 0 ) { | 918 | while ( ( resource = it.current() ) != 0 ) { |
992 | ++it; | 919 | ++it; |
993 | if ( !resource->readOnly() ) { | 920 | if ( !resource->readOnly() ) { |
994 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 921 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
995 | if ( res ) | 922 | if ( res ) |
996 | kresResources.append( res ); | 923 | kresResources.append( res ); |
997 | } | 924 | } |
998 | } | 925 | } |
999 | 926 | ||
1000 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 927 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1001 | resource = static_cast<KABC::Resource*>( res ); | 928 | resource = static_cast<KABC::Resource*>( res ); |
1002 | 929 | ||
1003 | if ( resource ) { | 930 | if ( resource ) { |
1004 | KABC::Addressee addr; | 931 | KABC::Addressee addr; |
1005 | addr.setResource( resource ); | 932 | addr.setResource( resource ); |
1006 | mEditorDialog->setAddressee( addr ); | 933 | mEditorDialog->setAddressee( addr ); |
1007 | KApplication::execDialog ( mEditorDialog ); | 934 | KApplication::execDialog ( mEditorDialog ); |
1008 | 935 | ||
1009 | } else | 936 | } else |
1010 | return; | 937 | return; |
1011 | 938 | ||
1012 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 939 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1013 | 940 | ||
1014 | 941 | ||
1015 | } | 942 | } |
1016 | 943 | ||
1017 | void KABCore::addEmail( QString aStr ) | 944 | void KABCore::addEmail( QString aStr ) |
1018 | { | 945 | { |
1019 | #ifndef KAB_EMBEDDED | 946 | #ifndef KAB_EMBEDDED |
1020 | QString fullName, email; | 947 | QString fullName, email; |
1021 | 948 | ||
1022 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 949 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1023 | 950 | ||
1024 | // Try to lookup the addressee matching the email address | 951 | // Try to lookup the addressee matching the email address |
1025 | bool found = false; | 952 | bool found = false; |
1026 | QStringList emailList; | 953 | QStringList emailList; |
1027 | KABC::AddressBook::Iterator it; | 954 | KABC::AddressBook::Iterator it; |
1028 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 955 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1029 | emailList = (*it).emails(); | 956 | emailList = (*it).emails(); |
1030 | if ( emailList.contains( email ) > 0 ) { | 957 | if ( emailList.contains( email ) > 0 ) { |
1031 | found = true; | 958 | found = true; |
1032 | (*it).setNameFromString( fullName ); | 959 | (*it).setNameFromString( fullName ); |
1033 | editContact( (*it).uid() ); | 960 | editContact( (*it).uid() ); |
1034 | } | 961 | } |
1035 | } | 962 | } |
1036 | 963 | ||
1037 | if ( !found ) { | 964 | if ( !found ) { |
1038 | KABC::Addressee addr; | 965 | KABC::Addressee addr; |
1039 | addr.setNameFromString( fullName ); | 966 | addr.setNameFromString( fullName ); |
1040 | addr.insertEmail( email, true ); | 967 | addr.insertEmail( email, true ); |
1041 | 968 | ||
1042 | mAddressBook->insertAddressee( addr ); | 969 | mAddressBook->insertAddressee( addr ); |
1043 | mViewManager->refreshView( addr.uid() ); | 970 | mViewManager->refreshView( addr.uid() ); |
1044 | editContact( addr.uid() ); | 971 | editContact( addr.uid() ); |
1045 | } | 972 | } |
1046 | #else //KAB_EMBEDDED | 973 | #else //KAB_EMBEDDED |
1047 | qDebug("KABCore::addEmail finsih method"); | 974 | qDebug("KABCore::addEmail finsih method"); |
1048 | #endif //KAB_EMBEDDED | 975 | #endif //KAB_EMBEDDED |
1049 | } | 976 | } |
1050 | 977 | ||
1051 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 978 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1052 | { | 979 | { |
1053 | mXXPortManager->importVCard( url, showPreview ); | 980 | mXXPortManager->importVCard( url, showPreview ); |
1054 | } | 981 | } |
1055 | void KABCore::importFromOL() | 982 | void KABCore::importFromOL() |
1056 | { | 983 | { |
1057 | #ifdef _WIN32_ | 984 | #ifdef _WIN32_ |
1058 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 985 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1059 | idgl->exec(); | 986 | idgl->exec(); |
1060 | KABC::Addressee::List list = idgl->getAddressList(); | 987 | KABC::Addressee::List list = idgl->getAddressList(); |
1061 | if ( list.count() > 0 ) { | 988 | if ( list.count() > 0 ) { |
1062 | KABC::Addressee::List listNew; | 989 | KABC::Addressee::List listNew; |
1063 | KABC::Addressee::List listExisting; | 990 | KABC::Addressee::List listExisting; |
1064 | KABC::Addressee::List::Iterator it; | 991 | KABC::Addressee::List::Iterator it; |
1065 | KABC::AddressBook::Iterator iter; | 992 | KABC::AddressBook::Iterator iter; |
1066 | for ( it = list.begin(); it != list.end(); ++it ) { | 993 | for ( it = list.begin(); it != list.end(); ++it ) { |
1067 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 994 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1068 | listNew.append( (*it) ); | 995 | listNew.append( (*it) ); |
1069 | else | 996 | else |
1070 | listExisting.append( (*it) ); | 997 | listExisting.append( (*it) ); |
1071 | } | 998 | } |
1072 | if ( listExisting.count() > 0 ) | 999 | if ( listExisting.count() > 0 ) |
1073 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1000 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1074 | if ( listNew.count() > 0 ) { | 1001 | if ( listNew.count() > 0 ) { |
1075 | pasteWithNewUid = false; | 1002 | pasteWithNewUid = false; |
1076 | pasteContacts( listNew ); | 1003 | pasteContacts( listNew ); |
1077 | pasteWithNewUid = true; | 1004 | pasteWithNewUid = true; |
1078 | } | 1005 | } |
1079 | } | 1006 | } |
1080 | delete idgl; | 1007 | delete idgl; |
1081 | #endif | 1008 | #endif |
1082 | } | 1009 | } |
1083 | 1010 | ||
1084 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1011 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1085 | { | 1012 | { |
1086 | mXXPortManager->importVCard( vCard, showPreview ); | 1013 | mXXPortManager->importVCard( vCard, showPreview ); |
1087 | } | 1014 | } |
1088 | 1015 | ||
1089 | //US added a second method without defaultparameter | 1016 | //US added a second method without defaultparameter |
1090 | void KABCore::editContact2() { | 1017 | void KABCore::editContact2() { |
1091 | editContact( QString::null ); | 1018 | editContact( QString::null ); |
1092 | } | 1019 | } |
1093 | 1020 | ||
1094 | void KABCore::editContact( const QString &uid ) | 1021 | void KABCore::editContact( const QString &uid ) |
1095 | { | 1022 | { |
1096 | 1023 | ||
1097 | if ( mExtensionManager->isQuickEditVisible() ) | 1024 | if ( mExtensionManager->isQuickEditVisible() ) |
1098 | return; | 1025 | return; |
1099 | 1026 | ||
1100 | // First, locate the contact entry | 1027 | // First, locate the contact entry |
1101 | QString localUID = uid; | 1028 | QString localUID = uid; |
1102 | if ( localUID.isNull() ) { | 1029 | if ( localUID.isNull() ) { |
1103 | QStringList uidList = mViewManager->selectedUids(); | 1030 | QStringList uidList = mViewManager->selectedUids(); |
1104 | if ( uidList.count() > 0 ) | 1031 | if ( uidList.count() > 0 ) |
1105 | localUID = *( uidList.at( 0 ) ); | 1032 | localUID = *( uidList.at( 0 ) ); |
1106 | } | 1033 | } |
1107 | 1034 | ||
1108 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1035 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1109 | if ( !addr.isEmpty() ) { | 1036 | if ( !addr.isEmpty() ) { |
1110 | mEditorDialog->setAddressee( addr ); | 1037 | mEditorDialog->setAddressee( addr ); |
1111 | KApplication::execDialog ( mEditorDialog ); | 1038 | KApplication::execDialog ( mEditorDialog ); |
1112 | } | 1039 | } |
1113 | } | 1040 | } |
1114 | 1041 | ||
1115 | /** | 1042 | /** |
1116 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1043 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1117 | the method will try to find a selected addressee in the view. | 1044 | the method will try to find a selected addressee in the view. |
1118 | */ | 1045 | */ |
1119 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1046 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1120 | { | 1047 | { |
1121 | if ( mMultipleViewsAtOnce ) | 1048 | if ( mMultipleViewsAtOnce ) |
1122 | { | 1049 | { |
1123 | editContact( uid ); | 1050 | editContact( uid ); |
1124 | } | 1051 | } |
1125 | else | 1052 | else |
1126 | { | 1053 | { |
1127 | setDetailsVisible( true ); | 1054 | setDetailsVisible( true ); |
1128 | mActionDetails->setChecked(true); | 1055 | mActionDetails->setChecked(true); |
1129 | } | 1056 | } |
1130 | 1057 | ||
1131 | } | 1058 | } |
1132 | 1059 | ||
1133 | void KABCore::save() | 1060 | void KABCore::save() |
1134 | { | 1061 | { |
1135 | if ( !mModified ) | 1062 | if ( !mModified ) |
1136 | return; | 1063 | return; |
1137 | QString text = i18n( "There was an error while attempting to save\n the " | 1064 | QString text = i18n( "There was an error while attempting to save\n the " |
1138 | "address book. Please check that some \nother application is " | 1065 | "address book. Please check that some \nother application is " |
1139 | "not using it. " ); | 1066 | "not using it. " ); |
1140 | statusMessage(i18n("Saving addressbook ... ")); | 1067 | statusMessage(i18n("Saving addressbook ... ")); |
1141 | #ifndef KAB_EMBEDDED | 1068 | #ifndef KAB_EMBEDDED |
1142 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1069 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1143 | if ( !b || !b->save() ) { | 1070 | if ( !b || !b->save() ) { |
1144 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1071 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1145 | } | 1072 | } |
1146 | #else //KAB_EMBEDDED | 1073 | #else //KAB_EMBEDDED |
1147 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1074 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1148 | if ( !b || !b->save() ) { | 1075 | if ( !b || !b->save() ) { |
1149 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1076 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1150 | } | 1077 | } |
1151 | #endif //KAB_EMBEDDED | 1078 | #endif //KAB_EMBEDDED |
1152 | 1079 | ||
1153 | statusMessage(i18n("Addressbook saved!")); | 1080 | statusMessage(i18n("Addressbook saved!")); |
1154 | setModified( false ); | 1081 | setModified( false ); |
1155 | } | 1082 | } |
1156 | 1083 | ||
1157 | void KABCore::statusMessage(QString mess , int time ) | 1084 | void KABCore::statusMessage(QString mess , int time ) |
1158 | { | 1085 | { |
1159 | //topLevelWidget()->setCaption( mess ); | 1086 | //topLevelWidget()->setCaption( mess ); |
1160 | // pending setting timer to revome message | 1087 | // pending setting timer to revome message |
1161 | } | 1088 | } |
1162 | void KABCore::undo() | 1089 | void KABCore::undo() |
1163 | { | 1090 | { |
1164 | UndoStack::instance()->undo(); | 1091 | UndoStack::instance()->undo(); |
1165 | 1092 | ||
1166 | // Refresh the view | 1093 | // Refresh the view |
1167 | mViewManager->refreshView(); | 1094 | mViewManager->refreshView(); |
1168 | } | 1095 | } |
1169 | 1096 | ||
1170 | void KABCore::redo() | 1097 | void KABCore::redo() |
1171 | { | 1098 | { |
1172 | RedoStack::instance()->redo(); | 1099 | RedoStack::instance()->redo(); |
1173 | 1100 | ||
1174 | // Refresh the view | 1101 | // Refresh the view |
1175 | mViewManager->refreshView(); | 1102 | mViewManager->refreshView(); |
1176 | } | 1103 | } |
1177 | 1104 | ||
1178 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1105 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1179 | { | 1106 | { |
1180 | if (mMultipleViewsAtOnce) | 1107 | if (mMultipleViewsAtOnce) |
1181 | { | 1108 | { |
1182 | if ( visible ) | 1109 | if ( visible ) |
1183 | mJumpButtonBar->show(); | 1110 | mJumpButtonBar->show(); |
1184 | else | 1111 | else |
1185 | mJumpButtonBar->hide(); | 1112 | mJumpButtonBar->hide(); |
1186 | } | 1113 | } |
1187 | else | 1114 | else |
1188 | { | 1115 | { |
1189 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1116 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1190 | if (mViewManager->isVisible()) | 1117 | if (mViewManager->isVisible()) |
1191 | { | 1118 | { |
1192 | if ( visible ) | 1119 | if ( visible ) |
1193 | mJumpButtonBar->show(); | 1120 | mJumpButtonBar->show(); |
1194 | else | 1121 | else |
1195 | mJumpButtonBar->hide(); | 1122 | mJumpButtonBar->hide(); |
1196 | } | 1123 | } |
1197 | else | 1124 | else |
1198 | { | 1125 | { |
1199 | mJumpButtonBar->hide(); | 1126 | mJumpButtonBar->hide(); |
1200 | } | 1127 | } |
1201 | } | 1128 | } |
1202 | } | 1129 | } |
1203 | 1130 | ||
1204 | 1131 | ||
1205 | void KABCore::setDetailsToState() | 1132 | void KABCore::setDetailsToState() |
1206 | { | 1133 | { |
1207 | setDetailsVisible( mActionDetails->isChecked() ); | 1134 | setDetailsVisible( mActionDetails->isChecked() ); |
1208 | } | 1135 | } |
1209 | 1136 | ||
1210 | 1137 | ||
1211 | 1138 | ||
1212 | void KABCore::setDetailsVisible( bool visible ) | 1139 | void KABCore::setDetailsVisible( bool visible ) |
1213 | { | 1140 | { |
1214 | if (visible && mDetails->isHidden()) | 1141 | if (visible && mDetails->isHidden()) |
1215 | { | 1142 | { |
1216 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1143 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1217 | if ( addrList.count() > 0 ) | 1144 | if ( addrList.count() > 0 ) |
1218 | mDetails->setAddressee( addrList[ 0 ] ); | 1145 | mDetails->setAddressee( addrList[ 0 ] ); |
1219 | } | 1146 | } |
1220 | 1147 | ||
1221 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1148 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1222 | // the listview and the detailview. We do that by changing the splitbar size. | 1149 | // the listview and the detailview. We do that by changing the splitbar size. |
1223 | if (mMultipleViewsAtOnce) | 1150 | if (mMultipleViewsAtOnce) |
1224 | { | 1151 | { |
1225 | if ( visible ) | 1152 | if ( visible ) |
1226 | mDetails->show(); | 1153 | mDetails->show(); |
1227 | else | 1154 | else |
1228 | mDetails->hide(); | 1155 | mDetails->hide(); |
1229 | } | 1156 | } |
1230 | else | 1157 | else |
1231 | { | 1158 | { |
1232 | if ( visible ) { | 1159 | if ( visible ) { |
1233 | mViewManager->hide(); | 1160 | mViewManager->hide(); |
1234 | mDetails->show(); | 1161 | mDetails->show(); |
1235 | } | 1162 | } |
1236 | else { | 1163 | else { |
1237 | mViewManager->show(); | 1164 | mViewManager->show(); |
1238 | mDetails->hide(); | 1165 | mDetails->hide(); |
1239 | } | 1166 | } |
1240 | setJumpButtonBarVisible( !visible ); | 1167 | setJumpButtonBarVisible( !visible ); |
1241 | } | 1168 | } |
1242 | 1169 | ||
1243 | } | 1170 | } |
1244 | 1171 | ||
1245 | void KABCore::extensionChanged( int id ) | 1172 | void KABCore::extensionChanged( int id ) |
1246 | { | 1173 | { |
1247 | //change the details view only for non desktop systems | 1174 | //change the details view only for non desktop systems |
1248 | #ifndef DESKTOP_VERSION | 1175 | #ifndef DESKTOP_VERSION |
1249 | 1176 | ||
1250 | if (id == 0) | 1177 | if (id == 0) |
1251 | { | 1178 | { |
1252 | //the user disabled the extension. | 1179 | //the user disabled the extension. |
1253 | 1180 | ||
1254 | if (mMultipleViewsAtOnce) | 1181 | if (mMultipleViewsAtOnce) |
1255 | { // enable detailsview again | 1182 | { // enable detailsview again |
1256 | setDetailsVisible( true ); | 1183 | setDetailsVisible( true ); |
1257 | mActionDetails->setChecked( true ); | 1184 | mActionDetails->setChecked( true ); |
1258 | } | 1185 | } |
1259 | else | 1186 | else |
1260 | { //go back to the listview | 1187 | { //go back to the listview |
1261 | setDetailsVisible( false ); | 1188 | setDetailsVisible( false ); |
1262 | mActionDetails->setChecked( false ); | 1189 | mActionDetails->setChecked( false ); |
1263 | mActionDetails->setEnabled(true); | 1190 | mActionDetails->setEnabled(true); |
1264 | } | 1191 | } |
1265 | 1192 | ||
1266 | } | 1193 | } |
1267 | else | 1194 | else |
1268 | { | 1195 | { |
1269 | //the user enabled the extension. | 1196 | //the user enabled the extension. |
1270 | setDetailsVisible( false ); | 1197 | setDetailsVisible( false ); |
1271 | mActionDetails->setChecked( false ); | 1198 | mActionDetails->setChecked( false ); |
1272 | 1199 | ||
1273 | if (!mMultipleViewsAtOnce) | 1200 | if (!mMultipleViewsAtOnce) |
1274 | { | 1201 | { |
1275 | mActionDetails->setEnabled(false); | 1202 | mActionDetails->setEnabled(false); |
1276 | } | 1203 | } |
1277 | 1204 | ||
1278 | mExtensionManager->setSelectionChanged(); | 1205 | mExtensionManager->setSelectionChanged(); |
1279 | 1206 | ||
1280 | } | 1207 | } |
1281 | 1208 | ||
1282 | #endif// DESKTOP_VERSION | 1209 | #endif// DESKTOP_VERSION |
1283 | 1210 | ||
1284 | } | 1211 | } |
1285 | 1212 | ||
1286 | 1213 | ||
1287 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1214 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1288 | { | 1215 | { |
1289 | 1216 | ||
1290 | if ( list.count() != 0 ) { | 1217 | if ( list.count() != 0 ) { |
1291 | KABC::Addressee::List::ConstIterator it; | 1218 | KABC::Addressee::List::ConstIterator it; |
1292 | for ( it = list.begin(); it != list.end(); ++it ) | 1219 | for ( it = list.begin(); it != list.end(); ++it ) |
1293 | mAddressBook->insertAddressee( *it ); | 1220 | mAddressBook->insertAddressee( *it ); |
1294 | if ( list.count() > 1 ) | 1221 | if ( list.count() > 1 ) |
1295 | setModified(); | 1222 | setModified(); |
1296 | else | 1223 | else |
1297 | setModifiedWOrefresh(); | 1224 | setModifiedWOrefresh(); |
1298 | } | 1225 | } |
1299 | if ( list.count() == 0 ) | 1226 | if ( list.count() == 0 ) |
1300 | mViewManager->refreshView(); | 1227 | mViewManager->refreshView(); |
1301 | else | 1228 | else |
1302 | mViewManager->refreshView( list[ 0 ].uid() ); | 1229 | mViewManager->refreshView( list[ 0 ].uid() ); |
1303 | 1230 | ||
1304 | 1231 | ||
1305 | 1232 | ||
1306 | } | 1233 | } |
1307 | 1234 | ||
1308 | QString KABCore::getNameByPhone( const QString &phone ) | 1235 | QString KABCore::getNameByPhone( const QString &phone ) |
1309 | { | 1236 | { |
1310 | #ifndef KAB_EMBEDDED | 1237 | #ifndef KAB_EMBEDDED |
1311 | QRegExp r( "[/*/-/ ]" ); | 1238 | QRegExp r( "[/*/-/ ]" ); |
1312 | QString localPhone( phone ); | 1239 | QString localPhone( phone ); |
1313 | 1240 | ||
1314 | bool found = false; | 1241 | bool found = false; |
1315 | QString ownerName = ""; | 1242 | QString ownerName = ""; |
1316 | KABC::AddressBook::Iterator iter; | 1243 | KABC::AddressBook::Iterator iter; |
1317 | KABC::PhoneNumber::List::Iterator phoneIter; | 1244 | KABC::PhoneNumber::List::Iterator phoneIter; |
1318 | KABC::PhoneNumber::List phoneList; | 1245 | KABC::PhoneNumber::List phoneList; |
1319 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1246 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1320 | phoneList = (*iter).phoneNumbers(); | 1247 | phoneList = (*iter).phoneNumbers(); |
1321 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1248 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1322 | ++phoneIter) { | 1249 | ++phoneIter) { |
1323 | // Get rid of separator chars so just the numbers are compared. | 1250 | // Get rid of separator chars so just the numbers are compared. |
1324 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1251 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1325 | ownerName = (*iter).formattedName(); | 1252 | ownerName = (*iter).formattedName(); |
1326 | found = true; | 1253 | found = true; |
1327 | } | 1254 | } |
1328 | } | 1255 | } |
1329 | } | 1256 | } |
1330 | 1257 | ||
1331 | return ownerName; | 1258 | return ownerName; |
1332 | #else //KAB_EMBEDDED | 1259 | #else //KAB_EMBEDDED |
1333 | qDebug("KABCore::getNameByPhone finsih method"); | 1260 | qDebug("KABCore::getNameByPhone finsih method"); |
1334 | return ""; | 1261 | return ""; |
1335 | #endif //KAB_EMBEDDED | 1262 | #endif //KAB_EMBEDDED |
1336 | 1263 | ||
1337 | } | 1264 | } |
1338 | 1265 | ||
1339 | void KABCore::openConfigDialog() | 1266 | void KABCore::openConfigDialog() |
1340 | { | 1267 | { |
1341 | KABPrefs* kab_prefs = KABPrefs::instance(); | 1268 | KABPrefs* kab_prefs = KABPrefs::instance(); |
1342 | KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); | 1269 | KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); |
1343 | 1270 | ||
1344 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1271 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1345 | KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1272 | KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1346 | ConfigureDialog->addModule(kabcfg ); | 1273 | ConfigureDialog->addModule(kabcfg ); |
1347 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1274 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1348 | ConfigureDialog->addModule(kdelibcfg ); | 1275 | ConfigureDialog->addModule(kdelibcfg ); |
1349 | 1276 | ||
1350 | 1277 | ||
1351 | 1278 | ||
1352 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1279 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1353 | this, SLOT( configurationChanged() ) ); | 1280 | this, SLOT( configurationChanged() ) ); |
1354 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1281 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1355 | this, SLOT( configurationChanged() ) ); | 1282 | this, SLOT( configurationChanged() ) ); |
1356 | saveSettings(); | 1283 | saveSettings(); |
1357 | #ifndef DESKTOP_VERSION | 1284 | #ifndef DESKTOP_VERSION |
1358 | ConfigureDialog->showMaximized(); | 1285 | ConfigureDialog->showMaximized(); |
1359 | #endif | 1286 | #endif |
1360 | if ( ConfigureDialog->exec() ) | 1287 | if ( ConfigureDialog->exec() ) |
1361 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1288 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1362 | delete ConfigureDialog; | 1289 | delete ConfigureDialog; |
1363 | } | 1290 | } |
1364 | 1291 | ||
1365 | void KABCore::openLDAPDialog() | 1292 | void KABCore::openLDAPDialog() |
1366 | { | 1293 | { |
1367 | #ifndef KAB_EMBEDDED | 1294 | #ifndef KAB_EMBEDDED |
1368 | if ( !mLdapSearchDialog ) { | 1295 | if ( !mLdapSearchDialog ) { |
1369 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1296 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1370 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1297 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1371 | SLOT( refreshView() ) ); | 1298 | SLOT( refreshView() ) ); |
1372 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1299 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1373 | SLOT( setModified() ) ); | 1300 | SLOT( setModified() ) ); |
1374 | } else | 1301 | } else |
1375 | mLdapSearchDialog->restoreSettings(); | 1302 | mLdapSearchDialog->restoreSettings(); |
1376 | 1303 | ||
1377 | if ( mLdapSearchDialog->isOK() ) | 1304 | if ( mLdapSearchDialog->isOK() ) |
1378 | mLdapSearchDialog->exec(); | 1305 | mLdapSearchDialog->exec(); |
1379 | #else //KAB_EMBEDDED | 1306 | #else //KAB_EMBEDDED |
1380 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1307 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1381 | #endif //KAB_EMBEDDED | 1308 | #endif //KAB_EMBEDDED |
1382 | } | 1309 | } |
1383 | 1310 | ||
1384 | void KABCore::print() | 1311 | void KABCore::print() |
1385 | { | 1312 | { |
1386 | #ifndef KAB_EMBEDDED | 1313 | #ifndef KAB_EMBEDDED |
1387 | KPrinter printer; | 1314 | KPrinter printer; |
1388 | if ( !printer.setup( this ) ) | 1315 | if ( !printer.setup( this ) ) |
1389 | return; | 1316 | return; |
1390 | 1317 | ||
1391 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1318 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1392 | mViewManager->selectedUids(), this ); | 1319 | mViewManager->selectedUids(), this ); |
1393 | 1320 | ||
1394 | wizard.exec(); | 1321 | wizard.exec(); |
1395 | #else //KAB_EMBEDDED | 1322 | #else //KAB_EMBEDDED |
1396 | qDebug("KABCore::print() finsih method"); | 1323 | qDebug("KABCore::print() finsih method"); |
1397 | #endif //KAB_EMBEDDED | 1324 | #endif //KAB_EMBEDDED |
1398 | 1325 | ||
1399 | } | 1326 | } |
1400 | 1327 | ||
1401 | 1328 | ||
1402 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1329 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1403 | { | 1330 | { |
1404 | if ( mGUIClient ) | 1331 | if ( mGUIClient ) |
1405 | mGUIClient->insertChildClient( client ); | 1332 | mGUIClient->insertChildClient( client ); |
1406 | else | 1333 | else |
1407 | KMessageBox::error( this, "no KXMLGUICLient"); | 1334 | KMessageBox::error( this, "no KXMLGUICLient"); |
1408 | } | 1335 | } |
1409 | 1336 | ||
1410 | 1337 | ||
1411 | void KABCore::configurationChanged() | 1338 | void KABCore::configurationChanged() |
1412 | { | 1339 | { |
1413 | mExtensionManager->reconfigure(); | 1340 | mExtensionManager->reconfigure(); |
1414 | } | 1341 | } |
1415 | 1342 | ||
1416 | void KABCore::addressBookChanged() | 1343 | void KABCore::addressBookChanged() |
1417 | { | 1344 | { |
1418 | /*US | 1345 | /*US |
1419 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1346 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1420 | while ( it.current() ) { | 1347 | while ( it.current() ) { |
1421 | if ( it.current()->dirty() ) { | 1348 | if ( it.current()->dirty() ) { |
1422 | QString text = i18n( "Data has been changed externally. Unsaved " | 1349 | QString text = i18n( "Data has been changed externally. Unsaved " |
1423 | "changes will be lost." ); | 1350 | "changes will be lost." ); |
1424 | KMessageBox::information( this, text ); | 1351 | KMessageBox::information( this, text ); |
1425 | } | 1352 | } |
1426 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1353 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1427 | ++it; | 1354 | ++it; |
1428 | } | 1355 | } |
1429 | */ | 1356 | */ |
1430 | if (mEditorDialog) | 1357 | if (mEditorDialog) |
1431 | { | 1358 | { |
1432 | if (mEditorDialog->dirty()) | 1359 | if (mEditorDialog->dirty()) |
1433 | { | 1360 | { |
1434 | QString text = i18n( "Data has been changed externally. Unsaved " | 1361 | QString text = i18n( "Data has been changed externally. Unsaved " |
1435 | "changes will be lost." ); | 1362 | "changes will be lost." ); |
1436 | KMessageBox::information( this, text ); | 1363 | KMessageBox::information( this, text ); |
1437 | } | 1364 | } |
1438 | QString currentuid = mEditorDialog->addressee().uid(); | 1365 | QString currentuid = mEditorDialog->addressee().uid(); |
1439 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1366 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1440 | } | 1367 | } |
1441 | mViewManager->refreshView(); | 1368 | mViewManager->refreshView(); |
1442 | // mDetails->refreshView(); | 1369 | // mDetails->refreshView(); |
1443 | 1370 | ||
1444 | 1371 | ||
1445 | } | 1372 | } |
1446 | 1373 | ||
1447 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1374 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1448 | const char *name ) | 1375 | const char *name ) |
1449 | { | 1376 | { |
1450 | 1377 | ||
1451 | if ( mEditorDialog == 0 ) { | 1378 | if ( mEditorDialog == 0 ) { |
1452 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1379 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1453 | name ? name : "editorDialog" ); | 1380 | name ? name : "editorDialog" ); |
1454 | 1381 | ||
1455 | 1382 | ||
1456 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1383 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1457 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1384 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1458 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1385 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1459 | // SLOT( slotEditorDestroyed( const QString& ) ) ); | 1386 | // SLOT( slotEditorDestroyed( const QString& ) ) ); |
1460 | } | 1387 | } |
1461 | 1388 | ||
1462 | return mEditorDialog; | 1389 | return mEditorDialog; |
1463 | } | 1390 | } |
1464 | 1391 | ||
1465 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1392 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1466 | { | 1393 | { |
1467 | //mEditorDict.remove( uid ); | 1394 | //mEditorDict.remove( uid ); |
1468 | } | 1395 | } |
1469 | 1396 | ||
1470 | void KABCore::initGUI() | 1397 | void KABCore::initGUI() |
1471 | { | 1398 | { |
1472 | #ifndef KAB_EMBEDDED | 1399 | #ifndef KAB_EMBEDDED |
1473 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1400 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1474 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1401 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1475 | 1402 | ||
1476 | mExtensionBarSplitter = new QSplitter( this ); | 1403 | mExtensionBarSplitter = new QSplitter( this ); |
1477 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1404 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1478 | 1405 | ||
1479 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1406 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1480 | 1407 | ||
1481 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1408 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1482 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1409 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1483 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1410 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1484 | SLOT( incrementalSearch( const QString& ) ) ); | 1411 | SLOT( incrementalSearch( const QString& ) ) ); |
1485 | 1412 | ||
1486 | mViewManager = new ViewManager( this, viewSpace ); | 1413 | mViewManager = new ViewManager( this, viewSpace ); |
1487 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1414 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1488 | 1415 | ||
1489 | mDetails = new ViewContainer( mDetailsSplitter ); | 1416 | mDetails = new ViewContainer( mDetailsSplitter ); |
1490 | 1417 | ||
1491 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1418 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1492 | 1419 | ||
1493 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1420 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1494 | 1421 | ||
1495 | topLayout->addWidget( mExtensionBarSplitter ); | 1422 | topLayout->addWidget( mExtensionBarSplitter ); |
1496 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1423 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1497 | topLayout->addWidget( mJumpButtonBar ); | 1424 | topLayout->addWidget( mJumpButtonBar ); |
1498 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1425 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1499 | 1426 | ||
1500 | mXXPortManager = new XXPortManager( this, this ); | 1427 | mXXPortManager = new XXPortManager( this, this ); |
1501 | 1428 | ||
1502 | #else //KAB_EMBEDDED | 1429 | #else //KAB_EMBEDDED |
1503 | //US initialize viewMenu before settingup viewmanager. | 1430 | //US initialize viewMenu before settingup viewmanager. |
1504 | // Viewmanager needs this menu to plugin submenues. | 1431 | // Viewmanager needs this menu to plugin submenues. |
1505 | viewMenu = new QPopupMenu( this ); | 1432 | viewMenu = new QPopupMenu( this ); |
1506 | settingsMenu = new QPopupMenu( this ); | 1433 | settingsMenu = new QPopupMenu( this ); |
1507 | //filterMenu = new QPopupMenu( this ); | 1434 | //filterMenu = new QPopupMenu( this ); |
1508 | ImportMenu = new QPopupMenu( this ); | 1435 | ImportMenu = new QPopupMenu( this ); |
1509 | ExportMenu = new QPopupMenu( this ); | 1436 | ExportMenu = new QPopupMenu( this ); |
1510 | 1437 | ||
1511 | changeMenu= new QPopupMenu( this ); | 1438 | changeMenu= new QPopupMenu( this ); |
1512 | 1439 | ||
1513 | //US since we have no splitter for the embedded system, setup | 1440 | //US since we have no splitter for the embedded system, setup |
1514 | // a layout with two frames. One left and one right. | 1441 | // a layout with two frames. One left and one right. |
1515 | 1442 | ||
1516 | QBoxLayout *topLayout; | 1443 | QBoxLayout *topLayout; |
1517 | 1444 | ||
1518 | // = new QHBoxLayout( this ); | 1445 | // = new QHBoxLayout( this ); |
1519 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1446 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1520 | 1447 | ||
1521 | // QWidget *mainBox = new QWidget( this ); | 1448 | // QWidget *mainBox = new QWidget( this ); |
1522 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1449 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1523 | 1450 | ||
1524 | #ifdef DESKTOP_VERSION | 1451 | #ifdef DESKTOP_VERSION |
1525 | topLayout = new QHBoxLayout( this ); | 1452 | topLayout = new QHBoxLayout( this ); |
1526 | 1453 | ||
1527 | 1454 | ||
1528 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1455 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1529 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1456 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1530 | 1457 | ||
1531 | topLayout->addWidget(mMiniSplitter ); | 1458 | topLayout->addWidget(mMiniSplitter ); |
1532 | 1459 | ||
1533 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1460 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1534 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1461 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1535 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1462 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1536 | mDetails = new ViewContainer( mMiniSplitter ); | 1463 | mDetails = new ViewContainer( mMiniSplitter ); |
1537 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1464 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1538 | #else | 1465 | #else |
1539 | if ( QApplication::desktop()->width() > 480 ) { | 1466 | if ( QApplication::desktop()->width() > 480 ) { |
1540 | topLayout = new QHBoxLayout( this ); | 1467 | topLayout = new QHBoxLayout( this ); |
1541 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1468 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1542 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1469 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1543 | } else { | 1470 | } else { |
1544 | 1471 | ||
1545 | topLayout = new QHBoxLayout( this ); | 1472 | topLayout = new QHBoxLayout( this ); |
1546 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1473 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1547 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1474 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1548 | } | 1475 | } |
1549 | 1476 | ||
1550 | topLayout->addWidget(mMiniSplitter ); | 1477 | topLayout->addWidget(mMiniSplitter ); |
1551 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1478 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1552 | mDetails = new ViewContainer( mMiniSplitter ); | 1479 | mDetails = new ViewContainer( mMiniSplitter ); |
1553 | 1480 | ||
1554 | 1481 | ||
1555 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1482 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1556 | #endif | 1483 | #endif |
1557 | //eh->hide(); | 1484 | //eh->hide(); |
1558 | // topLayout->addWidget(mExtensionManager ); | 1485 | // topLayout->addWidget(mExtensionManager ); |
1559 | 1486 | ||
1560 | 1487 | ||
1561 | /*US | 1488 | /*US |
1562 | #ifndef KAB_NOSPLITTER | 1489 | #ifndef KAB_NOSPLITTER |
1563 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1490 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1564 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1491 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1565 | topLayout->setSpacing( 10 ); | 1492 | topLayout->setSpacing( 10 ); |
1566 | 1493 | ||
1567 | mDetailsSplitter = new QSplitter( this ); | 1494 | mDetailsSplitter = new QSplitter( this ); |
1568 | 1495 | ||
1569 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1496 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1570 | 1497 | ||
1571 | mViewManager = new ViewManager( this, viewSpace ); | 1498 | mViewManager = new ViewManager( this, viewSpace ); |
1572 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1499 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1573 | 1500 | ||
1574 | mDetails = new ViewContainer( mDetailsSplitter ); | 1501 | mDetails = new ViewContainer( mDetailsSplitter ); |
1575 | 1502 | ||
1576 | topLayout->addWidget( mDetailsSplitter ); | 1503 | topLayout->addWidget( mDetailsSplitter ); |
1577 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1504 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1578 | #else //KAB_NOSPLITTER | 1505 | #else //KAB_NOSPLITTER |
1579 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1506 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1580 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1507 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1581 | topLayout->setSpacing( 10 ); | 1508 | topLayout->setSpacing( 10 ); |
1582 | 1509 | ||
1583 | // mDetailsSplitter = new QSplitter( this ); | 1510 | // mDetailsSplitter = new QSplitter( this ); |
1584 | 1511 | ||
1585 | QVBox *viewSpace = new QVBox( this ); | 1512 | QVBox *viewSpace = new QVBox( this ); |
1586 | 1513 | ||
1587 | mViewManager = new ViewManager( this, viewSpace ); | 1514 | mViewManager = new ViewManager( this, viewSpace ); |
1588 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1515 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1589 | 1516 | ||
1590 | mDetails = new ViewContainer( this ); | 1517 | mDetails = new ViewContainer( this ); |
1591 | 1518 | ||
1592 | topLayout->addWidget( viewSpace ); | 1519 | topLayout->addWidget( viewSpace ); |
1593 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1520 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1594 | topLayout->addWidget( mDetails ); | 1521 | topLayout->addWidget( mDetails ); |
1595 | #endif //KAB_NOSPLITTER | 1522 | #endif //KAB_NOSPLITTER |
1596 | */ | 1523 | */ |
1597 | 1524 | ||
1598 | 1525 | ||
1599 | #endif //KAB_EMBEDDED | 1526 | #endif //KAB_EMBEDDED |
1600 | initActions(); | 1527 | initActions(); |
1601 | 1528 | ||
1602 | #ifdef KAB_EMBEDDED | 1529 | #ifdef KAB_EMBEDDED |
1603 | addActionsManually(); | 1530 | addActionsManually(); |
1604 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1531 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1605 | mXXPortManager = new XXPortManager( this, this ); | 1532 | mXXPortManager = new XXPortManager( this, this ); |
1606 | 1533 | ||
1607 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1534 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1608 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1535 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1609 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1536 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1610 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1537 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1611 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1538 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1612 | // mIncSearchWidget->hide(); | 1539 | // mIncSearchWidget->hide(); |
1613 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1540 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1614 | SLOT( incrementalSearch( const QString& ) ) ); | 1541 | SLOT( incrementalSearch( const QString& ) ) ); |
1615 | 1542 | ||
1616 | 1543 | ||
1617 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1544 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1618 | 1545 | ||
1619 | topLayout->addWidget( mJumpButtonBar ); | 1546 | topLayout->addWidget( mJumpButtonBar ); |
1620 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1547 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1621 | 1548 | ||
1622 | // mMainWindow->getIconToolBar()->raise(); | 1549 | // mMainWindow->getIconToolBar()->raise(); |
1623 | 1550 | ||
1624 | #endif //KAB_EMBEDDED | 1551 | #endif //KAB_EMBEDDED |
1625 | 1552 | ||
1626 | } | 1553 | } |
1627 | void KABCore::initActions() | 1554 | void KABCore::initActions() |
1628 | { | 1555 | { |
1629 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1556 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1630 | 1557 | ||
1631 | #ifndef KAB_EMBEDDED | 1558 | #ifndef KAB_EMBEDDED |
1632 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1559 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1633 | SLOT( clipboardDataChanged() ) ); | 1560 | SLOT( clipboardDataChanged() ) ); |
1634 | #endif //KAB_EMBEDDED | 1561 | #endif //KAB_EMBEDDED |
1635 | 1562 | ||
1636 | // file menu | 1563 | // file menu |
1637 | if ( mIsPart ) { | 1564 | if ( mIsPart ) { |
1638 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1565 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1639 | SLOT( sendMail() ), actionCollection(), | 1566 | SLOT( sendMail() ), actionCollection(), |
1640 | "kaddressbook_mail" ); | 1567 | "kaddressbook_mail" ); |
1641 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1568 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1642 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1569 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1643 | 1570 | ||
1644 | } else { | 1571 | } else { |
1645 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1572 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1646 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1573 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1647 | } | 1574 | } |
1648 | 1575 | ||
1649 | 1576 | ||
1650 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1577 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1651 | SLOT( save() ), actionCollection(), "file_sync" ); | 1578 | SLOT( save() ), actionCollection(), "file_sync" ); |
1652 | 1579 | ||
1653 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1580 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1654 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1581 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1655 | 1582 | ||
1656 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1583 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1657 | this, SLOT( mailVCard() ), | 1584 | this, SLOT( mailVCard() ), |
1658 | actionCollection(), "file_mail_vcard"); | 1585 | actionCollection(), "file_mail_vcard"); |
1659 | 1586 | ||
1660 | mActionBeamVCard = 0; | 1587 | mActionBeamVCard = 0; |
1661 | mActionBeam = 0; | 1588 | mActionBeam = 0; |
1662 | 1589 | ||
1663 | #ifndef DESKTOP_VERSION | 1590 | #ifndef DESKTOP_VERSION |
1664 | if ( Ir::supported() ) { | 1591 | if ( Ir::supported() ) { |
1665 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1592 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1666 | SLOT( beamVCard() ), actionCollection(), | 1593 | SLOT( beamVCard() ), actionCollection(), |
1667 | "kaddressbook_beam_vcard" ); | 1594 | "kaddressbook_beam_vcard" ); |
1668 | 1595 | ||
1669 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1596 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1670 | SLOT( beamMySelf() ), actionCollection(), | 1597 | SLOT( beamMySelf() ), actionCollection(), |
1671 | "kaddressbook_beam_myself" ); | 1598 | "kaddressbook_beam_myself" ); |
1672 | } | 1599 | } |
1673 | #endif | 1600 | #endif |
1674 | 1601 | ||
1675 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1602 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1676 | this, SLOT( editContact2() ), | 1603 | this, SLOT( editContact2() ), |
1677 | actionCollection(), "file_properties" ); | 1604 | actionCollection(), "file_properties" ); |
1678 | 1605 | ||
1679 | #ifdef KAB_EMBEDDED | 1606 | #ifdef KAB_EMBEDDED |
1680 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1607 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1681 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1608 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1682 | mMainWindow, SLOT( exit() ), | 1609 | mMainWindow, SLOT( exit() ), |
1683 | actionCollection(), "quit" ); | 1610 | actionCollection(), "quit" ); |
1684 | #endif //KAB_EMBEDDED | 1611 | #endif //KAB_EMBEDDED |
1685 | 1612 | ||
1686 | // edit menu | 1613 | // edit menu |
1687 | if ( mIsPart ) { | 1614 | if ( mIsPart ) { |
1688 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1615 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1689 | SLOT( copyContacts() ), actionCollection(), | 1616 | SLOT( copyContacts() ), actionCollection(), |
1690 | "kaddressbook_copy" ); | 1617 | "kaddressbook_copy" ); |
1691 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1618 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1692 | SLOT( cutContacts() ), actionCollection(), | 1619 | SLOT( cutContacts() ), actionCollection(), |
1693 | "kaddressbook_cut" ); | 1620 | "kaddressbook_cut" ); |
1694 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1621 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1695 | SLOT( pasteContacts() ), actionCollection(), | 1622 | SLOT( pasteContacts() ), actionCollection(), |
1696 | "kaddressbook_paste" ); | 1623 | "kaddressbook_paste" ); |
1697 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1624 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1698 | SLOT( selectAllContacts() ), actionCollection(), | 1625 | SLOT( selectAllContacts() ), actionCollection(), |
1699 | "kaddressbook_select_all" ); | 1626 | "kaddressbook_select_all" ); |
1700 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1627 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1701 | SLOT( undo() ), actionCollection(), | 1628 | SLOT( undo() ), actionCollection(), |
1702 | "kaddressbook_undo" ); | 1629 | "kaddressbook_undo" ); |
1703 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1630 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1704 | this, SLOT( redo() ), actionCollection(), | 1631 | this, SLOT( redo() ), actionCollection(), |
1705 | "kaddressbook_redo" ); | 1632 | "kaddressbook_redo" ); |
1706 | } else { | 1633 | } else { |
1707 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1634 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1708 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1635 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1709 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1636 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1710 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1637 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1711 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1638 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1712 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1639 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1713 | } | 1640 | } |
1714 | 1641 | ||
1715 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1642 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1716 | Key_Delete, this, SLOT( deleteContacts() ), | 1643 | Key_Delete, this, SLOT( deleteContacts() ), |
1717 | actionCollection(), "edit_delete" ); | 1644 | actionCollection(), "edit_delete" ); |
1718 | 1645 | ||
1719 | mActionUndo->setEnabled( false ); | 1646 | mActionUndo->setEnabled( false ); |
1720 | mActionRedo->setEnabled( false ); | 1647 | mActionRedo->setEnabled( false ); |
1721 | 1648 | ||
1722 | // settings menu | 1649 | // settings menu |
1723 | #ifdef KAB_EMBEDDED | 1650 | #ifdef KAB_EMBEDDED |
1724 | //US special menuentry to configure the addressbook resources. On KDE | 1651 | //US special menuentry to configure the addressbook resources. On KDE |
1725 | // you do that through the control center !!! | 1652 | // you do that through the control center !!! |
1726 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1653 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1727 | SLOT( configureResources() ), actionCollection(), | 1654 | SLOT( configureResources() ), actionCollection(), |
1728 | "kaddressbook_configure_resources" ); | 1655 | "kaddressbook_configure_resources" ); |
1729 | #endif //KAB_EMBEDDED | 1656 | #endif //KAB_EMBEDDED |
1730 | 1657 | ||
1731 | if ( mIsPart ) { | 1658 | if ( mIsPart ) { |
1732 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1659 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1733 | SLOT( openConfigDialog() ), actionCollection(), | 1660 | SLOT( openConfigDialog() ), actionCollection(), |
1734 | "kaddressbook_configure" ); | 1661 | "kaddressbook_configure" ); |
1735 | 1662 | ||
1736 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1663 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1737 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1664 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1738 | "kaddressbook_configure_shortcuts" ); | 1665 | "kaddressbook_configure_shortcuts" ); |
1739 | #ifdef KAB_EMBEDDED | 1666 | #ifdef KAB_EMBEDDED |
1740 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1667 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1741 | mActionConfigureToolbars->setEnabled( false ); | 1668 | mActionConfigureToolbars->setEnabled( false ); |
1742 | #endif //KAB_EMBEDDED | 1669 | #endif //KAB_EMBEDDED |
1743 | 1670 | ||
1744 | } else { | 1671 | } else { |
1745 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1672 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1746 | 1673 | ||
1747 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1674 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1748 | } | 1675 | } |
1749 | 1676 | ||
1750 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1677 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1751 | actionCollection(), "options_show_jump_bar" ); | 1678 | actionCollection(), "options_show_jump_bar" ); |
1752 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1679 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1753 | 1680 | ||
1754 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1681 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1755 | actionCollection(), "options_show_details" ); | 1682 | actionCollection(), "options_show_details" ); |
1756 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1683 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1757 | 1684 | ||
1758 | // misc | 1685 | // misc |
1759 | // only enable LDAP lookup if we can handle the protocol | 1686 | // only enable LDAP lookup if we can handle the protocol |
1760 | #ifndef KAB_EMBEDDED | 1687 | #ifndef KAB_EMBEDDED |
1761 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1688 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1762 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1689 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1763 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1690 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1764 | "ldap_lookup" ); | 1691 | "ldap_lookup" ); |
1765 | } | 1692 | } |
1766 | #else //KAB_EMBEDDED | 1693 | #else //KAB_EMBEDDED |
1767 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1694 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1768 | #endif //KAB_EMBEDDED | 1695 | #endif //KAB_EMBEDDED |
1769 | 1696 | ||
1770 | 1697 | ||
1771 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1698 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1772 | SLOT( setWhoAmI() ), actionCollection(), | 1699 | SLOT( setWhoAmI() ), actionCollection(), |
1773 | "set_personal" ); | 1700 | "set_personal" ); |
1774 | 1701 | ||
1775 | 1702 | ||
1776 | 1703 | ||
1777 | 1704 | ||
1778 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1705 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1779 | SLOT( setCategories() ), actionCollection(), | 1706 | SLOT( setCategories() ), actionCollection(), |
1780 | "edit_set_categories" ); | 1707 | "edit_set_categories" ); |
1781 | 1708 | ||
1782 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1709 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1783 | SLOT( removeVoice() ), actionCollection(), | 1710 | SLOT( removeVoice() ), actionCollection(), |
1784 | "remove_voice" ); | 1711 | "remove_voice" ); |
1785 | mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, | 1712 | mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, |
1786 | SLOT( importFromOL() ), actionCollection(), | 1713 | SLOT( importFromOL() ), actionCollection(), |
1787 | "import_OL" ); | 1714 | "import_OL" ); |
1788 | #ifdef KAB_EMBEDDED | 1715 | #ifdef KAB_EMBEDDED |
1789 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1716 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1790 | this, SLOT( showLicence() ), actionCollection(), | 1717 | this, SLOT( showLicence() ), actionCollection(), |
1791 | "licence_about_data" ); | 1718 | "licence_about_data" ); |
1792 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1719 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1793 | this, SLOT( faq() ), actionCollection(), | 1720 | this, SLOT( faq() ), actionCollection(), |
1794 | "faq_about_data" ); | 1721 | "faq_about_data" ); |
1795 | 1722 | ||
1796 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1723 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1797 | this, SLOT( createAboutData() ), actionCollection(), | 1724 | this, SLOT( createAboutData() ), actionCollection(), |
1798 | "kaddressbook_about_data" ); | 1725 | "kaddressbook_about_data" ); |
1799 | #endif //KAB_EMBEDDED | 1726 | #endif //KAB_EMBEDDED |
1800 | 1727 | ||
1801 | clipboardDataChanged(); | 1728 | clipboardDataChanged(); |
1802 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1729 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1803 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1730 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1804 | } | 1731 | } |
1805 | 1732 | ||
1806 | //US we need this function, to plug all actions into the correct menues. | 1733 | //US we need this function, to plug all actions into the correct menues. |
1807 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1734 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1808 | void KABCore::addActionsManually() | 1735 | void KABCore::addActionsManually() |
1809 | { | 1736 | { |
1810 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1737 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1811 | 1738 | ||
1812 | #ifdef KAB_EMBEDDED | 1739 | #ifdef KAB_EMBEDDED |
1813 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1740 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1814 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1741 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1815 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1742 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1816 | 1743 | ||
1817 | KToolBar* tb = mMainWindow->toolBar(); | 1744 | KToolBar* tb = mMainWindow->toolBar(); |
1818 | 1745 | ||
1819 | #ifdef DESKTOP_VERSION | 1746 | #ifdef DESKTOP_VERSION |
1820 | QMenuBar* mb = mMainWindow->menuBar(); | 1747 | QMenuBar* mb = mMainWindow->menuBar(); |
1821 | 1748 | ||
1822 | //US setup menubar. | 1749 | //US setup menubar. |
1823 | //Disable the following block if you do not want to have a menubar. | 1750 | //Disable the following block if you do not want to have a menubar. |
1824 | mb->insertItem( "&File", fileMenu ); | 1751 | mb->insertItem( "&File", fileMenu ); |
1825 | mb->insertItem( "&Edit", editMenu ); | 1752 | mb->insertItem( "&Edit", editMenu ); |
1826 | mb->insertItem( "&View", viewMenu ); | 1753 | mb->insertItem( "&View", viewMenu ); |
1827 | mb->insertItem( "&Settings", settingsMenu ); | 1754 | mb->insertItem( "&Settings", settingsMenu ); |
1828 | mb->insertItem( "&Change selected", changeMenu ); | 1755 | mb->insertItem( "&Change selected", changeMenu ); |
1829 | mb->insertItem( "&Help", helpMenu ); | 1756 | mb->insertItem( "&Help", helpMenu ); |
1830 | mIncSearchWidget = new IncSearchWidget( tb ); | 1757 | mIncSearchWidget = new IncSearchWidget( tb ); |
1831 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1758 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1832 | 1759 | ||
1833 | #else | 1760 | #else |
1834 | //US setup toolbar | 1761 | //US setup toolbar |
1835 | QMenuBar *menuBarTB = new QMenuBar( tb ); | 1762 | QMenuBar *menuBarTB = new QMenuBar( tb ); |
1836 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1763 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1837 | menuBarTB->insertItem( "ME", popupBarTB); | 1764 | menuBarTB->insertItem( "ME", popupBarTB); |
1838 | tb->insertWidget(-1, 0, menuBarTB); | 1765 | tb->insertWidget(-1, 0, menuBarTB); |
1839 | mIncSearchWidget = new IncSearchWidget( tb ); | 1766 | mIncSearchWidget = new IncSearchWidget( tb ); |
1840 | 1767 | ||
1841 | tb->enableMoving(false); | 1768 | tb->enableMoving(false); |
1842 | popupBarTB->insertItem( "&File", fileMenu ); | 1769 | popupBarTB->insertItem( "&File", fileMenu ); |
1843 | popupBarTB->insertItem( "&Edit", editMenu ); | 1770 | popupBarTB->insertItem( "&Edit", editMenu ); |
1844 | popupBarTB->insertItem( "&View", viewMenu ); | 1771 | popupBarTB->insertItem( "&View", viewMenu ); |
1845 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1772 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1846 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1773 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1847 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1774 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1848 | popupBarTB->insertItem( "&Help", helpMenu ); | 1775 | popupBarTB->insertItem( "&Help", helpMenu ); |
1849 | if (QApplication::desktop()->width() > 320 ) { | 1776 | if (QApplication::desktop()->width() > 320 ) { |
1850 | // mViewManager->getFilterAction()->plug ( tb); | 1777 | // mViewManager->getFilterAction()->plug ( tb); |
1851 | } | 1778 | } |
1852 | #endif | 1779 | #endif |
1853 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1780 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1854 | 1781 | ||
1855 | 1782 | ||
1856 | 1783 | ||
1857 | //US Now connect the actions with the menue entries. | 1784 | //US Now connect the actions with the menue entries. |
1858 | mActionPrint->plug( fileMenu ); | 1785 | mActionPrint->plug( fileMenu ); |
1859 | mActionMail->plug( fileMenu ); | 1786 | mActionMail->plug( fileMenu ); |
1860 | fileMenu->insertSeparator(); | 1787 | fileMenu->insertSeparator(); |
1861 | 1788 | ||
1862 | mActionNewContact->plug( fileMenu ); | 1789 | mActionNewContact->plug( fileMenu ); |
1863 | mActionNewContact->plug( tb ); | 1790 | mActionNewContact->plug( tb ); |
1864 | 1791 | ||
1865 | mActionEditAddressee->plug( fileMenu ); | 1792 | mActionEditAddressee->plug( fileMenu ); |
1866 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1793 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1867 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1794 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1868 | mActionEditAddressee->plug( tb ); | 1795 | mActionEditAddressee->plug( tb ); |
1869 | 1796 | ||
1870 | fileMenu->insertSeparator(); | 1797 | fileMenu->insertSeparator(); |
1871 | mActionSave->plug( fileMenu ); | 1798 | mActionSave->plug( fileMenu ); |
1872 | fileMenu->insertItem( "&Import", ImportMenu ); | 1799 | fileMenu->insertItem( "&Import", ImportMenu ); |
1873 | fileMenu->insertItem( "&Emport", ExportMenu ); | 1800 | fileMenu->insertItem( "&Emport", ExportMenu ); |
1874 | fileMenu->insertSeparator(); | 1801 | fileMenu->insertSeparator(); |
1875 | mActionMailVCard->plug( fileMenu ); | 1802 | mActionMailVCard->plug( fileMenu ); |
1876 | #ifndef DESKTOP_VERSION | 1803 | #ifndef DESKTOP_VERSION |
1877 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1804 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1878 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1805 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1879 | #endif | 1806 | #endif |
1880 | fileMenu->insertSeparator(); | 1807 | fileMenu->insertSeparator(); |
1881 | mActionQuit->plug( fileMenu ); | 1808 | mActionQuit->plug( fileMenu ); |
1882 | #ifdef _WIN32_ | 1809 | #ifdef _WIN32_ |
1883 | mActionImportOL->plug( ImportMenu ); | 1810 | mActionImportOL->plug( ImportMenu ); |
1884 | #endif | 1811 | #endif |
1885 | // edit menu | 1812 | // edit menu |
1886 | mActionUndo->plug( editMenu ); | 1813 | mActionUndo->plug( editMenu ); |
1887 | mActionRedo->plug( editMenu ); | 1814 | mActionRedo->plug( editMenu ); |
1888 | editMenu->insertSeparator(); | 1815 | editMenu->insertSeparator(); |
1889 | mActionCut->plug( editMenu ); | 1816 | mActionCut->plug( editMenu ); |
1890 | mActionCopy->plug( editMenu ); | 1817 | mActionCopy->plug( editMenu ); |
1891 | mActionPaste->plug( editMenu ); | 1818 | mActionPaste->plug( editMenu ); |
1892 | mActionDelete->plug( editMenu ); | 1819 | mActionDelete->plug( editMenu ); |
1893 | editMenu->insertSeparator(); | 1820 | editMenu->insertSeparator(); |
1894 | mActionSelectAll->plug( editMenu ); | 1821 | mActionSelectAll->plug( editMenu ); |
1895 | 1822 | ||
1896 | mActionRemoveVoice->plug( changeMenu ); | 1823 | mActionRemoveVoice->plug( changeMenu ); |
1897 | // settings menu | 1824 | // settings menu |
1898 | //US special menuentry to configure the addressbook resources. On KDE | 1825 | //US special menuentry to configure the addressbook resources. On KDE |
1899 | // you do that through the control center !!! | 1826 | // you do that through the control center !!! |
1900 | mActionConfigResources->plug( settingsMenu ); | 1827 | mActionConfigResources->plug( settingsMenu ); |
1901 | settingsMenu->insertSeparator(); | 1828 | settingsMenu->insertSeparator(); |
1902 | 1829 | ||
1903 | mActionConfigKAddressbook->plug( settingsMenu ); | 1830 | mActionConfigKAddressbook->plug( settingsMenu ); |
1904 | 1831 | ||
1905 | if ( mIsPart ) { | 1832 | if ( mIsPart ) { |
1906 | mActionConfigShortcuts->plug( settingsMenu ); | 1833 | mActionConfigShortcuts->plug( settingsMenu ); |
1907 | mActionConfigureToolbars->plug( settingsMenu ); | 1834 | mActionConfigureToolbars->plug( settingsMenu ); |
1908 | 1835 | ||
1909 | } else { | 1836 | } else { |
1910 | mActionKeyBindings->plug( settingsMenu ); | 1837 | mActionKeyBindings->plug( settingsMenu ); |
1911 | } | 1838 | } |
1912 | 1839 | ||
1913 | settingsMenu->insertSeparator(); | 1840 | settingsMenu->insertSeparator(); |
1914 | 1841 | ||
1915 | mActionJumpBar->plug( settingsMenu ); | 1842 | mActionJumpBar->plug( settingsMenu ); |
1916 | mActionDetails->plug( settingsMenu ); | 1843 | mActionDetails->plug( settingsMenu ); |
1917 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 1844 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
1918 | mActionDetails->plug( tb ); | 1845 | mActionDetails->plug( tb ); |
1919 | settingsMenu->insertSeparator(); | 1846 | settingsMenu->insertSeparator(); |
1920 | 1847 | ||
1921 | mActionWhoAmI->plug( settingsMenu ); | 1848 | mActionWhoAmI->plug( settingsMenu ); |
1922 | mActionCategories->plug( settingsMenu ); | 1849 | mActionCategories->plug( settingsMenu ); |
1923 | 1850 | ||
1924 | mActionLicence->plug( helpMenu ); | 1851 | mActionLicence->plug( helpMenu ); |
1925 | mActionFaq->plug( helpMenu ); | 1852 | mActionFaq->plug( helpMenu ); |
1926 | mActionAboutKAddressbook->plug( helpMenu ); | 1853 | mActionAboutKAddressbook->plug( helpMenu ); |
1927 | 1854 | ||
1928 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 1855 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
1929 | 1856 | ||
1930 | mActionSave->plug( tb ); | 1857 | mActionSave->plug( tb ); |
1931 | mViewManager->getFilterAction()->plug ( tb); | 1858 | mViewManager->getFilterAction()->plug ( tb); |
1932 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 1859 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
1933 | mActionUndo->plug( tb ); | 1860 | mActionUndo->plug( tb ); |
1934 | mActionDelete->plug( tb ); | 1861 | mActionDelete->plug( tb ); |
1935 | mActionRedo->plug( tb ); | 1862 | mActionRedo->plug( tb ); |
1936 | } | 1863 | } |
1937 | } | 1864 | } |
1938 | //mActionQuit->plug ( tb ); | 1865 | //mActionQuit->plug ( tb ); |
1939 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 1866 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
1940 | 1867 | ||
1941 | //US link the searchwidget first to this. | 1868 | //US link the searchwidget first to this. |
1942 | // The real linkage to the toolbar happens later. | 1869 | // The real linkage to the toolbar happens later. |
1943 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 1870 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
1944 | //US tb->insertItem( mIncSearchWidget ); | 1871 | //US tb->insertItem( mIncSearchWidget ); |
1945 | /*US | 1872 | /*US |
1946 | mIncSearchWidget = new IncSearchWidget( tb ); | 1873 | mIncSearchWidget = new IncSearchWidget( tb ); |
1947 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1874 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1948 | SLOT( incrementalSearch( const QString& ) ) ); | 1875 | SLOT( incrementalSearch( const QString& ) ) ); |
1949 | 1876 | ||
1950 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1877 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1951 | 1878 | ||
1952 | //US topLayout->addWidget( mJumpButtonBar ); | 1879 | //US topLayout->addWidget( mJumpButtonBar ); |
1953 | this->layout()->add( mJumpButtonBar ); | 1880 | this->layout()->add( mJumpButtonBar ); |
1954 | */ | 1881 | */ |
1955 | 1882 | ||
1956 | #endif //KAB_EMBEDDED | 1883 | #endif //KAB_EMBEDDED |
1957 | } | 1884 | } |
1958 | void KABCore::showLicence() | 1885 | void KABCore::showLicence() |
1959 | { | 1886 | { |
1960 | KApplication::showLicence(); | 1887 | KApplication::showLicence(); |
1961 | } | 1888 | } |
1962 | void KABCore::removeVoice() | 1889 | void KABCore::removeVoice() |
1963 | { | 1890 | { |
1964 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 1891 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
1965 | return; | 1892 | return; |
1966 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 1893 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
1967 | KABC::Addressee::List::Iterator it; | 1894 | KABC::Addressee::List::Iterator it; |
1968 | for ( it = list.begin(); it != list.end(); ++it ) { | 1895 | for ( it = list.begin(); it != list.end(); ++it ) { |
1969 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 1896 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
1970 | PhoneNumber::List::Iterator phoneIt; | 1897 | PhoneNumber::List::Iterator phoneIt; |
1971 | bool found = false; | 1898 | bool found = false; |
1972 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 1899 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
1973 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 1900 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
1974 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 1901 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
1975 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 1902 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
1976 | (*it).insertPhoneNumber( (*phoneIt) ); | 1903 | (*it).insertPhoneNumber( (*phoneIt) ); |
1977 | found = true; | 1904 | found = true; |
1978 | } | 1905 | } |
1979 | } | 1906 | } |
1980 | 1907 | ||
1981 | } | 1908 | } |
1982 | if ( found ) | 1909 | if ( found ) |
1983 | contactModified((*it) ); | 1910 | contactModified((*it) ); |
1984 | } | 1911 | } |
1985 | } | 1912 | } |
1986 | 1913 | ||
1987 | 1914 | ||
1988 | 1915 | ||
1989 | void KABCore::clipboardDataChanged() | 1916 | void KABCore::clipboardDataChanged() |
1990 | { | 1917 | { |
1991 | 1918 | ||
1992 | if ( mReadWrite ) | 1919 | if ( mReadWrite ) |
1993 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 1920 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
1994 | 1921 | ||
1995 | } | 1922 | } |
1996 | 1923 | ||
1997 | void KABCore::updateActionMenu() | 1924 | void KABCore::updateActionMenu() |
1998 | { | 1925 | { |
1999 | UndoStack *undo = UndoStack::instance(); | 1926 | UndoStack *undo = UndoStack::instance(); |
2000 | RedoStack *redo = RedoStack::instance(); | 1927 | RedoStack *redo = RedoStack::instance(); |
2001 | 1928 | ||
2002 | if ( undo->isEmpty() ) | 1929 | if ( undo->isEmpty() ) |
2003 | mActionUndo->setText( i18n( "Undo" ) ); | 1930 | mActionUndo->setText( i18n( "Undo" ) ); |
2004 | else | 1931 | else |
2005 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 1932 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2006 | 1933 | ||
2007 | mActionUndo->setEnabled( !undo->isEmpty() ); | 1934 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2008 | 1935 | ||
2009 | if ( !redo->top() ) | 1936 | if ( !redo->top() ) |
2010 | mActionRedo->setText( i18n( "Redo" ) ); | 1937 | mActionRedo->setText( i18n( "Redo" ) ); |
2011 | else | 1938 | else |
2012 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 1939 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2013 | 1940 | ||
2014 | mActionRedo->setEnabled( !redo->isEmpty() ); | 1941 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2015 | } | 1942 | } |
2016 | 1943 | ||
2017 | void KABCore::configureKeyBindings() | 1944 | void KABCore::configureKeyBindings() |
2018 | { | 1945 | { |
2019 | #ifndef KAB_EMBEDDED | 1946 | #ifndef KAB_EMBEDDED |
2020 | KKeyDialog::configure( actionCollection(), true ); | 1947 | KKeyDialog::configure( actionCollection(), true ); |
2021 | #else //KAB_EMBEDDED | 1948 | #else //KAB_EMBEDDED |
2022 | qDebug("KABCore::configureKeyBindings() not implemented"); | 1949 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2023 | #endif //KAB_EMBEDDED | 1950 | #endif //KAB_EMBEDDED |
2024 | } | 1951 | } |
2025 | 1952 | ||
2026 | #ifdef KAB_EMBEDDED | 1953 | #ifdef KAB_EMBEDDED |
2027 | void KABCore::configureResources() | 1954 | void KABCore::configureResources() |
2028 | { | 1955 | { |
2029 | KRES::KCMKResources dlg( this, "" , 0 ); | 1956 | KRES::KCMKResources dlg( this, "" , 0 ); |
2030 | 1957 | ||
2031 | if ( !dlg.exec() ) | 1958 | if ( !dlg.exec() ) |
2032 | return; | 1959 | return; |
2033 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 1960 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2034 | } | 1961 | } |
2035 | #endif //KAB_EMBEDDED | 1962 | #endif //KAB_EMBEDDED |
2036 | 1963 | ||
2037 | 1964 | ||
2038 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 1965 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2039 | * for the attendees list of an event. | 1966 | * for the attendees list of an event. |
2040 | */ | 1967 | */ |
2041 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 1968 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2042 | { | 1969 | { |
2043 | QStringList nameList; | 1970 | QStringList nameList; |
2044 | QStringList emailList; | 1971 | QStringList emailList; |
2045 | QStringList uidList; | 1972 | QStringList uidList; |
2046 | 1973 | ||
2047 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 1974 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2048 | uint i=0; | 1975 | uint i=0; |
2049 | for (i=0; i < list.count(); i++) | 1976 | for (i=0; i < list.count(); i++) |
2050 | { | 1977 | { |
2051 | nameList.append(list[i].realName()); | 1978 | nameList.append(list[i].realName()); |
2052 | emailList.append(list[i].preferredEmail()); | 1979 | emailList.append(list[i].preferredEmail()); |
2053 | uidList.append(list[i].uid()); | 1980 | uidList.append(list[i].uid()); |
2054 | } | 1981 | } |
2055 | 1982 | ||
2056 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 1983 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2057 | 1984 | ||
2058 | } | 1985 | } |
2059 | 1986 | ||
2060 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 1987 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2061 | */ | 1988 | */ |
2062 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 1989 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2063 | { | 1990 | { |
2064 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 1991 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2065 | 1992 | ||
2066 | QString foundUid = QString::null; | 1993 | QString foundUid = QString::null; |
2067 | if ( ! uid.isEmpty() ) { | 1994 | if ( ! uid.isEmpty() ) { |
2068 | Addressee adrr = mAddressBook->findByUid( uid ); | 1995 | Addressee adrr = mAddressBook->findByUid( uid ); |
2069 | if ( !adrr.isEmpty() ) { | 1996 | if ( !adrr.isEmpty() ) { |
2070 | foundUid = uid; | 1997 | foundUid = uid; |
2071 | } | 1998 | } |
2072 | if ( email == "sendbacklist" ) { | 1999 | if ( email == "sendbacklist" ) { |
2073 | //qDebug("ssssssssssssssssssssssend "); | 2000 | //qDebug("ssssssssssssssssssssssend "); |
2074 | QStringList nameList; | 2001 | QStringList nameList; |
2075 | QStringList emailList; | 2002 | QStringList emailList; |
2076 | QStringList uidList; | 2003 | QStringList uidList; |
2077 | nameList.append(adrr.realName()); | 2004 | nameList.append(adrr.realName()); |
2078 | emailList = adrr.emails(); | 2005 | emailList = adrr.emails(); |
2079 | uidList.append( adrr.preferredEmail()); | 2006 | uidList.append( adrr.preferredEmail()); |
2080 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2007 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2081 | return; | 2008 | return; |
2082 | } | 2009 | } |
2083 | 2010 | ||
2084 | } | 2011 | } |
2085 | 2012 | ||
2086 | if ( email == "sendbacklist" ) | 2013 | if ( email == "sendbacklist" ) |
2087 | return; | 2014 | return; |
2088 | if (foundUid.isEmpty()) | 2015 | if (foundUid.isEmpty()) |
2089 | { | 2016 | { |
2090 | //find the uid of the person first | 2017 | //find the uid of the person first |
2091 | Addressee::List namelist; | 2018 | Addressee::List namelist; |
2092 | Addressee::List emaillist; | 2019 | Addressee::List emaillist; |
2093 | 2020 | ||
2094 | if (!name.isEmpty()) | 2021 | if (!name.isEmpty()) |
2095 | namelist = mAddressBook->findByName( name ); | 2022 | namelist = mAddressBook->findByName( name ); |
2096 | 2023 | ||
2097 | if (!email.isEmpty()) | 2024 | if (!email.isEmpty()) |
2098 | emaillist = mAddressBook->findByEmail( email ); | 2025 | emaillist = mAddressBook->findByEmail( email ); |
2099 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2026 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2100 | //check if we have a match in Namelist and Emaillist | 2027 | //check if we have a match in Namelist and Emaillist |
2101 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2028 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2102 | foundUid = emaillist[0].uid(); | 2029 | foundUid = emaillist[0].uid(); |
2103 | } | 2030 | } |
2104 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2031 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2105 | foundUid = namelist[0].uid(); | 2032 | foundUid = namelist[0].uid(); |
2106 | else | 2033 | else |
2107 | { | 2034 | { |
2108 | for (int i = 0; i < namelist.count(); i++) | 2035 | for (int i = 0; i < namelist.count(); i++) |
2109 | { | 2036 | { |
2110 | for (int j = 0; j < emaillist.count(); j++) | 2037 | for (int j = 0; j < emaillist.count(); j++) |
2111 | { | 2038 | { |
2112 | if (namelist[i] == emaillist[j]) | 2039 | if (namelist[i] == emaillist[j]) |
2113 | { | 2040 | { |
2114 | foundUid = namelist[i].uid(); | 2041 | foundUid = namelist[i].uid(); |
2115 | } | 2042 | } |
2116 | } | 2043 | } |
2117 | } | 2044 | } |
2118 | } | 2045 | } |
2119 | } | 2046 | } |
2120 | else | 2047 | else |
2121 | { | 2048 | { |
2122 | foundUid = uid; | 2049 | foundUid = uid; |
2123 | } | 2050 | } |
2124 | 2051 | ||
2125 | if (!foundUid.isEmpty()) | 2052 | if (!foundUid.isEmpty()) |
2126 | { | 2053 | { |
2127 | 2054 | ||
2128 | // raise Ka/Pi if it is in the background | 2055 | // raise Ka/Pi if it is in the background |
2129 | #ifndef DESKTOP_VERSION | 2056 | #ifndef DESKTOP_VERSION |
2130 | #ifndef KORG_NODCOP | 2057 | #ifndef KORG_NODCOP |
2131 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2058 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2132 | #endif | 2059 | #endif |
2133 | #endif | 2060 | #endif |
2134 | 2061 | ||
2135 | mMainWindow->showMaximized(); | 2062 | mMainWindow->showMaximized(); |
2136 | mMainWindow-> raise(); | 2063 | mMainWindow-> raise(); |
2137 | 2064 | ||
2138 | mViewManager->setSelected( "", false); | 2065 | mViewManager->setSelected( "", false); |
2139 | mViewManager->refreshView( "" ); | 2066 | mViewManager->refreshView( "" ); |
2140 | mViewManager->setSelected( foundUid, true ); | 2067 | mViewManager->setSelected( foundUid, true ); |
2141 | mViewManager->refreshView( foundUid ); | 2068 | mViewManager->refreshView( foundUid ); |
2142 | 2069 | ||
2143 | if ( !mMultipleViewsAtOnce ) | 2070 | if ( !mMultipleViewsAtOnce ) |
2144 | { | 2071 | { |
2145 | setDetailsVisible( true ); | 2072 | setDetailsVisible( true ); |
2146 | mActionDetails->setChecked(true); | 2073 | mActionDetails->setChecked(true); |
2147 | } | 2074 | } |
2148 | } | 2075 | } |
2149 | } | 2076 | } |
2150 | 2077 | ||
2151 | 2078 | ||
2152 | void KABCore::faq() | 2079 | void KABCore::faq() |
2153 | { | 2080 | { |
2154 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2081 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2155 | } | 2082 | } |
2156 | 2083 | ||
2157 | 2084 | ||
2158 | 2085 | ||
2159 | 2086 | ||
2160 | #ifndef KAB_EMBEDDED | 2087 | #ifndef KAB_EMBEDDED |
2161 | #include "kabcore.moc" | 2088 | #include "kabcore.moc" |
2162 | #endif //KAB_EMBEDDED | 2089 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h index 7457080..17106e8 100644 --- a/kaddressbook/kaddressbookview.h +++ b/kaddressbook/kaddressbookview.h | |||
@@ -1,295 +1,296 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
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 KADDRESSBOOKVIEW_H | 24 | #ifndef KADDRESSBOOKVIEW_H |
25 | #define KADDRESSBOOKVIEW_H | 25 | #define KADDRESSBOOKVIEW_H |
26 | 26 | ||
27 | #ifndef KAB_EMBEDDED | 27 | #ifndef KAB_EMBEDDED |
28 | #include <klibloader.h> | 28 | #include <klibloader.h> |
29 | #endif //KAB_EMBEDDED | 29 | #endif //KAB_EMBEDDED |
30 | 30 | ||
31 | class KConfig; | 31 | class KConfig; |
32 | class QDropEvent; | 32 | class QDropEvent; |
33 | 33 | ||
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <kabc/field.h> | 35 | #include <kabc/field.h> |
36 | #include <qwidget.h> | 36 | #include <qwidget.h> |
37 | 37 | ||
38 | #include "viewconfigurewidget.h" | 38 | #include "viewconfigurewidget.h" |
39 | #include "filter.h" | 39 | #include "filter.h" |
40 | 40 | ||
41 | namespace KABC { class AddressBook; } | 41 | namespace KABC { class AddressBook; } |
42 | 42 | ||
43 | /** | 43 | /** |
44 | Base class for all views in kaddressbook. This class implements | 44 | Base class for all views in kaddressbook. This class implements |
45 | all the common methods needed to provide a view to the user. | 45 | all the common methods needed to provide a view to the user. |
46 | 46 | ||
47 | To implement a specific view (table, card, etc), just inherit from | 47 | To implement a specific view (table, card, etc), just inherit from |
48 | this class and implement all the pure virtuals. | 48 | this class and implement all the pure virtuals. |
49 | 49 | ||
50 | @author Mike Pilone <mpilone@slac.com> | 50 | @author Mike Pilone <mpilone@slac.com> |
51 | */ | 51 | */ |
52 | class KAddressBookView : public QWidget | 52 | class KAddressBookView : public QWidget |
53 | { | 53 | { |
54 | Q_OBJECT | 54 | Q_OBJECT |
55 | 55 | ||
56 | public: | 56 | public: |
57 | enum DefaultFilterType { None = 0, Active = 1, Specific = 2 }; | 57 | enum DefaultFilterType { None = 0, Active = 1, Specific = 2 }; |
58 | 58 | ||
59 | KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name ); | 59 | KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name ); |
60 | virtual ~KAddressBookView(); | 60 | virtual ~KAddressBookView(); |
61 | 61 | ||
62 | /** | 62 | /** |
63 | Must be overloaded in subclasses. Should return a list of | 63 | Must be overloaded in subclasses. Should return a list of |
64 | all the uids of selected contacts. | 64 | all the uids of selected contacts. |
65 | */ | 65 | */ |
66 | virtual QStringList selectedUids() = 0; | 66 | virtual QStringList selectedUids() = 0; |
67 | virtual void doSearch( const QString& s ,KABC::Field *field ) = 0; | ||
67 | 68 | ||
68 | /** | 69 | /** |
69 | Called whenever this view should read the config. This can be used | 70 | Called whenever this view should read the config. This can be used |
70 | as a sign that the config has changed, therefore the view should | 71 | as a sign that the config has changed, therefore the view should |
71 | assume the worst and rebuild itself if necessary. For example, | 72 | assume the worst and rebuild itself if necessary. For example, |
72 | in a table view this method may be called when the user adds or | 73 | in a table view this method may be called when the user adds or |
73 | removes columns from the view. | 74 | removes columns from the view. |
74 | 75 | ||
75 | If overloaded in the subclass, do not forget to call super class's | 76 | If overloaded in the subclass, do not forget to call super class's |
76 | method. | 77 | method. |
77 | 78 | ||
78 | @param config The KConfig object to read from. The group will already | 79 | @param config The KConfig object to read from. The group will already |
79 | be set, so do not change the group. | 80 | be set, so do not change the group. |
80 | */ | 81 | */ |
81 | virtual void readConfig( KConfig *config ); | 82 | virtual void readConfig( KConfig *config ); |
82 | 83 | ||
83 | /** | 84 | /** |
84 | Called whenever this view should write the config. The view should not | 85 | Called whenever this view should write the config. The view should not |
85 | write out information handled by the application, such as which fields | 86 | write out information handled by the application, such as which fields |
86 | are visible. The view should only write out information specific | 87 | are visible. The view should only write out information specific |
87 | to itself (i.e.: All information in the ViewConfigWidget) | 88 | to itself (i.e.: All information in the ViewConfigWidget) |
88 | 89 | ||
89 | If overloaded in the subclass, do not forget to call the super class's | 90 | If overloaded in the subclass, do not forget to call the super class's |
90 | method. | 91 | method. |
91 | 92 | ||
92 | @param config The KConfig object to read from. The group will already | 93 | @param config The KConfig object to read from. The group will already |
93 | be set, so do not change the group. | 94 | be set, so do not change the group. |
94 | */ | 95 | */ |
95 | virtual void writeConfig( KConfig *config ); | 96 | virtual void writeConfig( KConfig *config ); |
96 | 97 | ||
97 | /** | 98 | /** |
98 | Returns a QString with all the selected email addresses concatenated | 99 | Returns a QString with all the selected email addresses concatenated |
99 | together with a ',' seperator. | 100 | together with a ',' seperator. |
100 | */ | 101 | */ |
101 | virtual QString selectedEmails(); | 102 | virtual QString selectedEmails(); |
102 | 103 | ||
103 | /** | 104 | /** |
104 | Return the type of the view: Icon, Table, etc. Please make sure that | 105 | Return the type of the view: Icon, Table, etc. Please make sure that |
105 | this is the same value that ViewWrapper::type() will return for your | 106 | this is the same value that ViewWrapper::type() will return for your |
106 | view. | 107 | view. |
107 | */ | 108 | */ |
108 | virtual QString type() const = 0; | 109 | virtual QString type() const = 0; |
109 | 110 | ||
110 | /** | 111 | /** |
111 | Returns a list of the fields that should be displayed. The list | 112 | Returns a list of the fields that should be displayed. The list |
112 | is composed of the fields proper names (ie: Home Address), so | 113 | is composed of the fields proper names (ie: Home Address), so |
113 | the view may need to translate them in order to get the | 114 | the view may need to translate them in order to get the |
114 | value from the addressee. | 115 | value from the addressee. |
115 | 116 | ||
116 | This list is generated from the config file, so it is advisable to call | 117 | This list is generated from the config file, so it is advisable to call |
117 | this method whenever a readConfig() is called in order to get the newest | 118 | this method whenever a readConfig() is called in order to get the newest |
118 | list of fields. | 119 | list of fields. |
119 | */ | 120 | */ |
120 | KABC::Field::List fields() const; | 121 | KABC::Field::List fields() const; |
121 | 122 | ||
122 | /** | 123 | /** |
123 | Sets the active filter. This filter will be used for filtering | 124 | Sets the active filter. This filter will be used for filtering |
124 | the list of addressees to display. The view will <b>not</b> | 125 | the list of addressees to display. The view will <b>not</b> |
125 | automatically refresh itself, so in most cases you will want to call | 126 | automatically refresh itself, so in most cases you will want to call |
126 | KAddressBookView::refresh() after this method. | 127 | KAddressBookView::refresh() after this method. |
127 | */ | 128 | */ |
128 | void setFilter( const Filter& ); | 129 | void setFilter( const Filter& ); |
129 | 130 | ||
130 | /** | 131 | /** |
131 | @return The default filter type selection. If the selection | 132 | @return The default filter type selection. If the selection |
132 | is SpecificFilter, the name of the filter can be retrieved with | 133 | is SpecificFilter, the name of the filter can be retrieved with |
133 | defaultFilterName() | 134 | defaultFilterName() |
134 | */ | 135 | */ |
135 | DefaultFilterType defaultFilterType() const; | 136 | DefaultFilterType defaultFilterType() const; |
136 | 137 | ||
137 | /** | 138 | /** |
138 | @return The name of the default filter. This string is | 139 | @return The name of the default filter. This string is |
139 | only valid if defaultFilterType() is returning SpecificFilter. | 140 | only valid if defaultFilterType() is returning SpecificFilter. |
140 | */ | 141 | */ |
141 | const QString &defaultFilterName() const; | 142 | const QString &defaultFilterName() const; |
142 | 143 | ||
143 | /** | 144 | /** |
144 | @return The address book. | 145 | @return The address book. |
145 | */ | 146 | */ |
146 | KABC::AddressBook *addressBook() const; | 147 | KABC::AddressBook *addressBook() const; |
147 | 148 | ||
148 | public slots: | 149 | public slots: |
149 | /** | 150 | /** |
150 | Must be overloaded in subclasses to refresh the view. | 151 | Must be overloaded in subclasses to refresh the view. |
151 | Refreshing includes updating the view to ensure that only items | 152 | Refreshing includes updating the view to ensure that only items |
152 | in the document are visible. If <i>uid</i> is valid, only the | 153 | in the document are visible. If <i>uid</i> is valid, only the |
153 | addressee with uid needs to be refreshed. This is an optimization | 154 | addressee with uid needs to be refreshed. This is an optimization |
154 | only. | 155 | only. |
155 | */ | 156 | */ |
156 | virtual void refresh( QString uid = QString::null ) = 0; | 157 | virtual void refresh( QString uid = QString::null ) = 0; |
157 | 158 | ||
158 | /** | 159 | /** |
159 | This method must be overloaded in subclasses. Select (highlight) | 160 | This method must be overloaded in subclasses. Select (highlight) |
160 | the addressee matching <i>uid</i>. If uid | 161 | the addressee matching <i>uid</i>. If uid |
161 | is equal to QString::null, then all addressees should be selected. | 162 | is equal to QString::null, then all addressees should be selected. |
162 | */ | 163 | */ |
163 | #ifndef KAB_EMBEDDED | 164 | #ifndef KAB_EMBEDDED |
164 | //MOC_SKIP_BEGIN | 165 | //MOC_SKIP_BEGIN |
165 | virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0; | 166 | virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0; |
166 | //MOC_SKIP_END | 167 | //MOC_SKIP_END |
167 | #else //KAB_EMBEDDED | 168 | #else //KAB_EMBEDDED |
168 | //US my moc can not handle the default parameters. Is this a problem ??? | 169 | //US my moc can not handle the default parameters. Is this a problem ??? |
169 | virtual void setSelected( QString uid, bool selected) = 0; | 170 | virtual void setSelected( QString uid, bool selected) = 0; |
170 | #endif //KAB_EMBEDDED | 171 | #endif //KAB_EMBEDDED |
171 | 172 | ||
172 | signals: | 173 | signals: |
173 | /** | 174 | /** |
174 | This signal should be emitted by a subclass whenever an addressee | 175 | This signal should be emitted by a subclass whenever an addressee |
175 | is modified. | 176 | is modified. |
176 | */ | 177 | */ |
177 | void modified(); | 178 | void modified(); |
178 | 179 | ||
179 | /** | 180 | /** |
180 | This signal should be emitted by a subclass whenever an addressee | 181 | This signal should be emitted by a subclass whenever an addressee |
181 | is selected. Selected means that the addressee was given the focus. | 182 | is selected. Selected means that the addressee was given the focus. |
182 | Some widgets may call this 'highlighted'. The view is responsible for | 183 | Some widgets may call this 'highlighted'. The view is responsible for |
183 | emitting this signal multiple times if multiple items are selected, | 184 | emitting this signal multiple times if multiple items are selected, |
184 | with the last item selected being the last emit. | 185 | with the last item selected being the last emit. |
185 | 186 | ||
186 | @param uid The uid of the selected addressee. | 187 | @param uid The uid of the selected addressee. |
187 | 188 | ||
188 | @see KListView | 189 | @see KListView |
189 | */ | 190 | */ |
190 | void selected( const QString &uid ); | 191 | void selected( const QString &uid ); |
191 | void deleteRequest(); | 192 | void deleteRequest(); |
192 | /** | 193 | /** |
193 | This signal should be emitted by a subclass whenever an addressee | 194 | This signal should be emitted by a subclass whenever an addressee |
194 | is executed. This is defined by the KDE system wide config, but it | 195 | is executed. This is defined by the KDE system wide config, but it |
195 | either means single or doubleclicked. | 196 | either means single or doubleclicked. |
196 | 197 | ||
197 | @param ui The uid of the selected addressee | 198 | @param ui The uid of the selected addressee |
198 | 199 | ||
199 | @see KListView | 200 | @see KListView |
200 | */ | 201 | */ |
201 | void executed( const QString &uid ); | 202 | void executed( const QString &uid ); |
202 | 203 | ||
203 | /** | 204 | /** |
204 | This signal is emitted whenever a user attempts to start a drag | 205 | This signal is emitted whenever a user attempts to start a drag |
205 | in the view. The slot connected to this signal would usually want | 206 | in the view. The slot connected to this signal would usually want |
206 | to create a QDragObject. | 207 | to create a QDragObject. |
207 | */ | 208 | */ |
208 | void startDrag(); | 209 | void startDrag(); |
209 | 210 | ||
210 | /** | 211 | /** |
211 | This signal is emitted whenever the user drops something on the | 212 | This signal is emitted whenever the user drops something on the |
212 | view. The individual view should handle checking if the item is | 213 | view. The individual view should handle checking if the item is |
213 | droppable (ie: if it is a vcard). | 214 | droppable (ie: if it is a vcard). |
214 | */ | 215 | */ |
215 | void dropped( QDropEvent* ); | 216 | void dropped( QDropEvent* ); |
216 | 217 | ||
217 | protected: | 218 | protected: |
218 | /** | 219 | /** |
219 | Returns a list of the addressees that should be displayed. This method | 220 | Returns a list of the addressees that should be displayed. This method |
220 | should always be used by the subclass to get a list of addressees. This | 221 | should always be used by the subclass to get a list of addressees. This |
221 | method internally takes many factors into account, including the current | 222 | method internally takes many factors into account, including the current |
222 | filter. | 223 | filter. |
223 | */ | 224 | */ |
224 | KABC::Addressee::List addressees(); | 225 | KABC::Addressee::List addressees(); |
225 | 226 | ||
226 | /** | 227 | /** |
227 | This method returns the widget that should be used as the parent for | 228 | This method returns the widget that should be used as the parent for |
228 | all view components. By using this widget as the parent and not | 229 | all view components. By using this widget as the parent and not |
229 | 'this', the view subclass has the option of placing other widgets | 230 | 'this', the view subclass has the option of placing other widgets |
230 | around the view (ie: search fields, etc). Do not delete this widget! | 231 | around the view (ie: search fields, etc). Do not delete this widget! |
231 | */ | 232 | */ |
232 | QWidget *viewWidget(); | 233 | QWidget *viewWidget(); |
233 | 234 | ||
234 | private: | 235 | private: |
235 | void initGUI(); | 236 | void initGUI(); |
236 | 237 | ||
237 | DefaultFilterType mDefaultFilterType; | 238 | DefaultFilterType mDefaultFilterType; |
238 | Filter mFilter; | 239 | Filter mFilter; |
239 | QString mDefaultFilterName; | 240 | QString mDefaultFilterName; |
240 | KABC::AddressBook *mAddressBook; | 241 | KABC::AddressBook *mAddressBook; |
241 | KABC::Field::List mFieldList; | 242 | KABC::Field::List mFieldList; |
242 | 243 | ||
243 | QWidget *mViewWidget; | 244 | QWidget *mViewWidget; |
244 | }; | 245 | }; |
245 | 246 | ||
246 | #ifndef KAB_EMBEDDED | 247 | #ifndef KAB_EMBEDDED |
247 | //MOC_SKIP_BEGIN | 248 | //MOC_SKIP_BEGIN |
248 | class ViewFactory : public KLibFactory | 249 | class ViewFactory : public KLibFactory |
249 | //MOC_SKIP_END | 250 | //MOC_SKIP_END |
250 | #else //KAB_EMBEDDED | 251 | #else //KAB_EMBEDDED |
251 | class ViewFactory | 252 | class ViewFactory |
252 | #endif //KAB_EMBEDDED | 253 | #endif //KAB_EMBEDDED |
253 | { | 254 | { |
254 | 255 | ||
255 | public: | 256 | public: |
256 | virtual KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, | 257 | virtual KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, |
257 | const char *name = 0 ) = 0; | 258 | const char *name = 0 ) = 0; |
258 | 259 | ||
259 | /** | 260 | /** |
260 | @return The type of the view. This is normally a small one word | 261 | @return The type of the view. This is normally a small one word |
261 | string (ie: Table, Icon, Tree, etc). | 262 | string (ie: Table, Icon, Tree, etc). |
262 | */ | 263 | */ |
263 | virtual QString type() const = 0; | 264 | virtual QString type() const = 0; |
264 | 265 | ||
265 | /** | 266 | /** |
266 | @return The description of the view. This should be a 3 to | 267 | @return The description of the view. This should be a 3 to |
267 | 4 line string (don't actually use return characters in the string) | 268 | 4 line string (don't actually use return characters in the string) |
268 | describing the features offered by the view. | 269 | describing the features offered by the view. |
269 | */ | 270 | */ |
270 | virtual QString description() const = 0; | 271 | virtual QString description() const = 0; |
271 | 272 | ||
272 | /** | 273 | /** |
273 | Creates a config dialog for the view type. The default | 274 | Creates a config dialog for the view type. The default |
274 | implementation will return a ViewConfigDialog. This default | 275 | implementation will return a ViewConfigDialog. This default |
275 | dialog will allow the user to set the visible fields only. If | 276 | dialog will allow the user to set the visible fields only. If |
276 | you need more config options (as most views will), this method | 277 | you need more config options (as most views will), this method |
277 | can be overloaded to return your sublcass of ViewConfigDialog. | 278 | can be overloaded to return your sublcass of ViewConfigDialog. |
278 | If this method is over loaded the base classes method should | 279 | If this method is over loaded the base classes method should |
279 | <B>not</B> be called. | 280 | <B>not</B> be called. |
280 | */ | 281 | */ |
281 | virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, | 282 | virtual ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, |
282 | QWidget *parent, | 283 | QWidget *parent, |
283 | const char *name = 0 ); | 284 | const char *name = 0 ); |
284 | 285 | ||
285 | protected: | 286 | protected: |
286 | virtual QObject* createObject( QObject*, const char*, const char*, | 287 | virtual QObject* createObject( QObject*, const char*, const char*, |
287 | const QStringList & ) | 288 | const QStringList & ) |
288 | { | 289 | { |
289 | return 0; | 290 | return 0; |
290 | } | 291 | } |
291 | 292 | ||
292 | }; | 293 | }; |
293 | 294 | ||
294 | 295 | ||
295 | #endif | 296 | #endif |
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index c93d51a..c6baeac 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp | |||
@@ -1,699 +1,704 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
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 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | 31 | ||
32 | #ifndef KAB_EMBEDDED | 32 | #ifndef KAB_EMBEDDED |
33 | #include <libkdepim/kvcarddrag.h> | 33 | #include <libkdepim/kvcarddrag.h> |
34 | #include <kabc/vcardconverter.h> | 34 | #include <kabc/vcardconverter.h> |
35 | #include <kconfig.h> | 35 | #include <kconfig.h> |
36 | #include <kdeversion.h> | 36 | #include <kdeversion.h> |
37 | #include <kiconloader.h> | 37 | #include <kiconloader.h> |
38 | #include <klocale.h> | 38 | #include <klocale.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | #include <kmultipledrag.h> | 40 | #include <kmultipledrag.h> |
41 | #include <ktrader.h> | 41 | #include <ktrader.h> |
42 | #include <kurldrag.h> | 42 | #include <kurldrag.h> |
43 | 43 | ||
44 | #include "addresseeutil.h" | 44 | #include "addresseeutil.h" |
45 | #else //KAB_EMBEDDED | 45 | #else //KAB_EMBEDDED |
46 | #include "views/kaddressbookiconview.h" | 46 | #include "views/kaddressbookiconview.h" |
47 | #include "views/kaddressbooktableview.h" | 47 | #include "views/kaddressbooktableview.h" |
48 | #include "views/kaddressbookcardview.h" | 48 | #include "views/kaddressbookcardview.h" |
49 | #include "kaddressbookview.h" | 49 | #include "kaddressbookview.h" |
50 | 50 | ||
51 | #include <qaction.h> | 51 | #include <qaction.h> |
52 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
53 | #include <qpopupmenu.h> | 53 | #include <qpopupmenu.h> |
54 | #include <kconfigbase.h> | 54 | #include <kconfigbase.h> |
55 | 55 | ||
56 | #endif //KAB_EMBEDDED | 56 | #endif //KAB_EMBEDDED |
57 | 57 | ||
58 | 58 | ||
59 | #include <kdebug.h> | 59 | #include <kdebug.h> |
60 | #include <kactionclasses.h> | 60 | #include <kactionclasses.h> |
61 | 61 | ||
62 | #include <qlayout.h> | 62 | #include <qlayout.h> |
63 | #include <qwidgetstack.h> | 63 | #include <qwidgetstack.h> |
64 | 64 | ||
65 | #include <kabc/addressbook.h> | 65 | #include <kabc/addressbook.h> |
66 | #include "filtereditdialog.h" | 66 | #include "filtereditdialog.h" |
67 | #include "addviewdialog.h" | 67 | #include "addviewdialog.h" |
68 | #include "kabcore.h" | 68 | #include "kabcore.h" |
69 | #include "kabprefs.h" | 69 | #include "kabprefs.h" |
70 | #include "viewmanager.h" | 70 | #include "viewmanager.h" |
71 | 71 | ||
72 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) | 72 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) |
73 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) | 73 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) |
74 | { | 74 | { |
75 | initGUI(); | 75 | initGUI(); |
76 | initActions(); | 76 | initActions(); |
77 | 77 | ||
78 | mViewDict.setAutoDelete( true ); | 78 | mViewDict.setAutoDelete( true ); |
79 | 79 | ||
80 | createViewFactories(); | 80 | createViewFactories(); |
81 | } | 81 | } |
82 | 82 | ||
83 | ViewManager::~ViewManager() | 83 | ViewManager::~ViewManager() |
84 | { | 84 | { |
85 | unloadViews(); | 85 | unloadViews(); |
86 | mViewFactoryDict.clear(); | 86 | mViewFactoryDict.clear(); |
87 | } | 87 | } |
88 | 88 | ||
89 | void ViewManager::restoreSettings() | 89 | void ViewManager::restoreSettings() |
90 | { | 90 | { |
91 | mViewNameList = KABPrefs::instance()->mViewNames; | 91 | mViewNameList = KABPrefs::instance()->mViewNames; |
92 | QString activeViewName = KABPrefs::instance()->mCurrentView; | 92 | QString activeViewName = KABPrefs::instance()->mCurrentView; |
93 | 93 | ||
94 | mActionSelectView->setItems( mViewNameList ); | 94 | mActionSelectView->setItems( mViewNameList ); |
95 | 95 | ||
96 | // Filter | 96 | // Filter |
97 | mFilterList = Filter::restore( mCore->config(), "Filter" ); | 97 | mFilterList = Filter::restore( mCore->config(), "Filter" ); |
98 | mActionSelectFilter->setItems( filterNames() ); | 98 | mActionSelectFilter->setItems( filterNames() ); |
99 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); | 99 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); |
100 | 100 | ||
101 | // Tell the views to reread their config, since they may have | 101 | // Tell the views to reread their config, since they may have |
102 | // been modified by global settings | 102 | // been modified by global settings |
103 | QString _oldgroup = mCore->config()->group(); | 103 | QString _oldgroup = mCore->config()->group(); |
104 | 104 | ||
105 | QDictIterator<KAddressBookView> it( mViewDict ); | 105 | QDictIterator<KAddressBookView> it( mViewDict ); |
106 | for ( it.toFirst(); it.current(); ++it ) { | 106 | for ( it.toFirst(); it.current(); ++it ) { |
107 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 107 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
108 | it.current()->readConfig( mCore->config() ); | 108 | it.current()->readConfig( mCore->config() ); |
109 | } | 109 | } |
110 | setActiveView( activeViewName ); | 110 | setActiveView( activeViewName ); |
111 | 111 | ||
112 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 112 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
113 | } | 113 | } |
114 | 114 | ||
115 | void ViewManager::saveSettings() | 115 | void ViewManager::saveSettings() |
116 | { | 116 | { |
117 | QString _oldgroup = mCore->config()->group(); | 117 | QString _oldgroup = mCore->config()->group(); |
118 | 118 | ||
119 | QDictIterator<KAddressBookView> it( mViewDict ); | 119 | QDictIterator<KAddressBookView> it( mViewDict ); |
120 | for ( it.toFirst(); it.current(); ++it ) { | 120 | for ( it.toFirst(); it.current(); ++it ) { |
121 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 121 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
122 | #ifdef DESKTOP_VERSION | 122 | #ifdef DESKTOP_VERSION |
123 | (*it)->writeConfig( mCore->config() ); | 123 | (*it)->writeConfig( mCore->config() ); |
124 | #else | 124 | #else |
125 | (*it).writeConfig( mCore->config() ); | 125 | (*it).writeConfig( mCore->config() ); |
126 | #endif | 126 | #endif |
127 | } | 127 | } |
128 | 128 | ||
129 | Filter::save( mCore->config(), "Filter", mFilterList ); | 129 | Filter::save( mCore->config(), "Filter", mFilterList ); |
130 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); | 130 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); |
131 | 131 | ||
132 | // write the view name list | 132 | // write the view name list |
133 | KABPrefs::instance()->mViewNames = mViewNameList; | 133 | KABPrefs::instance()->mViewNames = mViewNameList; |
134 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); | 134 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); |
135 | 135 | ||
136 | } | 136 | } |
137 | 137 | ||
138 | QStringList ViewManager::selectedUids() const | 138 | QStringList ViewManager::selectedUids() const |
139 | { | 139 | { |
140 | if ( mActiveView ) | 140 | if ( mActiveView ) |
141 | return mActiveView->selectedUids(); | 141 | return mActiveView->selectedUids(); |
142 | else | 142 | else |
143 | return QStringList(); | 143 | return QStringList(); |
144 | } | 144 | } |
145 | 145 | ||
146 | QStringList ViewManager::selectedEmails() const | 146 | QStringList ViewManager::selectedEmails() const |
147 | { | 147 | { |
148 | if ( mActiveView ) | 148 | if ( mActiveView ) |
149 | return mActiveView->selectedEmails(); | 149 | return mActiveView->selectedEmails(); |
150 | else | 150 | else |
151 | return QStringList(); | 151 | return QStringList(); |
152 | } | 152 | } |
153 | 153 | ||
154 | KABC::Addressee::List ViewManager::selectedAddressees() const | 154 | KABC::Addressee::List ViewManager::selectedAddressees() const |
155 | { | 155 | { |
156 | KABC::Addressee::List list; | 156 | KABC::Addressee::List list; |
157 | if ( mActiveView ) { | 157 | if ( mActiveView ) { |
158 | QStringList uids = mActiveView->selectedUids(); | 158 | QStringList uids = mActiveView->selectedUids(); |
159 | QStringList::Iterator it; | 159 | QStringList::Iterator it; |
160 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 160 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
161 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); | 161 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); |
162 | if ( !addr.isEmpty() ) | 162 | if ( !addr.isEmpty() ) |
163 | list.append( addr ); | 163 | list.append( addr ); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | return list; | 167 | return list; |
168 | } | 168 | } |
169 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 169 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
170 | void ViewManager::setSelected() | 170 | void ViewManager::setSelected() |
171 | { | 171 | { |
172 | setSelected( QString::null, true ); | 172 | setSelected( QString::null, true ); |
173 | } | 173 | } |
174 | 174 | ||
175 | void ViewManager::setSelected( const QString &uid, bool selected ) | 175 | void ViewManager::setSelected( const QString &uid, bool selected ) |
176 | { | 176 | { |
177 | if ( mActiveView ) | 177 | if ( mActiveView ) |
178 | mActiveView->setSelected( uid, selected ); | 178 | mActiveView->setSelected( uid, selected ); |
179 | } | 179 | } |
180 | 180 | ||
181 | void ViewManager::setListSelected(QStringList list) | 181 | void ViewManager::setListSelected(QStringList list) |
182 | { | 182 | { |
183 | int i, count = list.count(); | 183 | int i, count = list.count(); |
184 | for ( i = 0; i < count;++i ) | 184 | for ( i = 0; i < count;++i ) |
185 | setSelected( list[i], true ); | 185 | setSelected( list[i], true ); |
186 | 186 | ||
187 | } | 187 | } |
188 | void ViewManager::unloadViews() | 188 | void ViewManager::unloadViews() |
189 | { | 189 | { |
190 | mViewDict.clear(); | 190 | mViewDict.clear(); |
191 | mActiveView = 0; | 191 | mActiveView = 0; |
192 | } | 192 | } |
193 | 193 | ||
194 | void ViewManager::setActiveView( const QString &name ) | 194 | void ViewManager::setActiveView( const QString &name ) |
195 | { | 195 | { |
196 | KAddressBookView *view = 0; | 196 | KAddressBookView *view = 0; |
197 | 197 | ||
198 | // Check that this isn't the same as the current active view | 198 | // Check that this isn't the same as the current active view |
199 | if ( mActiveView && ( mActiveView->caption() == name ) ) | 199 | if ( mActiveView && ( mActiveView->caption() == name ) ) |
200 | return; | 200 | return; |
201 | 201 | ||
202 | // At this point we know the view that should be active is not | 202 | // At this point we know the view that should be active is not |
203 | // currently active. We will try to find the new on in the list. If | 203 | // currently active. We will try to find the new on in the list. If |
204 | // we can't find it, it means it hasn't been instantiated, so we will | 204 | // we can't find it, it means it hasn't been instantiated, so we will |
205 | // create it on demand. | 205 | // create it on demand. |
206 | 206 | ||
207 | view = mViewDict.find( name ); | 207 | view = mViewDict.find( name ); |
208 | 208 | ||
209 | // Check if we found the view. If we didn't, then we need to create it | 209 | // Check if we found the view. If we didn't, then we need to create it |
210 | if ( view == 0 ) { | 210 | if ( view == 0 ) { |
211 | KConfig *config = mCore->config(); | 211 | KConfig *config = mCore->config(); |
212 | 212 | ||
213 | KConfigGroupSaver saver( config, name ); | 213 | KConfigGroupSaver saver( config, name ); |
214 | 214 | ||
215 | QString type = config->readEntry( "Type", "Table" ); | 215 | QString type = config->readEntry( "Type", "Table" ); |
216 | 216 | ||
217 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; | 217 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; |
218 | 218 | ||
219 | ViewFactory *factory = mViewFactoryDict.find( type ); | 219 | ViewFactory *factory = mViewFactoryDict.find( type ); |
220 | if ( factory ) | 220 | if ( factory ) |
221 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); | 221 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); |
222 | 222 | ||
223 | if ( view ) { | 223 | if ( view ) { |
224 | view->setCaption( name ); | 224 | view->setCaption( name ); |
225 | mViewDict.insert( name, view ); | 225 | mViewDict.insert( name, view ); |
226 | //US my version needs an int as second parameter to addWidget | 226 | //US my version needs an int as second parameter to addWidget |
227 | mViewWidgetStack->addWidget( view, -1 ); | 227 | mViewWidgetStack->addWidget( view, -1 ); |
228 | view->readConfig( config ); | 228 | view->readConfig( config ); |
229 | 229 | ||
230 | // The manager just relays the signals | 230 | // The manager just relays the signals |
231 | connect( view, SIGNAL( selected( const QString& ) ), | 231 | connect( view, SIGNAL( selected( const QString& ) ), |
232 | SIGNAL( selected( const QString & ) ) ); | 232 | SIGNAL( selected( const QString & ) ) ); |
233 | connect( view, SIGNAL( executed( const QString& ) ), | 233 | connect( view, SIGNAL( executed( const QString& ) ), |
234 | SIGNAL( executed( const QString& ) ) ); | 234 | SIGNAL( executed( const QString& ) ) ); |
235 | 235 | ||
236 | connect( view, SIGNAL( deleteRequest( ) ), | 236 | connect( view, SIGNAL( deleteRequest( ) ), |
237 | SIGNAL( deleteRequest( ) ) ); | 237 | SIGNAL( deleteRequest( ) ) ); |
238 | 238 | ||
239 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); | 239 | connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); |
240 | connect( view, SIGNAL( dropped( QDropEvent* ) ), | 240 | connect( view, SIGNAL( dropped( QDropEvent* ) ), |
241 | SLOT( dropped( QDropEvent* ) ) ); | 241 | SLOT( dropped( QDropEvent* ) ) ); |
242 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); | 242 | connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | // If we found or created the view, raise it and refresh it | 246 | // If we found or created the view, raise it and refresh it |
247 | if ( view ) { | 247 | if ( view ) { |
248 | mActiveView = view; | 248 | mActiveView = view; |
249 | mViewWidgetStack->raiseWidget( view ); | 249 | mViewWidgetStack->raiseWidget( view ); |
250 | // Set the proper filter in the view. By setting the combo | 250 | // Set the proper filter in the view. By setting the combo |
251 | // box, the activated slot will be called, which will push | 251 | // box, the activated slot will be called, which will push |
252 | // the filter to the view and refresh it. | 252 | // the filter to the view and refresh it. |
253 | 253 | ||
254 | if ( view->defaultFilterType() == KAddressBookView::None ) { | 254 | if ( view->defaultFilterType() == KAddressBookView::None ) { |
255 | 255 | ||
256 | mActionSelectFilter->setCurrentItem( 0 ); | 256 | mActionSelectFilter->setCurrentItem( 0 ); |
257 | setActiveFilter( 0 ); | 257 | setActiveFilter( 0 ); |
258 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { | 258 | } else if ( view->defaultFilterType() == KAddressBookView::Active ) { |
259 | setActiveFilter( mActionSelectFilter->currentItem() ); | 259 | setActiveFilter( mActionSelectFilter->currentItem() ); |
260 | } else { | 260 | } else { |
261 | uint pos = filterPosition( view->defaultFilterName() ); | 261 | uint pos = filterPosition( view->defaultFilterName() ); |
262 | mActionSelectFilter->setCurrentItem( pos ); | 262 | mActionSelectFilter->setCurrentItem( pos ); |
263 | setActiveFilter( pos ); | 263 | setActiveFilter( pos ); |
264 | } | 264 | } |
265 | //US qDebug("ViewManager::setActiveView 6" ); | 265 | //US qDebug("ViewManager::setActiveView 6" ); |
266 | 266 | ||
267 | // Update the inc search widget to show the fields in the new active | 267 | // Update the inc search widget to show the fields in the new active |
268 | // view. | 268 | // view. |
269 | mCore->setSearchFields( mActiveView->fields() ); | 269 | mCore->setSearchFields( mActiveView->fields() ); |
270 | 270 | ||
271 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 271 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
272 | //US mActiveView->refresh(); | 272 | //US mActiveView->refresh(); |
273 | 273 | ||
274 | } | 274 | } |
275 | else | 275 | else |
276 | { | 276 | { |
277 | qDebug("ViewManager::setActiveView: unable to find view" ); | 277 | qDebug("ViewManager::setActiveView: unable to find view" ); |
278 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; | 278 | kdDebug(5720) << "ViewManager::setActiveView: unable to find view\n"; |
279 | } | 279 | } |
280 | } | 280 | } |
281 | 281 | ||
282 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 282 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
283 | void ViewManager::refreshView() | 283 | void ViewManager::refreshView() |
284 | { | 284 | { |
285 | refreshView( QString::null ); | 285 | refreshView( QString::null ); |
286 | } | 286 | } |
287 | 287 | ||
288 | void ViewManager::refreshView( const QString &uid ) | 288 | void ViewManager::refreshView( const QString &uid ) |
289 | { | 289 | { |
290 | if ( mActiveView ) | 290 | if ( mActiveView ) |
291 | mActiveView->refresh( uid ); | 291 | mActiveView->refresh( uid ); |
292 | } | 292 | } |
293 | 293 | ||
294 | void ViewManager::editView() | 294 | void ViewManager::editView() |
295 | { | 295 | { |
296 | if ( !mActiveView ) | 296 | if ( !mActiveView ) |
297 | return; | 297 | return; |
298 | 298 | ||
299 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); | 299 | ViewFactory *factory = mViewFactoryDict.find( mActiveView->type() ); |
300 | ViewConfigureWidget *wdg = 0; | 300 | ViewConfigureWidget *wdg = 0; |
301 | ViewConfigureDialog* dlg = 0; | 301 | ViewConfigureDialog* dlg = 0; |
302 | if ( factory ) { | 302 | if ( factory ) { |
303 | // Save the filters so the dialog has the latest set | 303 | // Save the filters so the dialog has the latest set |
304 | Filter::save( mCore->config(), "Filter", mFilterList ); | 304 | Filter::save( mCore->config(), "Filter", mFilterList ); |
305 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); | 305 | dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); |
306 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); | 306 | wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); |
307 | } else { | 307 | } else { |
308 | qDebug("ViewManager::editView()::cannot find viewfactory "); | 308 | qDebug("ViewManager::editView()::cannot find viewfactory "); |
309 | return; | 309 | return; |
310 | } | 310 | } |
311 | if ( wdg ) { | 311 | if ( wdg ) { |
312 | dlg->setWidget( wdg ); | 312 | dlg->setWidget( wdg ); |
313 | 313 | ||
314 | #ifndef DESKTOP_VERSION | 314 | #ifndef DESKTOP_VERSION |
315 | //dlg.setMaximumSize( 640, 480 ); | 315 | //dlg.setMaximumSize( 640, 480 ); |
316 | //dlg->setGeometry( 40,40, 400, 300); | 316 | //dlg->setGeometry( 40,40, 400, 300); |
317 | dlg->showMaximized(); | 317 | dlg->showMaximized(); |
318 | #endif | 318 | #endif |
319 | 319 | ||
320 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); | 320 | KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); |
321 | 321 | ||
322 | dlg->restoreSettings( mCore->config() ); | 322 | dlg->restoreSettings( mCore->config() ); |
323 | 323 | ||
324 | if ( dlg->exec() ) { | 324 | if ( dlg->exec() ) { |
325 | dlg->saveSettings( mCore->config() ); | 325 | dlg->saveSettings( mCore->config() ); |
326 | mActiveView->readConfig( mCore->config() ); | 326 | mActiveView->readConfig( mCore->config() ); |
327 | 327 | ||
328 | // Set the proper filter in the view. By setting the combo | 328 | // Set the proper filter in the view. By setting the combo |
329 | // box, the activated slot will be called, which will push | 329 | // box, the activated slot will be called, which will push |
330 | // the filter to the view and refresh it. | 330 | // the filter to the view and refresh it. |
331 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { | 331 | if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { |
332 | mActionSelectFilter->setCurrentItem( 0 ); | 332 | mActionSelectFilter->setCurrentItem( 0 ); |
333 | setActiveFilter( 0 ); | 333 | setActiveFilter( 0 ); |
334 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { | 334 | } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { |
335 | setActiveFilter( mActionSelectFilter->currentItem() ); | 335 | setActiveFilter( mActionSelectFilter->currentItem() ); |
336 | } else { | 336 | } else { |
337 | uint pos = filterPosition( mActiveView->defaultFilterName() ); | 337 | uint pos = filterPosition( mActiveView->defaultFilterName() ); |
338 | mActionSelectFilter->setCurrentItem( pos ); | 338 | mActionSelectFilter->setCurrentItem( pos ); |
339 | setActiveFilter( pos ); | 339 | setActiveFilter( pos ); |
340 | } | 340 | } |
341 | mCore->setSearchFields( mActiveView->fields() ); | 341 | mCore->setSearchFields( mActiveView->fields() ); |
342 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() | 342 | //US performance optimization. setActiveFilter calls also mActiveView->refresh() |
343 | //US mActiveView->refresh(); | 343 | //US mActiveView->refresh(); |
344 | 344 | ||
345 | 345 | ||
346 | //US this is a bugfix, that we get notified if we change a views configuration | 346 | //US this is a bugfix, that we get notified if we change a views configuration |
347 | emit modified(); | 347 | emit modified(); |
348 | 348 | ||
349 | } | 349 | } |
350 | 350 | ||
351 | } | 351 | } |
352 | delete dlg; | 352 | delete dlg; |
353 | } | 353 | } |
354 | 354 | ||
355 | void ViewManager::deleteView() | 355 | void ViewManager::deleteView() |
356 | { | 356 | { |
357 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) | 357 | QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) |
358 | .arg( mActiveView->caption() ); | 358 | .arg( mActiveView->caption() ); |
359 | QString caption = i18n( "Confirm Delete" ); | 359 | QString caption = i18n( "Confirm Delete" ); |
360 | 360 | ||
361 | 361 | ||
362 | if (QMessageBox::information( this, caption, | 362 | if (QMessageBox::information( this, caption, |
363 | text, | 363 | text, |
364 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) | 364 | i18n("Yes!"), i18n("No"), 0, 0 ) == 0) |
365 | { | 365 | { |
366 | mViewNameList.remove( mActiveView->caption() ); | 366 | mViewNameList.remove( mActiveView->caption() ); |
367 | 367 | ||
368 | // remove the view from the config file | 368 | // remove the view from the config file |
369 | KConfig *config = mCore->config(); | 369 | KConfig *config = mCore->config(); |
370 | config->deleteGroup( mActiveView->caption() ); | 370 | config->deleteGroup( mActiveView->caption() ); |
371 | 371 | ||
372 | mViewDict.remove( mActiveView->caption() ); | 372 | mViewDict.remove( mActiveView->caption() ); |
373 | mActiveView = 0; | 373 | mActiveView = 0; |
374 | 374 | ||
375 | // we are in an invalid state now, but that should be fixed after | 375 | // we are in an invalid state now, but that should be fixed after |
376 | // we emit the signal | 376 | // we emit the signal |
377 | mActionSelectView->setItems( mViewNameList ); | 377 | mActionSelectView->setItems( mViewNameList ); |
378 | if ( mViewNameList.count() > 0 ) { | 378 | if ( mViewNameList.count() > 0 ) { |
379 | mActionSelectView->setCurrentItem( 0 ); | 379 | mActionSelectView->setCurrentItem( 0 ); |
380 | setActiveView( mViewNameList[ 0 ] ); | 380 | setActiveView( mViewNameList[ 0 ] ); |
381 | } | 381 | } |
382 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 382 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | 385 | ||
386 | void ViewManager::addView() | 386 | void ViewManager::addView() |
387 | { | 387 | { |
388 | AddViewDialog dialog( &mViewFactoryDict, this ); | 388 | AddViewDialog dialog( &mViewFactoryDict, this ); |
389 | 389 | ||
390 | if ( dialog.exec() ) { | 390 | if ( dialog.exec() ) { |
391 | QString newName = dialog.viewName(); | 391 | QString newName = dialog.viewName(); |
392 | QString type = dialog.viewType(); | 392 | QString type = dialog.viewType(); |
393 | 393 | ||
394 | // Check for name conflicts | 394 | // Check for name conflicts |
395 | bool firstConflict = true; | 395 | bool firstConflict = true; |
396 | int numTries = 1; | 396 | int numTries = 1; |
397 | while ( mViewNameList.contains( newName ) > 0 ) { | 397 | while ( mViewNameList.contains( newName ) > 0 ) { |
398 | if ( !firstConflict ) { | 398 | if ( !firstConflict ) { |
399 | newName = newName.left( newName.length() - 4 ); | 399 | newName = newName.left( newName.length() - 4 ); |
400 | firstConflict = false; | 400 | firstConflict = false; |
401 | } | 401 | } |
402 | 402 | ||
403 | newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); | 403 | newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); |
404 | numTries++; | 404 | numTries++; |
405 | } | 405 | } |
406 | 406 | ||
407 | // Add the new one to the list | 407 | // Add the new one to the list |
408 | mViewNameList.append( newName ); | 408 | mViewNameList.append( newName ); |
409 | 409 | ||
410 | // write the view to the config file, | 410 | // write the view to the config file, |
411 | KConfig *config = mCore->config(); | 411 | KConfig *config = mCore->config(); |
412 | 412 | ||
413 | config->deleteGroup( newName ); | 413 | config->deleteGroup( newName ); |
414 | 414 | ||
415 | KConfigGroupSaver saver( config, newName ); | 415 | KConfigGroupSaver saver( config, newName ); |
416 | 416 | ||
417 | config->writeEntry( "Type", type ); | 417 | config->writeEntry( "Type", type ); |
418 | 418 | ||
419 | // try to set the active view | 419 | // try to set the active view |
420 | mActionSelectView->setItems( mViewNameList ); | 420 | mActionSelectView->setItems( mViewNameList ); |
421 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); | 421 | mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); |
422 | setActiveView( newName ); | 422 | setActiveView( newName ); |
423 | 423 | ||
424 | editView(); | 424 | editView(); |
425 | 425 | ||
426 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 426 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
427 | } | 427 | } |
428 | } | 428 | } |
429 | 429 | ||
430 | void ViewManager::createViewFactories() | 430 | void ViewManager::createViewFactories() |
431 | { | 431 | { |
432 | #ifndef KAB_EMBEDDED | 432 | #ifndef KAB_EMBEDDED |
433 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); | 433 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); |
434 | KTrader::OfferList::ConstIterator it; | 434 | KTrader::OfferList::ConstIterator it; |
435 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 435 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
436 | if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) | 436 | if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) |
437 | continue; | 437 | continue; |
438 | 438 | ||
439 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); | 439 | KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); |
440 | 440 | ||
441 | if ( !factory ) { | 441 | if ( !factory ) { |
442 | kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; | 442 | kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; |
443 | continue; | 443 | continue; |
444 | } | 444 | } |
445 | 445 | ||
446 | ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); | 446 | ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); |
447 | 447 | ||
448 | if ( !viewFactory ) { | 448 | if ( !viewFactory ) { |
449 | kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; | 449 | kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; |
450 | continue; | 450 | continue; |
451 | } | 451 | } |
452 | 452 | ||
453 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 453 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
454 | } | 454 | } |
455 | 455 | ||
456 | #else //KAB_EMBEDDED | 456 | #else //KAB_EMBEDDED |
457 | ViewFactory* viewFactory = new IconViewFactory(); | 457 | ViewFactory* viewFactory = new IconViewFactory(); |
458 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 458 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
459 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 459 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
460 | 460 | ||
461 | viewFactory = new TableViewFactory(); | 461 | viewFactory = new TableViewFactory(); |
462 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 462 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
463 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 463 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
464 | 464 | ||
465 | viewFactory = new CardViewFactory(); | 465 | viewFactory = new CardViewFactory(); |
466 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 466 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
467 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 467 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
468 | 468 | ||
469 | #endif //KAB_EMBEDDED | 469 | #endif //KAB_EMBEDDED |
470 | 470 | ||
471 | } | 471 | } |
472 | 472 | ||
473 | void ViewManager::dropped( QDropEvent *e ) | 473 | void ViewManager::dropped( QDropEvent *e ) |
474 | { | 474 | { |
475 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; | 475 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; |
476 | 476 | ||
477 | #ifndef KAB_EMBEDDED | 477 | #ifndef KAB_EMBEDDED |
478 | 478 | ||
479 | QString clipText, vcards; | 479 | QString clipText, vcards; |
480 | KURL::List urls; | 480 | KURL::List urls; |
481 | 481 | ||
482 | if ( KURLDrag::decode( e, urls) ) { | 482 | if ( KURLDrag::decode( e, urls) ) { |
483 | KURL::List::Iterator it = urls.begin(); | 483 | KURL::List::Iterator it = urls.begin(); |
484 | int c = urls.count(); | 484 | int c = urls.count(); |
485 | if ( c > 1 ) { | 485 | if ( c > 1 ) { |
486 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); | 486 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); |
487 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { | 487 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { |
488 | for ( ; it != urls.end(); ++it ) | 488 | for ( ; it != urls.end(); ++it ) |
489 | emit urlDropped( *it ); | 489 | emit urlDropped( *it ); |
490 | } | 490 | } |
491 | } else if ( c == 1 ) | 491 | } else if ( c == 1 ) |
492 | emit urlDropped( *it ); | 492 | emit urlDropped( *it ); |
493 | } else if ( KVCardDrag::decode( e, vcards ) ) { | 493 | } else if ( KVCardDrag::decode( e, vcards ) ) { |
494 | KABC::Addressee addr; | 494 | KABC::Addressee addr; |
495 | KABC::VCardConverter converter; | 495 | KABC::VCardConverter converter; |
496 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); | 496 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); |
497 | QStringList::Iterator it; | 497 | QStringList::Iterator it; |
498 | for ( it = list.begin(); it != list.end(); ++it ) { | 498 | for ( it = list.begin(); it != list.end(); ++it ) { |
499 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { | 499 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { |
500 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); | 500 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); |
501 | if ( a.isEmpty() ) { | 501 | if ( a.isEmpty() ) { |
502 | mCore->addressBook()->insertAddressee( addr ); | 502 | mCore->addressBook()->insertAddressee( addr ); |
503 | emit modified(); | 503 | emit modified(); |
504 | } | 504 | } |
505 | } | 505 | } |
506 | } | 506 | } |
507 | 507 | ||
508 | mActiveView->refresh(); | 508 | mActiveView->refresh(); |
509 | } | 509 | } |
510 | #else //KAB_EMBEDDED | 510 | #else //KAB_EMBEDDED |
511 | qDebug("ViewManager::dropped() has to be changed!!" ); | 511 | qDebug("ViewManager::dropped() has to be changed!!" ); |
512 | #endif //KAB_EMBEDDED | 512 | #endif //KAB_EMBEDDED |
513 | 513 | ||
514 | } | 514 | } |
515 | 515 | ||
516 | void ViewManager::startDrag() | 516 | void ViewManager::startDrag() |
517 | { | 517 | { |
518 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; | 518 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; |
519 | 519 | ||
520 | #ifndef KAB_EMBEDDED | 520 | #ifndef KAB_EMBEDDED |
521 | 521 | ||
522 | // Get the list of all the selected addressees | 522 | // Get the list of all the selected addressees |
523 | KABC::Addressee::List addrList; | 523 | KABC::Addressee::List addrList; |
524 | QStringList uidList = selectedUids(); | 524 | QStringList uidList = selectedUids(); |
525 | QStringList::Iterator iter; | 525 | QStringList::Iterator iter; |
526 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) | 526 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) |
527 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); | 527 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); |
528 | 528 | ||
529 | KMultipleDrag *drag = new KMultipleDrag( this ); | 529 | KMultipleDrag *drag = new KMultipleDrag( this ); |
530 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); | 530 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); |
531 | KABC::Addressee::List::Iterator it; | 531 | KABC::Addressee::List::Iterator it; |
532 | QStringList vcards; | 532 | QStringList vcards; |
533 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { | 533 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { |
534 | QString vcard = QString::null; | 534 | QString vcard = QString::null; |
535 | KABC::VCardConverter converter; | 535 | KABC::VCardConverter converter; |
536 | if ( converter.addresseeToVCard( *it, vcard ) ) | 536 | if ( converter.addresseeToVCard( *it, vcard ) ) |
537 | vcards.append( vcard ); | 537 | vcards.append( vcard ); |
538 | } | 538 | } |
539 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); | 539 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); |
540 | 540 | ||
541 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); | 541 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); |
542 | drag->dragCopy(); | 542 | drag->dragCopy(); |
543 | 543 | ||
544 | #else //KAB_EMBEDDED | 544 | #else //KAB_EMBEDDED |
545 | qDebug("ViewManager::startDrag() has to be changed!!" ); | 545 | qDebug("ViewManager::startDrag() has to be changed!!" ); |
546 | #endif //KAB_EMBEDDED | 546 | #endif //KAB_EMBEDDED |
547 | 547 | ||
548 | } | 548 | } |
549 | void ViewManager::doSearch( const QString& s,KABC::Field *field ) | ||
550 | { | ||
551 | if ( mActiveView ) | ||
552 | mActiveView->doSearch( s, field ); | ||
549 | 553 | ||
554 | } | ||
550 | void ViewManager::setActiveFilter( int index ) | 555 | void ViewManager::setActiveFilter( int index ) |
551 | { | 556 | { |
552 | Filter currentFilter; | 557 | Filter currentFilter; |
553 | 558 | ||
554 | if ( ( index - 1 ) < 0 ) | 559 | if ( ( index - 1 ) < 0 ) |
555 | currentFilter = Filter(); | 560 | currentFilter = Filter(); |
556 | else | 561 | else |
557 | currentFilter = mFilterList[ index - 1 ]; | 562 | currentFilter = mFilterList[ index - 1 ]; |
558 | 563 | ||
559 | // Check if we have a view. Since the filter combo is created before | 564 | // Check if we have a view. Since the filter combo is created before |
560 | // the view, this slot could be called before there is a valid view. | 565 | // the view, this slot could be called before there is a valid view. |
561 | if ( mActiveView ) { | 566 | if ( mActiveView ) { |
562 | mActiveView->setFilter( currentFilter ); | 567 | mActiveView->setFilter( currentFilter ); |
563 | mActiveView->refresh(); | 568 | mActiveView->refresh(); |
564 | emit selected( QString::null ); | 569 | emit selected( QString::null ); |
565 | } | 570 | } |
566 | } | 571 | } |
567 | 572 | ||
568 | void ViewManager::configureFilters() | 573 | void ViewManager::configureFilters() |
569 | { | 574 | { |
570 | FilterDialog dlg( this ); | 575 | FilterDialog dlg( this ); |
571 | 576 | ||
572 | dlg.setFilters( mFilterList ); | 577 | dlg.setFilters( mFilterList ); |
573 | 578 | ||
574 | if ( dlg.exec() ) | 579 | if ( dlg.exec() ) |
575 | mFilterList = dlg.filters(); | 580 | mFilterList = dlg.filters(); |
576 | 581 | ||
577 | uint pos = mActionSelectFilter->currentItem(); | 582 | uint pos = mActionSelectFilter->currentItem(); |
578 | mActionSelectFilter->setItems( filterNames() ); | 583 | mActionSelectFilter->setItems( filterNames() ); |
579 | mActionSelectFilter->setCurrentItem( pos ); | 584 | mActionSelectFilter->setCurrentItem( pos ); |
580 | setActiveFilter( pos ); | 585 | setActiveFilter( pos ); |
581 | } | 586 | } |
582 | 587 | ||
583 | QStringList ViewManager::filterNames() const | 588 | QStringList ViewManager::filterNames() const |
584 | { | 589 | { |
585 | QStringList names( i18n( "No Filter" ) ); | 590 | QStringList names( i18n( "No Filter" ) ); |
586 | 591 | ||
587 | Filter::List::ConstIterator it; | 592 | Filter::List::ConstIterator it; |
588 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) | 593 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) |
589 | names.append( (*it).name() ); | 594 | names.append( (*it).name() ); |
590 | 595 | ||
591 | return names; | 596 | return names; |
592 | } | 597 | } |
593 | 598 | ||
594 | int ViewManager::filterPosition( const QString &name ) const | 599 | int ViewManager::filterPosition( const QString &name ) const |
595 | { | 600 | { |
596 | int pos = 0; | 601 | int pos = 0; |
597 | 602 | ||
598 | Filter::List::ConstIterator it; | 603 | Filter::List::ConstIterator it; |
599 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) | 604 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) |
600 | if ( name == (*it).name() ) | 605 | if ( name == (*it).name() ) |
601 | return pos + 1; | 606 | return pos + 1; |
602 | 607 | ||
603 | return 0; | 608 | return 0; |
604 | } | 609 | } |
605 | 610 | ||
606 | void ViewManager::initActions() | 611 | void ViewManager::initActions() |
607 | { | 612 | { |
608 | //US <ActionList name="view_loadedviews"/> | 613 | //US <ActionList name="view_loadedviews"/> |
609 | //US <Separator/> | 614 | //US <Separator/> |
610 | 615 | ||
611 | #ifdef KAB_EMBEDDED | 616 | #ifdef KAB_EMBEDDED |
612 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); | 617 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); |
613 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); | 618 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); |
614 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); | 619 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); |
615 | #endif //KAB_EMBEDDED | 620 | #endif //KAB_EMBEDDED |
616 | 621 | ||
617 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); | 622 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); |
618 | #if KDE_VERSION >= 309 | 623 | #if KDE_VERSION >= 309 |
619 | mActionSelectView->setMenuAccelsEnabled( false ); | 624 | mActionSelectView->setMenuAccelsEnabled( false ); |
620 | #endif | 625 | #endif |
621 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), | 626 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), |
622 | SLOT( setActiveView( const QString& ) ) ); | 627 | SLOT( setActiveView( const QString& ) ) ); |
623 | 628 | ||
624 | 629 | ||
625 | #ifdef KAB_EMBEDDED | 630 | #ifdef KAB_EMBEDDED |
626 | mActionSelectView->plug(viewmenu); | 631 | mActionSelectView->plug(viewmenu); |
627 | viewmenu->insertSeparator(); | 632 | viewmenu->insertSeparator(); |
628 | #endif //KAB_EMBEDDED | 633 | #endif //KAB_EMBEDDED |
629 | 634 | ||
630 | KAction *action; | 635 | KAction *action; |
631 | 636 | ||
632 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, | 637 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, |
633 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); | 638 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); |
634 | #ifndef KAB_EMBEDDED | 639 | #ifndef KAB_EMBEDDED |
635 | action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); | 640 | action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); |
636 | #else //KAB_EMBEDDED | 641 | #else //KAB_EMBEDDED |
637 | action->plug(viewmenu); | 642 | action->plug(viewmenu); |
638 | #endif //KAB_EMBEDDED | 643 | #endif //KAB_EMBEDDED |
639 | 644 | ||
640 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, | 645 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, |
641 | SLOT( addView() ), mCore->actionCollection(), "view_add" ); | 646 | SLOT( addView() ), mCore->actionCollection(), "view_add" ); |
642 | #ifndef KAB_EMBEDDED | 647 | #ifndef KAB_EMBEDDED |
643 | action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); | 648 | action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); |
644 | #else //KAB_EMBEDDED | 649 | #else //KAB_EMBEDDED |
645 | action->plug(viewmenu); | 650 | action->plug(viewmenu); |
646 | #endif //KAB_EMBEDDED | 651 | #endif //KAB_EMBEDDED |
647 | 652 | ||
648 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, | 653 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, |
649 | this, SLOT( deleteView() ), | 654 | this, SLOT( deleteView() ), |
650 | mCore->actionCollection(), "view_delete" ); | 655 | mCore->actionCollection(), "view_delete" ); |
651 | #ifndef KAB_EMBEDDED | 656 | #ifndef KAB_EMBEDDED |
652 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); | 657 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); |
653 | #else //KAB_EMBEDDED | 658 | #else //KAB_EMBEDDED |
654 | mActionDeleteView->plug(viewmenu); | 659 | mActionDeleteView->plug(viewmenu); |
655 | viewmenu->insertSeparator(); | 660 | viewmenu->insertSeparator(); |
656 | #endif //KAB_EMBEDDED | 661 | #endif //KAB_EMBEDDED |
657 | 662 | ||
658 | #ifndef KAB_EMBEDDED | 663 | #ifndef KAB_EMBEDDED |
659 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, | 664 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, |
660 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), | 665 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), |
661 | "view_refresh" ); | 666 | "view_refresh" ); |
662 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); | 667 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); |
663 | #else //KAB_EMBEDDED | 668 | #else //KAB_EMBEDDED |
664 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, | 669 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, |
665 | SLOT( refreshView()), mCore->actionCollection(), | 670 | SLOT( refreshView()), mCore->actionCollection(), |
666 | "view_refresh" ); | 671 | "view_refresh" ); |
667 | action->plug(viewmenu); | 672 | action->plug(viewmenu); |
668 | viewmenu->insertSeparator(); | 673 | viewmenu->insertSeparator(); |
669 | #endif //KAB_EMBEDDED | 674 | #endif //KAB_EMBEDDED |
670 | 675 | ||
671 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, | 676 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, |
672 | SLOT( configureFilters() ), mCore->actionCollection(), | 677 | SLOT( configureFilters() ), mCore->actionCollection(), |
673 | "options_edit_filters" ); | 678 | "options_edit_filters" ); |
674 | 679 | ||
675 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); | 680 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); |
676 | 681 | ||
677 | #if KDE_VERSION >= 309 | 682 | #if KDE_VERSION >= 309 |
678 | mActionSelectFilter->setMenuAccelsEnabled( false ); | 683 | mActionSelectFilter->setMenuAccelsEnabled( false ); |
679 | #endif | 684 | #endif |
680 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), | 685 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), |
681 | SLOT( setActiveFilter( int ) ) ); | 686 | SLOT( setActiveFilter( int ) ) ); |
682 | 687 | ||
683 | #ifdef KAB_EMBEDDED | 688 | #ifdef KAB_EMBEDDED |
684 | action->plug(settingsmenu); | 689 | action->plug(settingsmenu); |
685 | mActionSelectFilter->plug(viewmenu); | 690 | mActionSelectFilter->plug(viewmenu); |
686 | #endif //KAB_EMBEDDED | 691 | #endif //KAB_EMBEDDED |
687 | 692 | ||
688 | } | 693 | } |
689 | 694 | ||
690 | void ViewManager::initGUI() | 695 | void ViewManager::initGUI() |
691 | { | 696 | { |
692 | QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); | 697 | QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); |
693 | mViewWidgetStack = new QWidgetStack( this ); | 698 | mViewWidgetStack = new QWidgetStack( this ); |
694 | layout->addWidget( mViewWidgetStack ); | 699 | layout->addWidget( mViewWidgetStack ); |
695 | } | 700 | } |
696 | 701 | ||
697 | #ifndef KAB_EMBEDDED | 702 | #ifndef KAB_EMBEDDED |
698 | #include "viewmanager.moc" | 703 | #include "viewmanager.moc" |
699 | #endif //KAB_EMBEDDED | 704 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h index 97c2275..6def6b6 100644 --- a/kaddressbook/viewmanager.h +++ b/kaddressbook/viewmanager.h | |||
@@ -1,153 +1,154 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
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 VIEWMANAGER_H | 24 | #ifndef VIEWMANAGER_H |
25 | #define VIEWMANAGER_H | 25 | #define VIEWMANAGER_H |
26 | 26 | ||
27 | #include <qwidget.h> | 27 | #include <qwidget.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | #include <kaddressbookview.h> | 29 | #include <kaddressbookview.h> |
30 | #include <qdict.h> | 30 | #include <qdict.h> |
31 | 31 | ||
32 | class KAction; | 32 | class KAction; |
33 | class KSelectAction; | 33 | class KSelectAction; |
34 | 34 | ||
35 | class KABCore; | 35 | class KABCore; |
36 | class QWidgetStack; | 36 | class QWidgetStack; |
37 | class QDropEvent; | 37 | class QDropEvent; |
38 | 38 | ||
39 | namespace KABC { class AddressBook; } | 39 | namespace KABC { class AddressBook; } |
40 | 40 | ||
41 | /** | 41 | /** |
42 | The view manager manages the views and everything related to them. The | 42 | The view manager manages the views and everything related to them. The |
43 | manager will load the views at startup and display a view when told to | 43 | manager will load the views at startup and display a view when told to |
44 | make one active. | 44 | make one active. |
45 | 45 | ||
46 | The view manager will also create and manage all dialogs directly related to | 46 | The view manager will also create and manage all dialogs directly related to |
47 | views (ie: AddView, ConfigureView, DeleteView, etc). | 47 | views (ie: AddView, ConfigureView, DeleteView, etc). |
48 | */ | 48 | */ |
49 | class ViewManager : public QWidget | 49 | class ViewManager : public QWidget |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | public: | 52 | public: |
53 | ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); | 53 | ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); |
54 | ~ViewManager(); | 54 | ~ViewManager(); |
55 | 55 | ||
56 | void restoreSettings(); | 56 | void restoreSettings(); |
57 | void saveSettings(); | 57 | void saveSettings(); |
58 | void doSearch( const QString& s ,KABC::Field *field ); | ||
58 | 59 | ||
59 | void unloadViews(); | 60 | void unloadViews(); |
60 | KSelectAction * getFilterAction() { return mActionSelectFilter; } | 61 | KSelectAction * getFilterAction() { return mActionSelectFilter; } |
61 | 62 | ||
62 | QStringList selectedUids() const; | 63 | QStringList selectedUids() const; |
63 | QStringList selectedEmails() const; | 64 | QStringList selectedEmails() const; |
64 | KABC::Addressee::List selectedAddressees() const; | 65 | KABC::Addressee::List selectedAddressees() const; |
65 | void setListSelected(QStringList); | 66 | void setListSelected(QStringList); |
66 | 67 | ||
67 | public slots: | 68 | public slots: |
68 | 69 | ||
69 | //US void setSelected( const QString &uid = QString::null, bool selected = true ); | 70 | //US void setSelected( const QString &uid = QString::null, bool selected = true ); |
70 | void setSelected( const QString &uid, bool); | 71 | void setSelected( const QString &uid, bool); |
71 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 72 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
72 | void setSelected(); | 73 | void setSelected(); |
73 | 74 | ||
74 | 75 | ||
75 | 76 | ||
76 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 77 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
77 | void refreshView(); | 78 | void refreshView(); |
78 | void refreshView( const QString &uid); | 79 | void refreshView( const QString &uid); |
79 | 80 | ||
80 | void editView(); | 81 | void editView(); |
81 | void deleteView(); | 82 | void deleteView(); |
82 | void addView(); | 83 | void addView(); |
83 | 84 | ||
84 | protected slots: | 85 | protected slots: |
85 | /** | 86 | /** |
86 | Called whenever the user drops something in the active view. | 87 | Called whenever the user drops something in the active view. |
87 | This method will try to decode what was dropped, and if it was | 88 | This method will try to decode what was dropped, and if it was |
88 | a valid addressee, add it to the addressbook. | 89 | a valid addressee, add it to the addressbook. |
89 | */ | 90 | */ |
90 | void dropped( QDropEvent* ); | 91 | void dropped( QDropEvent* ); |
91 | 92 | ||
92 | /** | 93 | /** |
93 | Called whenever the user attempts to start a drag in the view. | 94 | Called whenever the user attempts to start a drag in the view. |
94 | This method will convert all the selected addressees into text (vcard) | 95 | This method will convert all the selected addressees into text (vcard) |
95 | and create a drag object. | 96 | and create a drag object. |
96 | */ | 97 | */ |
97 | void startDrag(); | 98 | void startDrag(); |
98 | 99 | ||
99 | signals: | 100 | signals: |
100 | /** | 101 | /** |
101 | Emitted whenever the user selects an entry in the view. | 102 | Emitted whenever the user selects an entry in the view. |
102 | */ | 103 | */ |
103 | void selected( const QString &uid ); | 104 | void selected( const QString &uid ); |
104 | void deleteRequest( ); | 105 | void deleteRequest( ); |
105 | 106 | ||
106 | /** | 107 | /** |
107 | Emitted whenever the user activates an entry in the view. | 108 | Emitted whenever the user activates an entry in the view. |
108 | */ | 109 | */ |
109 | void executed( const QString &uid ); | 110 | void executed( const QString &uid ); |
110 | 111 | ||
111 | /** | 112 | /** |
112 | Emitted whenever the address book is modified in some way. | 113 | Emitted whenever the address book is modified in some way. |
113 | */ | 114 | */ |
114 | void modified(); | 115 | void modified(); |
115 | 116 | ||
116 | /** | 117 | /** |
117 | Emitted whenever a url is dragged on a view. | 118 | Emitted whenever a url is dragged on a view. |
118 | */ | 119 | */ |
119 | void urlDropped( const KURL& ); | 120 | void urlDropped( const KURL& ); |
120 | 121 | ||
121 | private slots: | 122 | private slots: |
122 | void setActiveView( const QString &name ); | 123 | void setActiveView( const QString &name ); |
123 | void setActiveFilter( int index ); | 124 | void setActiveFilter( int index ); |
124 | void configureFilters(); | 125 | void configureFilters(); |
125 | 126 | ||
126 | private: | 127 | private: |
127 | void createViewFactories(); | 128 | void createViewFactories(); |
128 | QStringList filterNames() const; | 129 | QStringList filterNames() const; |
129 | int filterPosition( const QString &name ) const; | 130 | int filterPosition( const QString &name ) const; |
130 | QStringList viewNames() const; | 131 | QStringList viewNames() const; |
131 | int viewPosition( const QString &name ) const; | 132 | int viewPosition( const QString &name ) const; |
132 | void initActions(); | 133 | void initActions(); |
133 | void initGUI(); | 134 | void initGUI(); |
134 | 135 | ||
135 | KABCore *mCore; | 136 | KABCore *mCore; |
136 | 137 | ||
137 | Filter mCurrentFilter; | 138 | Filter mCurrentFilter; |
138 | Filter::List mFilterList; | 139 | Filter::List mFilterList; |
139 | 140 | ||
140 | QDict<KAddressBookView> mViewDict; | 141 | QDict<KAddressBookView> mViewDict; |
141 | QDict<ViewFactory> mViewFactoryDict; | 142 | QDict<ViewFactory> mViewFactoryDict; |
142 | QStringList mViewNameList; | 143 | QStringList mViewNameList; |
143 | 144 | ||
144 | QWidgetStack *mViewWidgetStack; | 145 | QWidgetStack *mViewWidgetStack; |
145 | KAddressBookView *mActiveView; | 146 | KAddressBookView *mActiveView; |
146 | 147 | ||
147 | KAction *mActionDeleteView; | 148 | KAction *mActionDeleteView; |
148 | KSelectAction *mActionSelectFilter; | 149 | KSelectAction *mActionSelectFilter; |
149 | KSelectAction *mActionSelectView; | 150 | KSelectAction *mActionSelectView; |
150 | 151 | ||
151 | }; | 152 | }; |
152 | 153 | ||
153 | #endif | 154 | #endif |
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 239429f..49c0691 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp | |||
@@ -1,394 +1,445 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
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 <qdragobject.h> | 24 | #include <qdragobject.h> |
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qiconview.h> | 26 | #include <qiconview.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qstringlist.h> | 28 | #include <qstringlist.h> |
29 | 29 | ||
30 | #include <kabc/addressbook.h> | 30 | #include <kabc/addressbook.h> |
31 | #include <kabc/addressee.h> | 31 | #include <kabc/addressee.h> |
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <kdebug.h> | 33 | #include <kdebug.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | 35 | ||
36 | #include "kabprefs.h" | 36 | #include "kabprefs.h" |
37 | #include "viewmanager.h" | 37 | #include "viewmanager.h" |
38 | 38 | ||
39 | #include "kaddressbookcardview.h" | 39 | #include "kaddressbookcardview.h" |
40 | 40 | ||
41 | #ifndef KAB_EMBEDDED | 41 | #ifndef KAB_EMBEDDED |
42 | extern "C" { | 42 | extern "C" { |
43 | void *init_libkaddrbk_cardview() | 43 | void *init_libkaddrbk_cardview() |
44 | { | 44 | { |
45 | return ( new CardViewFactory ); | 45 | return ( new CardViewFactory ); |
46 | } | 46 | } |
47 | } | 47 | } |
48 | #endif //KAB_EMBEDDED | 48 | #endif //KAB_EMBEDDED |
49 | 49 | ||
50 | //////////////////////////////// | 50 | //////////////////////////////// |
51 | // AddresseeCardViewItem (internal class) | 51 | // AddresseeCardViewItem (internal class) |
52 | class AddresseeCardViewItem : public CardViewItem | 52 | class AddresseeCardViewItem : public CardViewItem |
53 | { | 53 | { |
54 | public: | 54 | public: |
55 | AddresseeCardViewItem(const KABC::Field::List &fields, | 55 | AddresseeCardViewItem(const KABC::Field::List &fields, |
56 | bool showEmptyFields, | 56 | bool showEmptyFields, |
57 | KABC::AddressBook *doc, const KABC::Addressee &a, | 57 | KABC::AddressBook *doc, const KABC::Addressee &a, |
58 | CardView *parent) | 58 | CardView *parent) |
59 | : CardViewItem(parent, a.formattedName()), | 59 | : CardViewItem(parent, a.formattedName()), |
60 | mFields( fields ), mShowEmptyFields(showEmptyFields), | 60 | mFields( fields ), mShowEmptyFields(showEmptyFields), |
61 | mDocument(doc), mAddressee(a) | 61 | mDocument(doc), mAddressee(a) |
62 | { | 62 | { |
63 | if ( mFields.isEmpty() ) { | 63 | if ( mFields.isEmpty() ) { |
64 | mFields = KABC::Field::defaultFields(); | 64 | mFields = KABC::Field::defaultFields(); |
65 | } | 65 | } |
66 | refresh(); | 66 | refresh(); |
67 | } | 67 | } |
68 | 68 | ||
69 | const KABC::Addressee &addressee() const { return mAddressee; } | 69 | const KABC::Addressee &addressee() const { return mAddressee; } |
70 | 70 | ||
71 | void refresh() | 71 | void refresh() |
72 | { | 72 | { |
73 | // Update our addressee, since it may have changed elsewhere | 73 | // Update our addressee, since it may have changed elsewhere |
74 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 74 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
75 | 75 | ||
76 | if (!mAddressee.isEmpty()) | 76 | if (!mAddressee.isEmpty()) |
77 | { | 77 | { |
78 | clearFields(); | 78 | clearFields(); |
79 | 79 | ||
80 | // Try all the selected fields until we find one with text. | 80 | // Try all the selected fields until we find one with text. |
81 | // This will limit the number of unlabeled icons in the view | 81 | // This will limit the number of unlabeled icons in the view |
82 | KABC::Field::List::Iterator iter; | 82 | KABC::Field::List::Iterator iter; |
83 | for (iter = mFields.begin(); iter != mFields.end(); ++iter) | 83 | for (iter = mFields.begin(); iter != mFields.end(); ++iter) |
84 | { | 84 | { |
85 | // insert empty fields or not? not doing so saves a bit of memory and CPU | 85 | // insert empty fields or not? not doing so saves a bit of memory and CPU |
86 | // (during geometry calculations), but prevents having equally | 86 | // (during geometry calculations), but prevents having equally |
87 | // wide label columns in all cards, unless CardViewItem/CardView search | 87 | // wide label columns in all cards, unless CardViewItem/CardView search |
88 | // globally for the widest label. (anders) | 88 | // globally for the widest label. (anders) |
89 | //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) | 89 | //if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty()) |
90 | insertField((*iter)->label(), (*iter)->value( mAddressee )); | 90 | insertField((*iter)->label(), (*iter)->value( mAddressee )); |
91 | } | 91 | } |
92 | 92 | ||
93 | // We might want to make this the first field. hmm... -mpilone | 93 | // We might want to make this the first field. hmm... -mpilone |
94 | setCaption( mAddressee.realName() ); | 94 | setCaption( mAddressee.realName() ); |
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | private: | 98 | private: |
99 | KABC::Field::List mFields; | 99 | KABC::Field::List mFields; |
100 | bool mShowEmptyFields; | 100 | bool mShowEmptyFields; |
101 | KABC::AddressBook *mDocument; | 101 | KABC::AddressBook *mDocument; |
102 | KABC::Addressee mAddressee; | 102 | KABC::Addressee mAddressee; |
103 | }; | 103 | }; |
104 | 104 | ||
105 | /////////////////////////////// | 105 | /////////////////////////////// |
106 | // AddresseeCardView | 106 | // AddresseeCardView |
107 | 107 | ||
108 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) | 108 | AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) |
109 | : CardView(parent, name) | 109 | : CardView(parent, name) |
110 | { | 110 | { |
111 | setAcceptDrops(true); | 111 | setAcceptDrops(true); |
112 | } | 112 | } |
113 | 113 | ||
114 | AddresseeCardView::~AddresseeCardView() | 114 | AddresseeCardView::~AddresseeCardView() |
115 | { | 115 | { |
116 | } | 116 | } |
117 | 117 | ||
118 | |||
118 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) | 119 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) |
119 | { | 120 | { |
120 | #ifndef KAB_EMBEDDED | 121 | #ifndef KAB_EMBEDDED |
121 | if (QTextDrag::canDecode(e)) | 122 | if (QTextDrag::canDecode(e)) |
122 | e->accept(); | 123 | e->accept(); |
123 | #else //KAB_EMBEDDED | 124 | #else //KAB_EMBEDDED |
124 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); | 125 | qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); |
125 | #endif //KAB_EMBEDDED | 126 | #endif //KAB_EMBEDDED |
126 | } | 127 | } |
127 | 128 | ||
128 | void AddresseeCardView::dropEvent(QDropEvent *e) | 129 | void AddresseeCardView::dropEvent(QDropEvent *e) |
129 | { | 130 | { |
130 | emit addresseeDropped(e); | 131 | emit addresseeDropped(e); |
131 | } | 132 | } |
132 | 133 | ||
133 | void AddresseeCardView::startDrag() | 134 | void AddresseeCardView::startDrag() |
134 | { | 135 | { |
135 | emit startAddresseeDrag(); | 136 | emit startAddresseeDrag(); |
136 | } | 137 | } |
137 | 138 | ||
138 | 139 | ||
139 | /////////////////////////////// | 140 | /////////////////////////////// |
140 | // KAddressBookCardView | 141 | // KAddressBookCardView |
141 | 142 | ||
142 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, | 143 | KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, |
143 | QWidget *parent, const char *name ) | 144 | QWidget *parent, const char *name ) |
144 | : KAddressBookView( ab, parent, name ) | 145 | : KAddressBookView( ab, parent, name ) |
145 | { | 146 | { |
146 | mShowEmptyFields = false; | 147 | mShowEmptyFields = false; |
147 | 148 | ||
148 | // Init the GUI | 149 | // Init the GUI |
149 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 150 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); |
150 | 151 | ||
151 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); | 152 | mCardView = new AddresseeCardView(viewWidget(), "mCardView"); |
152 | mCardView->setSelectionMode(CardView::Extended); | 153 | mCardView->setSelectionMode(CardView::Extended); |
153 | layout->addWidget(mCardView); | 154 | layout->addWidget(mCardView); |
154 | 155 | ||
155 | // Connect up the signals | 156 | // Connect up the signals |
156 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 157 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
157 | this, SLOT(addresseeExecuted(CardViewItem *))); | 158 | this, SLOT(addresseeExecuted(CardViewItem *))); |
158 | connect(mCardView, SIGNAL(selectionChanged()), | 159 | connect(mCardView, SIGNAL(selectionChanged()), |
159 | this, SLOT(addresseeSelected())); | 160 | this, SLOT(addresseeSelected())); |
160 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), | 161 | connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), |
161 | this, SIGNAL(dropped(QDropEvent*))); | 162 | this, SIGNAL(dropped(QDropEvent*))); |
162 | connect(mCardView, SIGNAL(startAddresseeDrag()), | 163 | connect(mCardView, SIGNAL(startAddresseeDrag()), |
163 | this, SIGNAL(startDrag())); | 164 | this, SIGNAL(startDrag())); |
164 | } | 165 | } |
165 | 166 | ||
166 | KAddressBookCardView::~KAddressBookCardView() | 167 | KAddressBookCardView::~KAddressBookCardView() |
167 | { | 168 | { |
168 | } | 169 | } |
169 | 170 | ||
170 | void KAddressBookCardView::readConfig(KConfig *config) | 171 | void KAddressBookCardView::readConfig(KConfig *config) |
171 | { | 172 | { |
172 | KAddressBookView::readConfig(config); | 173 | KAddressBookView::readConfig(config); |
173 | 174 | ||
174 | // costum colors? | 175 | // costum colors? |
175 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 176 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
176 | { | 177 | { |
177 | QPalette p( mCardView->palette() ); | 178 | QPalette p( mCardView->palette() ); |
178 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 179 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
179 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 180 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
180 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 181 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
181 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 182 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
182 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 183 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
183 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 184 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
184 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 185 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
185 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 186 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
186 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 187 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
187 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 188 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
188 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 189 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
189 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 190 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
190 | mCardView->viewport()->setPalette( p ); | 191 | mCardView->viewport()->setPalette( p ); |
191 | } | 192 | } |
192 | else | 193 | else |
193 | { | 194 | { |
194 | // needed if turned off during a session. | 195 | // needed if turned off during a session. |
195 | mCardView->viewport()->setPalette( mCardView->palette() ); | 196 | mCardView->viewport()->setPalette( mCardView->palette() ); |
196 | } | 197 | } |
197 | 198 | ||
198 | //custom fonts? | 199 | //custom fonts? |
199 | QFont f( font() ); | 200 | QFont f( font() ); |
200 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 201 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
201 | { | 202 | { |
202 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); | 203 | mCardView->setFont( config->readFontEntry( "TextFont", &f) ); |
203 | f.setBold( true ); | 204 | f.setBold( true ); |
204 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 205 | mCardView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
205 | } | 206 | } |
206 | else | 207 | else |
207 | { | 208 | { |
208 | mCardView->setFont( f ); | 209 | mCardView->setFont( f ); |
209 | f.setBold( true ); | 210 | f.setBold( true ); |
210 | mCardView->setHeaderFont( f ); | 211 | mCardView->setHeaderFont( f ); |
211 | } | 212 | } |
212 | 213 | ||
213 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); | 214 | mCardView->setDrawCardBorder(config->readBoolEntry("DrawBorder", true)); |
214 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", | 215 | mCardView->setDrawColSeparators(config->readBoolEntry("DrawSeparators", |
215 | true)); | 216 | true)); |
216 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); | 217 | mCardView->setDrawFieldLabels(config->readBoolEntry("DrawFieldLabels",false)); |
217 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); | 218 | mShowEmptyFields = config->readBoolEntry("ShowEmptyFields", false); |
218 | 219 | ||
219 | mCardView->setShowEmptyFields( mShowEmptyFields ); | 220 | mCardView->setShowEmptyFields( mShowEmptyFields ); |
220 | 221 | ||
221 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); | 222 | mCardView->setItemWidth( config->readNumEntry( "ItemWidth", 200 ) ); |
222 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); | 223 | mCardView->setItemMargin( config->readNumEntry( "ItemMargin", 0 ) ); |
223 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); | 224 | mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) ); |
224 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); | 225 | mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) ); |
225 | 226 | ||
226 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), | 227 | disconnect(mCardView, SIGNAL(executed(CardViewItem *)), |
227 | this, SLOT(addresseeExecuted(CardViewItem *))); | 228 | this, SLOT(addresseeExecuted(CardViewItem *))); |
228 | 229 | ||
229 | if (KABPrefs::instance()->mHonorSingleClick) | 230 | if (KABPrefs::instance()->mHonorSingleClick) |
230 | connect(mCardView, SIGNAL(executed(CardViewItem *)), | 231 | connect(mCardView, SIGNAL(executed(CardViewItem *)), |
231 | this, SLOT(addresseeExecuted(CardViewItem *))); | 232 | this, SLOT(addresseeExecuted(CardViewItem *))); |
232 | else | 233 | else |
233 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), | 234 | connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)), |
234 | this, SLOT(addresseeExecuted(CardViewItem *))); | 235 | this, SLOT(addresseeExecuted(CardViewItem *))); |
235 | 236 | ||
236 | } | 237 | } |
237 | 238 | ||
238 | void KAddressBookCardView::writeConfig( KConfig *config ) | 239 | void KAddressBookCardView::writeConfig( KConfig *config ) |
239 | { | 240 | { |
240 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); | 241 | config->writeEntry( "ItemWidth", mCardView->itemWidth() ); |
241 | KAddressBookView::writeConfig( config ); | 242 | KAddressBookView::writeConfig( config ); |
242 | } | 243 | } |
243 | 244 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) | |
245 | { | ||
246 | mCardView->clear(); | ||
247 | if ( s.isEmpty() || s == "*" ) { | ||
248 | refresh(); | ||
249 | return; | ||
250 | } | ||
251 | QString pattern = s.lower()+"*"; | ||
252 | QRegExp re; | ||
253 | re.setWildcard(true); // most people understand these better. | ||
254 | re.setCaseSensitive(false); | ||
255 | re.setPattern( pattern ); | ||
256 | if (!re.isValid()) | ||
257 | return; | ||
258 | mCardView->viewport()->setUpdatesEnabled( false ); | ||
259 | KABC::Addressee::List addresseeList = addressees(); | ||
260 | KABC::Addressee::List::Iterator it; | ||
261 | if ( field ) { | ||
262 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
263 | #if QT_VERSION >= 300 | ||
264 | if (re.search(field->value( *it ).lower()) != -1) | ||
265 | #else | ||
266 | if (re.match(field->value( *it ).lower()) != -1) | ||
267 | #endif | ||
268 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | ||
269 | addressBook(), *it, mCardView); | ||
270 | |||
271 | } | ||
272 | } else { | ||
273 | KABC::Field::List fieldList = fields(); | ||
274 | KABC::Field::List::ConstIterator fieldIt; | ||
275 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
276 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | ||
277 | #if QT_VERSION >= 300 | ||
278 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | ||
279 | #else | ||
280 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | ||
281 | #endif | ||
282 | { | ||
283 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | ||
284 | addressBook(), *it, mCardView); | ||
285 | continue; | ||
286 | } | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | mCardView->viewport()->setUpdatesEnabled( true ); | ||
291 | mCardView->viewport()->update(); | ||
292 | // by default nothing is selected | ||
293 | emit selected(QString::null); | ||
294 | } | ||
244 | QStringList KAddressBookCardView::selectedUids() | 295 | QStringList KAddressBookCardView::selectedUids() |
245 | { | 296 | { |
246 | QStringList uidList; | 297 | QStringList uidList; |
247 | CardViewItem *item; | 298 | CardViewItem *item; |
248 | AddresseeCardViewItem *aItem; | 299 | AddresseeCardViewItem *aItem; |
249 | 300 | ||
250 | for (item = mCardView->firstItem(); item; item = item->nextItem()) | 301 | for (item = mCardView->firstItem(); item; item = item->nextItem()) |
251 | { | 302 | { |
252 | if (item->isSelected()) | 303 | if (item->isSelected()) |
253 | { | 304 | { |
254 | #ifndef KAB_EMBEDDED | 305 | #ifndef KAB_EMBEDDED |
255 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 306 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
256 | #else //KAB_EMBEDDED | 307 | #else //KAB_EMBEDDED |
257 | aItem = (AddresseeCardViewItem*)(item); | 308 | aItem = (AddresseeCardViewItem*)(item); |
258 | #endif //KAB_EMBEDDED | 309 | #endif //KAB_EMBEDDED |
259 | if (aItem) | 310 | if (aItem) |
260 | uidList << aItem->addressee().uid(); | 311 | uidList << aItem->addressee().uid(); |
261 | } | 312 | } |
262 | } | 313 | } |
263 | 314 | ||
264 | return uidList; | 315 | return uidList; |
265 | } | 316 | } |
266 | 317 | ||
267 | void KAddressBookCardView::refresh(QString uid) | 318 | void KAddressBookCardView::refresh(QString uid) |
268 | { | 319 | { |
269 | CardViewItem *item; | 320 | CardViewItem *item; |
270 | AddresseeCardViewItem *aItem; | 321 | AddresseeCardViewItem *aItem; |
271 | 322 | ||
272 | if (uid.isNull()) | 323 | if (uid.isNull()) |
273 | { | 324 | { |
274 | // Rebuild the view | 325 | // Rebuild the view |
275 | mCardView->viewport()->setUpdatesEnabled( false ); | 326 | mCardView->viewport()->setUpdatesEnabled( false ); |
276 | mCardView->clear(); | 327 | mCardView->clear(); |
277 | 328 | ||
278 | KABC::Addressee::List addresseeList = addressees(); | 329 | KABC::Addressee::List addresseeList = addressees(); |
279 | KABC::Addressee::List::Iterator iter; | 330 | KABC::Addressee::List::Iterator iter; |
280 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) | 331 | for (iter = addresseeList.begin(); iter != addresseeList.end(); ++iter) |
281 | { | 332 | { |
282 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, | 333 | aItem = new AddresseeCardViewItem(fields(), mShowEmptyFields, |
283 | addressBook(), *iter, mCardView); | 334 | addressBook(), *iter, mCardView); |
284 | } | 335 | } |
285 | mCardView->viewport()->setUpdatesEnabled( true ); | 336 | mCardView->viewport()->setUpdatesEnabled( true ); |
286 | mCardView->viewport()->update(); | 337 | mCardView->viewport()->update(); |
287 | 338 | ||
288 | // by default nothing is selected | 339 | // by default nothing is selected |
289 | emit selected(QString::null); | 340 | emit selected(QString::null); |
290 | } | 341 | } |
291 | else | 342 | else |
292 | { | 343 | { |
293 | // Try to find the one to refresh | 344 | // Try to find the one to refresh |
294 | bool found = false; | 345 | bool found = false; |
295 | for (item = mCardView->firstItem(); item && !found; | 346 | for (item = mCardView->firstItem(); item && !found; |
296 | item = item->nextItem()) | 347 | item = item->nextItem()) |
297 | { | 348 | { |
298 | #ifndef KAB_EMBEDDED | 349 | #ifndef KAB_EMBEDDED |
299 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 350 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
300 | #else //KAB_EMBEDDED | 351 | #else //KAB_EMBEDDED |
301 | aItem = (AddresseeCardViewItem*)(item); | 352 | aItem = (AddresseeCardViewItem*)(item); |
302 | #endif //KAB_EMBEDDED | 353 | #endif //KAB_EMBEDDED |
303 | 354 | ||
304 | if ((aItem) && (aItem->addressee().uid() == uid)) | 355 | if ((aItem) && (aItem->addressee().uid() == uid)) |
305 | { | 356 | { |
306 | aItem->refresh(); | 357 | aItem->refresh(); |
307 | found = true; | 358 | found = true; |
308 | } | 359 | } |
309 | } | 360 | } |
310 | } | 361 | } |
311 | } | 362 | } |
312 | 363 | ||
313 | void KAddressBookCardView::setSelected(QString uid, bool selected) | 364 | void KAddressBookCardView::setSelected(QString uid, bool selected) |
314 | { | 365 | { |
315 | CardViewItem *item; | 366 | CardViewItem *item; |
316 | AddresseeCardViewItem *aItem; | 367 | AddresseeCardViewItem *aItem; |
317 | 368 | ||
318 | if (uid.isNull()) | 369 | if (uid.isNull()) |
319 | { | 370 | { |
320 | mCardView->selectAll(selected); | 371 | mCardView->selectAll(selected); |
321 | } | 372 | } |
322 | else | 373 | else |
323 | { | 374 | { |
324 | bool found = false; | 375 | bool found = false; |
325 | for (item = mCardView->firstItem(); item && !found; | 376 | for (item = mCardView->firstItem(); item && !found; |
326 | item = item->nextItem()) | 377 | item = item->nextItem()) |
327 | { | 378 | { |
328 | #ifndef KAB_EMBEDDED | 379 | #ifndef KAB_EMBEDDED |
329 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 380 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
330 | #else //KAB_EMBEDDED | 381 | #else //KAB_EMBEDDED |
331 | aItem = (AddresseeCardViewItem*)(item); | 382 | aItem = (AddresseeCardViewItem*)(item); |
332 | #endif //KAB_EMBEDDED | 383 | #endif //KAB_EMBEDDED |
333 | 384 | ||
334 | if ((aItem) && (aItem->addressee().uid() == uid)) | 385 | if ((aItem) && (aItem->addressee().uid() == uid)) |
335 | { | 386 | { |
336 | mCardView->setSelected(aItem, selected); | 387 | mCardView->setSelected(aItem, selected); |
337 | mCardView->ensureItemVisible(item); | 388 | mCardView->ensureItemVisible(item); |
338 | found = true; | 389 | found = true; |
339 | } | 390 | } |
340 | } | 391 | } |
341 | } | 392 | } |
342 | } | 393 | } |
343 | 394 | ||
344 | //US added an additional method without parameter | 395 | //US added an additional method without parameter |
345 | void KAddressBookCardView::setSelected() | 396 | void KAddressBookCardView::setSelected() |
346 | { | 397 | { |
347 | setSelected(QString::null, true); | 398 | setSelected(QString::null, true); |
348 | } | 399 | } |
349 | 400 | ||
350 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) | 401 | void KAddressBookCardView::addresseeExecuted(CardViewItem *item) |
351 | { | 402 | { |
352 | #ifndef KAB_EMBEDDED | 403 | #ifndef KAB_EMBEDDED |
353 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 404 | AddresseeCardViewItem *aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
354 | #else //KAB_EMBEDDED | 405 | #else //KAB_EMBEDDED |
355 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); | 406 | AddresseeCardViewItem *aItem = (AddresseeCardViewItem*)(item); |
356 | #endif //KAB_EMBEDDED | 407 | #endif //KAB_EMBEDDED |
357 | if (aItem) | 408 | if (aItem) |
358 | { | 409 | { |
359 | //kdDebug()<<"... even has a valid item:)"<<endl; | 410 | //kdDebug()<<"... even has a valid item:)"<<endl; |
360 | emit executed(aItem->addressee().uid()); | 411 | emit executed(aItem->addressee().uid()); |
361 | } | 412 | } |
362 | } | 413 | } |
363 | 414 | ||
364 | void KAddressBookCardView::addresseeSelected() | 415 | void KAddressBookCardView::addresseeSelected() |
365 | { | 416 | { |
366 | CardViewItem *item; | 417 | CardViewItem *item; |
367 | AddresseeCardViewItem *aItem; | 418 | AddresseeCardViewItem *aItem; |
368 | 419 | ||
369 | bool found = false; | 420 | bool found = false; |
370 | for (item = mCardView->firstItem(); item && !found; | 421 | for (item = mCardView->firstItem(); item && !found; |
371 | item = item->nextItem()) | 422 | item = item->nextItem()) |
372 | { | 423 | { |
373 | if (item->isSelected()) | 424 | if (item->isSelected()) |
374 | { | 425 | { |
375 | #ifndef KAB_EMBEDDED | 426 | #ifndef KAB_EMBEDDED |
376 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); | 427 | aItem = dynamic_cast<AddresseeCardViewItem*>(item); |
377 | #else //KAB_EMBEDDED | 428 | #else //KAB_EMBEDDED |
378 | aItem = (AddresseeCardViewItem*)(item); | 429 | aItem = (AddresseeCardViewItem*)(item); |
379 | #endif //KAB_EMBEDDED | 430 | #endif //KAB_EMBEDDED |
380 | if ( aItem ) | 431 | if ( aItem ) |
381 | { | 432 | { |
382 | emit selected(aItem->addressee().uid()); | 433 | emit selected(aItem->addressee().uid()); |
383 | found = true; | 434 | found = true; |
384 | } | 435 | } |
385 | } | 436 | } |
386 | } | 437 | } |
387 | 438 | ||
388 | if (!found) | 439 | if (!found) |
389 | emit selected(QString::null); | 440 | emit selected(QString::null); |
390 | 441 | ||
391 | } | 442 | } |
392 | #ifndef KAB_EMBEDDED | 443 | #ifndef KAB_EMBEDDED |
393 | #include "kaddressbookcardview.moc" | 444 | #include "kaddressbookcardview.moc" |
394 | #endif //KAB_EMBEDDED | 445 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/kaddressbookcardview.h b/kaddressbook/views/kaddressbookcardview.h index cd70371..b8efb01 100644 --- a/kaddressbook/views/kaddressbookcardview.h +++ b/kaddressbook/views/kaddressbookcardview.h | |||
@@ -1,117 +1,117 @@ | |||
1 | #ifndef KADDRESSBOOKCARDVIEW_H | 1 | #ifndef KADDRESSBOOKCARDVIEW_H |
2 | #define KADDRESSBOOKCARDVIEW_H | 2 | #define KADDRESSBOOKCARDVIEW_H |
3 | 3 | ||
4 | /* | 4 | /* |
5 | This file is part of KAddressBook. | 5 | This file is part of KAddressBook. |
6 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 6 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
7 | 7 | ||
8 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. | 11 | (at your option) any later version. |
12 | 12 | ||
13 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | 19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 | 21 | ||
22 | As a special exception, permission is given to link this program | 22 | As a special exception, permission is given to link this program |
23 | with any edition of Qt, and distribute the resulting executable, | 23 | with any edition of Qt, and distribute the resulting executable, |
24 | without including the source code for Qt in the source distribution. | 24 | without including the source code for Qt in the source distribution. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | #ifndef KAB_EMBEDDED | 28 | #ifndef KAB_EMBEDDED |
29 | #include <kiconview.h> | 29 | #include <kiconview.h> |
30 | #else //KAB_EMBEDDED | 30 | #else //KAB_EMBEDDED |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #endif //KAB_EMBEDDED | 32 | #endif //KAB_EMBEDDED |
33 | 33 | ||
34 | #include "cardview.h" | 34 | #include "cardview.h" |
35 | #include "kaddressbookview.h" | 35 | #include "kaddressbookview.h" |
36 | #include "configurecardviewdialog.h" | 36 | #include "configurecardviewdialog.h" |
37 | 37 | ||
38 | class QDragEnterEvent; | 38 | class QDragEnterEvent; |
39 | class QDragEntryEvent; | 39 | class QDragEntryEvent; |
40 | class QDropEvent; | 40 | class QDropEvent; |
41 | class KConfig; | 41 | class KConfig; |
42 | class AddresseeCardView; | 42 | class AddresseeCardView; |
43 | 43 | ||
44 | /** | 44 | /** |
45 | This view uses the CardView class to create a card view. At some | 45 | This view uses the CardView class to create a card view. At some |
46 | point in the future I think this will be the default view of | 46 | point in the future I think this will be the default view of |
47 | KAddressBook. | 47 | KAddressBook. |
48 | */ | 48 | */ |
49 | class KAddressBookCardView : public KAddressBookView | 49 | class KAddressBookCardView : public KAddressBookView |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | 52 | ||
53 | public: | 53 | public: |
54 | KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent, | 54 | KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent, |
55 | const char *name = 0 ); | 55 | const char *name = 0 ); |
56 | virtual ~KAddressBookCardView(); | 56 | virtual ~KAddressBookCardView(); |
57 | 57 | void doSearch( const QString& s,KABC::Field *field ); | |
58 | virtual QStringList selectedUids(); | 58 | virtual QStringList selectedUids(); |
59 | virtual QString type() const { return "Card"; } | 59 | virtual QString type() const { return "Card"; } |
60 | 60 | ||
61 | virtual void readConfig(KConfig *config); | 61 | virtual void readConfig(KConfig *config); |
62 | virtual void writeConfig(KConfig *); | 62 | virtual void writeConfig(KConfig *); |
63 | 63 | ||
64 | public slots: | 64 | public slots: |
65 | void refresh(QString uid = QString::null); | 65 | void refresh(QString uid = QString::null); |
66 | void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/); | 66 | void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/); |
67 | //US added an additional method without parameter | 67 | //US added an additional method without parameter |
68 | void setSelected(); | 68 | void setSelected(); |
69 | 69 | ||
70 | protected slots: | 70 | protected slots: |
71 | void addresseeExecuted(CardViewItem *item); | 71 | void addresseeExecuted(CardViewItem *item); |
72 | void addresseeSelected(); | 72 | void addresseeSelected(); |
73 | 73 | ||
74 | private: | 74 | private: |
75 | AddresseeCardView *mCardView; | 75 | AddresseeCardView *mCardView; |
76 | bool mShowEmptyFields; | 76 | bool mShowEmptyFields; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | class AddresseeCardView : public CardView | 79 | class AddresseeCardView : public CardView |
80 | { | 80 | { |
81 | Q_OBJECT | 81 | Q_OBJECT |
82 | public: | 82 | public: |
83 | AddresseeCardView(QWidget *parent, const char *name = 0); | 83 | AddresseeCardView(QWidget *parent, const char *name = 0); |
84 | ~AddresseeCardView(); | 84 | ~AddresseeCardView(); |
85 | 85 | ||
86 | signals: | 86 | signals: |
87 | void startAddresseeDrag(); | 87 | void startAddresseeDrag(); |
88 | void addresseeDropped(QDropEvent *); | 88 | void addresseeDropped(QDropEvent *); |
89 | 89 | ||
90 | protected: | 90 | protected: |
91 | virtual void dragEnterEvent(QDragEnterEvent *); | 91 | virtual void dragEnterEvent(QDragEnterEvent *); |
92 | virtual void dropEvent(QDropEvent *); | 92 | virtual void dropEvent(QDropEvent *); |
93 | virtual void startDrag(); | 93 | virtual void startDrag(); |
94 | }; | 94 | }; |
95 | 95 | ||
96 | 96 | ||
97 | class CardViewFactory : public ViewFactory | 97 | class CardViewFactory : public ViewFactory |
98 | { | 98 | { |
99 | public: | 99 | public: |
100 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 100 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
101 | { | 101 | { |
102 | return new KAddressBookCardView( ab, parent, name ); | 102 | return new KAddressBookCardView( ab, parent, name ); |
103 | } | 103 | } |
104 | 104 | ||
105 | QString type() const { return "Card"; } | 105 | QString type() const { return "Card"; } |
106 | 106 | ||
107 | QString description() const { return i18n( "Rolodex style cards represent contacts." ); } | 107 | QString description() const { return i18n( "Rolodex style cards represent contacts." ); } |
108 | 108 | ||
109 | ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, | 109 | ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, |
110 | const char *name = 0 ) | 110 | const char *name = 0 ) |
111 | { | 111 | { |
112 | return new ConfigureCardViewWidget( ab, parent, name ); | 112 | return new ConfigureCardViewWidget( ab, parent, name ); |
113 | } | 113 | } |
114 | }; | 114 | }; |
115 | 115 | ||
116 | 116 | ||
117 | #endif | 117 | #endif |
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp index 50ff285..78d63b0 100644 --- a/kaddressbook/views/kaddressbookiconview.cpp +++ b/kaddressbook/views/kaddressbookiconview.cpp | |||
@@ -1,378 +1,425 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
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 KAB_EMBEDDED | 24 | #ifndef KAB_EMBEDDED |
25 | #include <qiconview.h> | 25 | #include <qiconview.h> |
26 | #include <qstringlist.h> | 26 | #include <qstringlist.h> |
27 | 27 | ||
28 | #include <kabc/addressee.h> | 28 | #include <kabc/addressee.h> |
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | #include <kdebug.h> | 30 | #include <kdebug.h> |
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kiconloader.h> | 32 | #include <kiconloader.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #else //KAB_EMBEDDED | 35 | #else //KAB_EMBEDDED |
36 | #endif //KAB_EMBEDDED | 36 | #endif //KAB_EMBEDDED |
37 | 37 | ||
38 | #include <kabc/addressbook.h> | 38 | #include <kabc/addressbook.h> |
39 | #include "kabprefs.h" | 39 | #include "kabprefs.h" |
40 | #include "viewmanager.h" | 40 | #include "viewmanager.h" |
41 | #include "kaddressbookiconview.h" | 41 | #include "kaddressbookiconview.h" |
42 | #include <qlayout.h> | 42 | #include <qlayout.h> |
43 | #include <kglobal.h> | 43 | #include <kglobal.h> |
44 | /*US transfered to the headerfile | 44 | /*US transfered to the headerfile |
45 | class IconViewFactory : public ViewFactory | 45 | class IconViewFactory : public ViewFactory |
46 | { | 46 | { |
47 | public: | 47 | public: |
48 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 48 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
49 | { | 49 | { |
50 | return new KAddressBookIconView( ab, parent, name ); | 50 | return new KAddressBookIconView( ab, parent, name ); |
51 | } | 51 | } |
52 | 52 | ||
53 | QString type() const { return "Icon"; } | 53 | QString type() const { return "Icon"; } |
54 | 54 | ||
55 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } | 55 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } |
56 | }; | 56 | }; |
57 | 57 | ||
58 | */ | 58 | */ |
59 | 59 | ||
60 | extern "C" { | 60 | extern "C" { |
61 | void *init_libkaddrbk_iconview() | 61 | void *init_libkaddrbk_iconview() |
62 | { | 62 | { |
63 | return ( new IconViewFactory ); | 63 | return ( new IconViewFactory ); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | //////////////////////////////// | 67 | //////////////////////////////// |
68 | // AddresseeIconView (internal class) | 68 | // AddresseeIconView (internal class) |
69 | #ifndef KAB_EMBEDDED | 69 | #ifndef KAB_EMBEDDED |
70 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 70 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) |
71 | : KIconView(parent, name) | 71 | : KIconView(parent, name) |
72 | #else //KAB_EMBEDDED | 72 | #else //KAB_EMBEDDED |
73 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) | 73 | AddresseeIconView::AddresseeIconView(QWidget *parent, const char *name) |
74 | : QIconView(parent, name) | 74 | : QIconView(parent, name) |
75 | #endif //KAB_EMBEDDED | 75 | #endif //KAB_EMBEDDED |
76 | 76 | ||
77 | { | 77 | { |
78 | setSelectionMode( QIconView::Extended ); | 78 | setSelectionMode( QIconView::Extended ); |
79 | setResizeMode( QIconView::Adjust ); | 79 | setResizeMode( QIconView::Adjust ); |
80 | setWordWrapIconText( true ); | 80 | setWordWrapIconText( true ); |
81 | setGridX( 100 ); | 81 | setGridX( 100 ); |
82 | setItemsMovable(false); | 82 | setItemsMovable(false); |
83 | setSorting(true, true); | 83 | setSorting(true, true); |
84 | 84 | ||
85 | 85 | ||
86 | //US ??? setMode( KIconView::Select ); | 86 | //US ??? setMode( KIconView::Select ); |
87 | 87 | ||
88 | #ifndef KAB_EMBEDDED | 88 | #ifndef KAB_EMBEDDED |
89 | 89 | ||
90 | connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), | 90 | connect(this, SIGNAL(dropped(QDropEvent*, const QValueList<QIconDragItem>&)), |
91 | this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); | 91 | this, SLOT(itemDropped(QDropEvent*, const QValueList<QIconDragItem>&))); |
92 | #endif //KAB_EMBEDDED | 92 | #endif //KAB_EMBEDDED |
93 | } | 93 | } |
94 | 94 | ||
95 | AddresseeIconView::~AddresseeIconView() | 95 | AddresseeIconView::~AddresseeIconView() |
96 | { | 96 | { |
97 | } | 97 | } |
98 | 98 | ||
99 | |||
99 | void AddresseeIconView::itemDropped(QDropEvent *e, | 100 | void AddresseeIconView::itemDropped(QDropEvent *e, |
100 | const QValueList<QIconDragItem> &) | 101 | const QValueList<QIconDragItem> &) |
101 | { | 102 | { |
102 | emit addresseeDropped(e); | 103 | emit addresseeDropped(e); |
103 | } | 104 | } |
104 | 105 | ||
105 | QDragObject *AddresseeIconView::dragObject() | 106 | QDragObject *AddresseeIconView::dragObject() |
106 | { | 107 | { |
107 | emit startAddresseeDrag(); | 108 | emit startAddresseeDrag(); |
108 | 109 | ||
109 | // We never want IconView to start the drag | 110 | // We never want IconView to start the drag |
110 | return 0; | 111 | return 0; |
111 | } | 112 | } |
112 | //////////////////////////////// | 113 | //////////////////////////////// |
113 | // AddresseeIconViewItem (internal class) | 114 | // AddresseeIconViewItem (internal class) |
114 | #ifndef KAB_EMBEDDED | 115 | #ifndef KAB_EMBEDDED |
115 | class AddresseeIconViewItem : public KIconViewItem | 116 | class AddresseeIconViewItem : public KIconViewItem |
116 | #else //KAB_EMBEDDED | 117 | #else //KAB_EMBEDDED |
117 | class AddresseeIconViewItem : public QIconViewItem | 118 | class AddresseeIconViewItem : public QIconViewItem |
118 | #endif //KAB_EMBEDDED | 119 | #endif //KAB_EMBEDDED |
119 | { | 120 | { |
120 | public: | 121 | public: |
121 | #ifndef KAB_EMBEDDED | 122 | #ifndef KAB_EMBEDDED |
122 | AddresseeIconViewItem(const KABC::Field::List &fields, | 123 | AddresseeIconViewItem(const KABC::Field::List &fields, |
123 | KABC::AddressBook *doc, const KABC::Addressee &a, | 124 | KABC::AddressBook *doc, const KABC::Addressee &a, |
124 | QIconView *parent) | 125 | QIconView *parent) |
125 | : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) | 126 | : KIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) |
126 | #else //KAB_EMBEDDED | 127 | #else //KAB_EMBEDDED |
127 | AddresseeIconViewItem(const KABC::Field::List &fields, | 128 | AddresseeIconViewItem(const KABC::Field::List &fields, |
128 | KABC::AddressBook *doc, const KABC::Addressee &a, | 129 | KABC::AddressBook *doc, const KABC::Addressee &a, |
129 | QIconView *parent) | 130 | QIconView *parent) |
130 | : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) | 131 | : QIconViewItem(parent), mFields( fields ), mDocument(doc), mAddressee(a) |
131 | #endif //KAB_EMBEDDED | 132 | #endif //KAB_EMBEDDED |
132 | { | 133 | { |
133 | if ( mFields.isEmpty() ) { | 134 | if ( mFields.isEmpty() ) { |
134 | mFields = KABC::Field::defaultFields(); | 135 | mFields = KABC::Field::defaultFields(); |
135 | } | 136 | } |
136 | refresh(); | 137 | refresh(); |
137 | } | 138 | } |
138 | 139 | ||
139 | const KABC::Addressee &addressee() const { return mAddressee; } | 140 | const KABC::Addressee &addressee() const { return mAddressee; } |
140 | 141 | ||
141 | void refresh() | 142 | void refresh() |
142 | { | 143 | { |
143 | // Update our addressee, since it may have changed elsewhere | 144 | // Update our addressee, since it may have changed elsewhere |
144 | mAddressee = mDocument->findByUid(mAddressee.uid()); | 145 | mAddressee = mDocument->findByUid(mAddressee.uid()); |
145 | 146 | ||
146 | if (!mAddressee.isEmpty()) | 147 | if (!mAddressee.isEmpty()) |
147 | setText( mAddressee.givenName() + " " + mAddressee.familyName() ); | 148 | setText( mAddressee.givenName() + " " + mAddressee.familyName() ); |
148 | 149 | ||
149 | QPixmap icon; | 150 | QPixmap icon; |
150 | QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); | 151 | QPixmap defaultIcon( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop, 128 ) ); |
151 | KABC::Picture pic = mAddressee.photo(); | 152 | KABC::Picture pic = mAddressee.photo(); |
152 | if ( pic.data().isNull() ) | 153 | if ( pic.data().isNull() ) |
153 | pic = mAddressee.logo(); | 154 | pic = mAddressee.logo(); |
154 | 155 | ||
155 | if ( pic.isIntern() && !pic.data().isNull() ) { | 156 | if ( pic.isIntern() && !pic.data().isNull() ) { |
156 | QImage img = pic.data(); | 157 | QImage img = pic.data(); |
157 | #ifndef KAB_EMBEDDED | 158 | #ifndef KAB_EMBEDDED |
158 | if ( img.width() > img.height() ) | 159 | if ( img.width() > img.height() ) |
159 | icon = img.scaleWidth( 32 ); | 160 | icon = img.scaleWidth( 32 ); |
160 | else | 161 | else |
161 | icon = img.scaleHeight( 32 ); | 162 | icon = img.scaleHeight( 32 ); |
162 | #else //KAB_EMBEDDED | 163 | #else //KAB_EMBEDDED |
163 | qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); | 164 | qDebug("AddresseeIconViewItem::refresh - scale here dependend of the displaysize and the right factor"); |
164 | icon.convertFromImage(img.smoothScale(32, 32)); | 165 | icon.convertFromImage(img.smoothScale(32, 32)); |
165 | #endif //KAB_EMBEDDED | 166 | #endif //KAB_EMBEDDED |
166 | 167 | ||
167 | } else | 168 | } else |
168 | icon = defaultIcon; | 169 | icon = defaultIcon; |
169 | 170 | ||
170 | setPixmap( icon ); | 171 | setPixmap( icon ); |
171 | } | 172 | } |
172 | 173 | ||
173 | private: | 174 | private: |
174 | KABC::Field::List mFields; | 175 | KABC::Field::List mFields; |
175 | KABC::AddressBook *mDocument; | 176 | KABC::AddressBook *mDocument; |
176 | KABC::Addressee mAddressee; | 177 | KABC::Addressee mAddressee; |
177 | }; | 178 | }; |
178 | 179 | ||
179 | /////////////////////////////// | 180 | /////////////////////////////// |
180 | // KAddressBookView | 181 | // KAddressBookView |
181 | 182 | ||
182 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, | 183 | KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, |
183 | QWidget *parent, const char *name) | 184 | QWidget *parent, const char *name) |
184 | : KAddressBookView( ab, parent, name ) | 185 | : KAddressBookView( ab, parent, name ) |
185 | { | 186 | { |
186 | // Init the GUI | 187 | // Init the GUI |
187 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); | 188 | QVBoxLayout *layout = new QVBoxLayout(viewWidget()); |
188 | 189 | ||
189 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); | 190 | mIconView = new AddresseeIconView(viewWidget(), "mIconView"); |
190 | layout->addWidget(mIconView); | 191 | layout->addWidget(mIconView); |
191 | 192 | ||
192 | // Connect up the signals | 193 | // Connect up the signals |
193 | 194 | ||
194 | //US method executed is part of KIconView | 195 | //US method executed is part of KIconView |
195 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 196 | //US connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
196 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 197 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
197 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 198 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
198 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 199 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
199 | 200 | ||
200 | connect(mIconView, SIGNAL(selectionChanged()), | 201 | connect(mIconView, SIGNAL(selectionChanged()), |
201 | this, SLOT(addresseeSelected())); | 202 | this, SLOT(addresseeSelected())); |
202 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), | 203 | connect(mIconView, SIGNAL(addresseeDropped(QDropEvent*)), |
203 | this, SIGNAL(dropped(QDropEvent*))); | 204 | this, SIGNAL(dropped(QDropEvent*))); |
204 | connect(mIconView, SIGNAL(startAddresseeDrag()), | 205 | connect(mIconView, SIGNAL(startAddresseeDrag()), |
205 | this, SIGNAL(startDrag())); | 206 | this, SIGNAL(startDrag())); |
206 | } | 207 | } |
207 | 208 | ||
208 | KAddressBookIconView::~KAddressBookIconView() | 209 | KAddressBookIconView::~KAddressBookIconView() |
209 | { | 210 | { |
210 | } | 211 | } |
211 | 212 | ||
212 | void KAddressBookIconView::readConfig(KConfig *config) | 213 | void KAddressBookIconView::readConfig(KConfig *config) |
213 | { | 214 | { |
214 | KAddressBookView::readConfig(config); | 215 | KAddressBookView::readConfig(config); |
215 | 216 | ||
216 | //US method executed is part of KIconView | 217 | //US method executed is part of KIconView |
217 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), | 218 | //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), |
218 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); | 219 | //US this, SLOT(addresseeExecuted(QIconViewItem *))); |
219 | disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 220 | disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
220 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 221 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
221 | 222 | ||
222 | //US method executed is part of KIconView. Use selectionChanged instead | 223 | //US method executed is part of KIconView. Use selectionChanged instead |
223 | /*US | 224 | /*US |
224 | if (KABPrefs::instance()->mHonorSingleClick) | 225 | if (KABPrefs::instance()->mHonorSingleClick) |
225 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), | 226 | connect(mIconView, SIGNAL(executed(QIconViewItem *)), |
226 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 227 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
227 | else | 228 | else |
228 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), | 229 | connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)), |
229 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 230 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
230 | */ | 231 | */ |
231 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), | 232 | connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), |
232 | this, SLOT(addresseeExecuted(QIconViewItem *))); | 233 | this, SLOT(addresseeExecuted(QIconViewItem *))); |
233 | 234 | ||
234 | } | 235 | } |
236 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) | ||
237 | { | ||
238 | mIconView->clear(); | ||
239 | mIconList.clear(); | ||
240 | if ( s.isEmpty() || s == "*" ) { | ||
241 | refresh(); | ||
242 | return; | ||
243 | } | ||
244 | QString pattern = s.lower()+"*"; | ||
245 | QRegExp re; | ||
246 | re.setWildcard(true); // most people understand these better. | ||
247 | re.setCaseSensitive(false); | ||
248 | re.setPattern( pattern ); | ||
249 | if (!re.isValid()) | ||
250 | return; | ||
251 | KABC::Addressee::List addresseeList = addressees(); | ||
252 | KABC::Addressee::List::Iterator it; | ||
253 | if ( field ) { | ||
254 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
255 | #if QT_VERSION >= 300 | ||
256 | if (re.search(field->value( *it ).lower()) != -1) | ||
257 | #else | ||
258 | if (re.match(field->value( *it ).lower()) != -1) | ||
259 | #endif | ||
260 | mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | ||
261 | |||
235 | 262 | ||
263 | } | ||
264 | } else { | ||
265 | KABC::Field::List fieldList = fields(); | ||
266 | KABC::Field::List::ConstIterator fieldIt; | ||
267 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
268 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | ||
269 | #if QT_VERSION >= 300 | ||
270 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | ||
271 | #else | ||
272 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | ||
273 | #endif | ||
274 | { | ||
275 | mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | ||
276 | continue; | ||
277 | } | ||
278 | } | ||
279 | } | ||
280 | } | ||
281 | mIconView->arrangeItemsInGrid( true ); | ||
282 | } | ||
236 | QStringList KAddressBookIconView::selectedUids() | 283 | QStringList KAddressBookIconView::selectedUids() |
237 | { | 284 | { |
238 | QStringList uidList; | 285 | QStringList uidList; |
239 | QIconViewItem *item; | 286 | QIconViewItem *item; |
240 | AddresseeIconViewItem *aItem; | 287 | AddresseeIconViewItem *aItem; |
241 | 288 | ||
242 | for (item = mIconView->firstItem(); item; item = item->nextItem()) | 289 | for (item = mIconView->firstItem(); item; item = item->nextItem()) |
243 | { | 290 | { |
244 | if (item->isSelected()) | 291 | if (item->isSelected()) |
245 | { | 292 | { |
246 | #ifndef KAB_EMBEDDED | 293 | #ifndef KAB_EMBEDDED |
247 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 294 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
248 | #else //KAB_EMBEDDED | 295 | #else //KAB_EMBEDDED |
249 | aItem = (AddresseeIconViewItem*)(item); | 296 | aItem = (AddresseeIconViewItem*)(item); |
250 | #endif //KAB_EMBEDDED | 297 | #endif //KAB_EMBEDDED |
251 | if (aItem) | 298 | if (aItem) |
252 | uidList << aItem->addressee().uid(); | 299 | uidList << aItem->addressee().uid(); |
253 | } | 300 | } |
254 | } | 301 | } |
255 | 302 | ||
256 | return uidList; | 303 | return uidList; |
257 | } | 304 | } |
258 | 305 | ||
259 | void KAddressBookIconView::refresh(QString uid) | 306 | void KAddressBookIconView::refresh(QString uid) |
260 | { | 307 | { |
261 | QIconViewItem *item; | 308 | QIconViewItem *item; |
262 | AddresseeIconViewItem *aItem; | 309 | AddresseeIconViewItem *aItem; |
263 | 310 | ||
264 | if ( uid.isNull() ) { | 311 | if ( uid.isNull() ) { |
265 | // Rebuild the view | 312 | // Rebuild the view |
266 | mIconView->clear(); | 313 | mIconView->clear(); |
267 | mIconList.clear(); | 314 | mIconList.clear(); |
268 | 315 | ||
269 | KABC::Addressee::List addresseeList = addressees(); | 316 | KABC::Addressee::List addresseeList = addressees(); |
270 | KABC::Addressee::List::Iterator iter; | 317 | KABC::Addressee::List::Iterator iter; |
271 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) | 318 | for ( iter = addresseeList.begin(); iter != addresseeList.end(); ++iter ) |
272 | aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); | 319 | aItem = new AddresseeIconViewItem( fields(), addressBook(), *iter, mIconView ); |
273 | 320 | ||
274 | mIconView->arrangeItemsInGrid( true ); | 321 | mIconView->arrangeItemsInGrid( true ); |
275 | 322 | ||
276 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) | 323 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) |
277 | { | 324 | { |
278 | #ifndef KAB_EMBEDDED | 325 | #ifndef KAB_EMBEDDED |
279 | AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); | 326 | AddresseeIconViewItem* aivi = dynamic_cast<AddresseeIconViewItem*>( item ); |
280 | #else //KAB_EMBEDDED | 327 | #else //KAB_EMBEDDED |
281 | AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); | 328 | AddresseeIconViewItem* aivi = (AddresseeIconViewItem*)( item ); |
282 | #endif //KAB_EMBEDDED | 329 | #endif //KAB_EMBEDDED |
283 | mIconList.append( aivi ); | 330 | mIconList.append( aivi ); |
284 | } | 331 | } |
285 | 332 | ||
286 | } else { | 333 | } else { |
287 | // Try to find the one to refresh | 334 | // Try to find the one to refresh |
288 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { | 335 | for ( item = mIconView->firstItem(); item; item = item->nextItem() ) { |
289 | #ifndef KAB_EMBEDDED | 336 | #ifndef KAB_EMBEDDED |
290 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 337 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
291 | #else //KAB_EMBEDDED | 338 | #else //KAB_EMBEDDED |
292 | aItem = (AddresseeIconViewItem*)(item); | 339 | aItem = (AddresseeIconViewItem*)(item); |
293 | #endif //KAB_EMBEDDED | 340 | #endif //KAB_EMBEDDED |
294 | if ((aItem) && (aItem->addressee().uid() == uid)) { | 341 | if ((aItem) && (aItem->addressee().uid() == uid)) { |
295 | aItem->refresh(); | 342 | aItem->refresh(); |
296 | mIconView->arrangeItemsInGrid( true ); | 343 | mIconView->arrangeItemsInGrid( true ); |
297 | return; | 344 | return; |
298 | } | 345 | } |
299 | } | 346 | } |
300 | refresh( QString::null ); | 347 | refresh( QString::null ); |
301 | } | 348 | } |
302 | } | 349 | } |
303 | 350 | ||
304 | void KAddressBookIconView::setSelected(QString uid, bool selected) | 351 | void KAddressBookIconView::setSelected(QString uid, bool selected) |
305 | { | 352 | { |
306 | QIconViewItem *item; | 353 | QIconViewItem *item; |
307 | AddresseeIconViewItem *aItem; | 354 | AddresseeIconViewItem *aItem; |
308 | 355 | ||
309 | if (uid.isNull()) | 356 | if (uid.isNull()) |
310 | { | 357 | { |
311 | mIconView->selectAll(selected); | 358 | mIconView->selectAll(selected); |
312 | } | 359 | } |
313 | else | 360 | else |
314 | { | 361 | { |
315 | bool found = false; | 362 | bool found = false; |
316 | for (item = mIconView->firstItem(); item && !found; | 363 | for (item = mIconView->firstItem(); item && !found; |
317 | item = item->nextItem()) | 364 | item = item->nextItem()) |
318 | { | 365 | { |
319 | #ifndef KAB_EMBEDDED | 366 | #ifndef KAB_EMBEDDED |
320 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 367 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
321 | #else //KAB_EMBEDDED | 368 | #else //KAB_EMBEDDED |
322 | aItem = (AddresseeIconViewItem*)(item); | 369 | aItem = (AddresseeIconViewItem*)(item); |
323 | #endif //KAB_EMBEDDED | 370 | #endif //KAB_EMBEDDED |
324 | 371 | ||
325 | if ((aItem) && (aItem->addressee().uid() == uid)) | 372 | if ((aItem) && (aItem->addressee().uid() == uid)) |
326 | { | 373 | { |
327 | mIconView->setSelected(aItem, selected); | 374 | mIconView->setSelected(aItem, selected); |
328 | mIconView->ensureItemVisible( aItem ); | 375 | mIconView->ensureItemVisible( aItem ); |
329 | found = true; | 376 | found = true; |
330 | } | 377 | } |
331 | } | 378 | } |
332 | } | 379 | } |
333 | } | 380 | } |
334 | 381 | ||
335 | void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) | 382 | void KAddressBookIconView::addresseeExecuted(QIconViewItem *item) |
336 | { | 383 | { |
337 | #ifndef KAB_EMBEDDED | 384 | #ifndef KAB_EMBEDDED |
338 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 385 | AddresseeIconViewItem *aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
339 | #else //KAB_EMBEDDED | 386 | #else //KAB_EMBEDDED |
340 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); | 387 | AddresseeIconViewItem *aItem = (AddresseeIconViewItem*)(item); |
341 | #endif //KAB_EMBEDDED | 388 | #endif //KAB_EMBEDDED |
342 | 389 | ||
343 | if (aItem) { | 390 | if (aItem) { |
344 | emit executed(aItem->addressee().uid()); | 391 | emit executed(aItem->addressee().uid()); |
345 | } | 392 | } |
346 | } | 393 | } |
347 | 394 | ||
348 | void KAddressBookIconView::addresseeSelected() | 395 | void KAddressBookIconView::addresseeSelected() |
349 | { | 396 | { |
350 | QIconViewItem *item; | 397 | QIconViewItem *item; |
351 | AddresseeIconViewItem *aItem; | 398 | AddresseeIconViewItem *aItem; |
352 | 399 | ||
353 | bool found = false; | 400 | bool found = false; |
354 | for (item = mIconView->firstItem(); item && !found; | 401 | for (item = mIconView->firstItem(); item && !found; |
355 | item = item->nextItem()) | 402 | item = item->nextItem()) |
356 | { | 403 | { |
357 | if (item->isSelected()) | 404 | if (item->isSelected()) |
358 | { | 405 | { |
359 | #ifndef KAB_EMBEDDED | 406 | #ifndef KAB_EMBEDDED |
360 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); | 407 | aItem = dynamic_cast<AddresseeIconViewItem*>(item); |
361 | #else //KAB_EMBEDDED | 408 | #else //KAB_EMBEDDED |
362 | aItem = (AddresseeIconViewItem*)(item); | 409 | aItem = (AddresseeIconViewItem*)(item); |
363 | #endif //KAB_EMBEDDED | 410 | #endif //KAB_EMBEDDED |
364 | if (aItem) | 411 | if (aItem) |
365 | { | 412 | { |
366 | emit selected(aItem->addressee().uid()); | 413 | emit selected(aItem->addressee().uid()); |
367 | found = true; | 414 | found = true; |
368 | } | 415 | } |
369 | } | 416 | } |
370 | } | 417 | } |
371 | 418 | ||
372 | if (!found) | 419 | if (!found) |
373 | emit selected(QString::null); | 420 | emit selected(QString::null); |
374 | } | 421 | } |
375 | 422 | ||
376 | #ifndef KAB_EMBEDDED | 423 | #ifndef KAB_EMBEDDED |
377 | #include "kaddressbookiconview.moc" | 424 | #include "kaddressbookiconview.moc" |
378 | #endif //KAB_EMBEDDED | 425 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/kaddressbookiconview.h b/kaddressbook/views/kaddressbookiconview.h index 3afada3..963ee7c 100644 --- a/kaddressbook/views/kaddressbookiconview.h +++ b/kaddressbook/views/kaddressbookiconview.h | |||
@@ -1,130 +1,131 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
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 KADDRESSBOOKICONVIEW_H | 24 | #ifndef KADDRESSBOOKICONVIEW_H |
25 | #define KADDRESSBOOKICONVIEW_H | 25 | #define KADDRESSBOOKICONVIEW_H |
26 | 26 | ||
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | #ifndef KAB_EMBEDDED | 28 | #ifndef KAB_EMBEDDED |
29 | #include <kiconview.h> | 29 | #include <kiconview.h> |
30 | #else //KAB_EMBEDDED | 30 | #else //KAB_EMBEDDED |
31 | #include <qiconview.h> | 31 | #include <qiconview.h> |
32 | #include <qptrlist.h> | 32 | #include <qptrlist.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #endif //KAB_EMBEDDED | 34 | #endif //KAB_EMBEDDED |
35 | #include "kaddressbookview.h" | 35 | #include "kaddressbookview.h" |
36 | 36 | ||
37 | class QIconViewItem; | 37 | class QIconViewItem; |
38 | class KConfig; | 38 | class KConfig; |
39 | class AddresseeIconView; | 39 | class AddresseeIconView; |
40 | class AddresseeIconViewItem; | 40 | class AddresseeIconViewItem; |
41 | class QIconDragItem; | 41 | class QIconDragItem; |
42 | class KAddressBookIconView; | 42 | class KAddressBookIconView; |
43 | 43 | ||
44 | namespace KABC { class AddressBook; } | 44 | namespace KABC { class AddressBook; } |
45 | 45 | ||
46 | /** This is an example kaddressbook view that is implemented using | 46 | /** This is an example kaddressbook view that is implemented using |
47 | * KIconView. This view is not the most useful view, but it displays | 47 | * KIconView. This view is not the most useful view, but it displays |
48 | * how simple implementing a new view can be. | 48 | * how simple implementing a new view can be. |
49 | */ | 49 | */ |
50 | class KAddressBookIconView : public KAddressBookView | 50 | class KAddressBookIconView : public KAddressBookView |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | public: | 54 | public: |
55 | KAddressBookIconView( KABC::AddressBook *ab, QWidget *parent, | 55 | KAddressBookIconView( KABC::AddressBook *ab, QWidget *parent, |
56 | const char *name = 0 ); | 56 | const char *name = 0 ); |
57 | virtual ~KAddressBookIconView(); | 57 | virtual ~KAddressBookIconView(); |
58 | 58 | ||
59 | virtual QStringList selectedUids(); | 59 | virtual QStringList selectedUids(); |
60 | virtual QString type() const { return "Icon"; } | 60 | virtual QString type() const { return "Icon"; } |
61 | void doSearch( const QString& s ,KABC::Field *field ); | ||
61 | 62 | ||
62 | virtual void readConfig(KConfig *config); | 63 | virtual void readConfig(KConfig *config); |
63 | 64 | ||
64 | public slots: | 65 | public slots: |
65 | void refresh(QString uid = QString::null); | 66 | void refresh(QString uid = QString::null); |
66 | #ifndef KAB_EMBEDDED | 67 | #ifndef KAB_EMBEDDED |
67 | //MOC_SKIP_BEGIN | 68 | //MOC_SKIP_BEGIN |
68 | void setSelected(QString uid = QString::null, bool selected = true); | 69 | void setSelected(QString uid = QString::null, bool selected = true); |
69 | //MOC_SKIP_END | 70 | //MOC_SKIP_END |
70 | #else //KAB_EMBEDDED | 71 | #else //KAB_EMBEDDED |
71 | //US my MOC do not like default parameters ??? | 72 | //US my MOC do not like default parameters ??? |
72 | void setSelected(QString uid, bool selected); | 73 | void setSelected(QString uid, bool selected); |
73 | #endif //KAB_EMBEDDED | 74 | #endif //KAB_EMBEDDED |
74 | 75 | ||
75 | protected slots: | 76 | protected slots: |
76 | void addresseeExecuted(QIconViewItem *item); | 77 | void addresseeExecuted(QIconViewItem *item); |
77 | void addresseeSelected(); | 78 | void addresseeSelected(); |
78 | 79 | ||
79 | private: | 80 | private: |
80 | AddresseeIconView *mIconView; | 81 | AddresseeIconView *mIconView; |
81 | QPtrList<AddresseeIconViewItem> mIconList; | 82 | QPtrList<AddresseeIconViewItem> mIconList; |
82 | }; | 83 | }; |
83 | 84 | ||
84 | 85 | ||
85 | #ifndef KAB_EMBEDDED | 86 | #ifndef KAB_EMBEDDED |
86 | //MOC_SKIP_BEGIN | 87 | //MOC_SKIP_BEGIN |
87 | class AddresseeIconView : public KIconView | 88 | class AddresseeIconView : public KIconView |
88 | //MOC_SKIP_END | 89 | //MOC_SKIP_END |
89 | #else //KAB_EMBEDDED | 90 | #else //KAB_EMBEDDED |
90 | class AddresseeIconView : public QIconView | 91 | class AddresseeIconView : public QIconView |
91 | #endif //KAB_EMBEDDED | 92 | #endif //KAB_EMBEDDED |
92 | { | 93 | { |
93 | Q_OBJECT | 94 | Q_OBJECT |
94 | 95 | ||
95 | public: | 96 | public: |
96 | AddresseeIconView(QWidget *parent, const char *name); | 97 | AddresseeIconView(QWidget *parent, const char *name); |
97 | ~AddresseeIconView(); | 98 | ~AddresseeIconView(); |
98 | 99 | ||
99 | signals: | 100 | signals: |
100 | void addresseeDropped(QDropEvent *); | 101 | void addresseeDropped(QDropEvent *); |
101 | void startAddresseeDrag(); | 102 | void startAddresseeDrag(); |
102 | 103 | ||
103 | protected: | 104 | protected: |
104 | virtual QDragObject *dragObject(); | 105 | virtual QDragObject *dragObject(); |
105 | 106 | ||
106 | protected slots: | 107 | protected slots: |
107 | void itemDropped(QDropEvent *, const QValueList<QIconDragItem> &); | 108 | void itemDropped(QDropEvent *, const QValueList<QIconDragItem> &); |
108 | }; | 109 | }; |
109 | 110 | ||
110 | class IconViewFactory : public ViewFactory | 111 | class IconViewFactory : public ViewFactory |
111 | { | 112 | { |
112 | public: | 113 | public: |
113 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 114 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
114 | { | 115 | { |
115 | return new KAddressBookIconView( ab, parent, name ); | 116 | return new KAddressBookIconView( ab, parent, name ); |
116 | } | 117 | } |
117 | 118 | ||
118 | QString type() const { return "Icon"; } | 119 | QString type() const { return "Icon"; } |
119 | 120 | ||
120 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } | 121 | QString description() const { return i18n( "Icons represent contacts. Very simple view." ); } |
121 | }; | 122 | }; |
122 | /* | 123 | /* |
123 | extern "C" { | 124 | extern "C" { |
124 | void *init_libkaddrbk_iconview() | 125 | void *init_libkaddrbk_iconview() |
125 | { | 126 | { |
126 | return ( new IconViewFactory ); | 127 | return ( new IconViewFactory ); |
127 | } | 128 | } |
128 | } | 129 | } |
129 | */ | 130 | */ |
130 | #endif | 131 | #endif |
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index ab11e2a..12f7c27 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -1,393 +1,442 @@ | |||
1 | // $Id$ | 1 | // $Id$ |
2 | 2 | ||
3 | #include <qvbox.h> | 3 | #include <qvbox.h> |
4 | #include <qlistbox.h> | 4 | #include <qlistbox.h> |
5 | #include <qwidget.h> | 5 | #include <qwidget.h> |
6 | #include <qfile.h> | 6 | #include <qfile.h> |
7 | #include <qimage.h> | 7 | #include <qimage.h> |
8 | #include <qcombobox.h> | 8 | #include <qcombobox.h> |
9 | #include <qapplication.h> | 9 | #include <qapplication.h> |
10 | #include <qdragobject.h> | 10 | #include <qdragobject.h> |
11 | #include <qevent.h> | 11 | #include <qevent.h> |
12 | #include <qurl.h> | 12 | #include <qurl.h> |
13 | #include <qpixmap.h> | 13 | #include <qpixmap.h> |
14 | 14 | ||
15 | #include <kabc/addressbook.h> | 15 | #include <kabc/addressbook.h> |
16 | #include <kapplication.h> | 16 | #include <kapplication.h> |
17 | #include <kconfig.h> | 17 | #include <kconfig.h> |
18 | #include <kcolorbutton.h> | 18 | #include <kcolorbutton.h> |
19 | #include <kdebug.h> | 19 | #include <kdebug.h> |
20 | #include <kglobal.h> | 20 | #include <kglobal.h> |
21 | #include <kiconloader.h> | 21 | #include <kiconloader.h> |
22 | #include <klineedit.h> | 22 | #include <klineedit.h> |
23 | #include <klocale.h> | 23 | #include <klocale.h> |
24 | #include <kmessagebox.h> | 24 | #include <kmessagebox.h> |
25 | #include <kurl.h> | 25 | #include <kurl.h> |
26 | #include <kurlrequester.h> | 26 | #include <kurlrequester.h> |
27 | 27 | ||
28 | //US#include "configuretableviewdialog.h" | 28 | //US#include "configuretableviewdialog.h" |
29 | #include "contactlistview.h" | 29 | #include "contactlistview.h" |
30 | #include "kabprefs.h" | 30 | #include "kabprefs.h" |
31 | #include "undocmds.h" | 31 | #include "undocmds.h" |
32 | #include "viewmanager.h" | 32 | #include "viewmanager.h" |
33 | 33 | ||
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qheader.h> | 35 | #include <qheader.h> |
36 | 36 | ||
37 | #include "kaddressbooktableview.h" | 37 | #include "kaddressbooktableview.h" |
38 | 38 | ||
39 | 39 | ||
40 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, | 40 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, |
41 | QWidget *parent, const char *name ) | 41 | QWidget *parent, const char *name ) |
42 | : KAddressBookView( ab, parent, name ) | 42 | : KAddressBookView( ab, parent, name ) |
43 | { | 43 | { |
44 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); | 44 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); |
45 | 45 | ||
46 | // The list view will be created when the config is read. | 46 | // The list view will be created when the config is read. |
47 | mListView = 0; | 47 | mListView = 0; |
48 | } | 48 | } |
49 | 49 | ||
50 | KAddressBookTableView::~KAddressBookTableView() | 50 | KAddressBookTableView::~KAddressBookTableView() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | void KAddressBookTableView::reconstructListView() | 54 | void KAddressBookTableView::reconstructListView() |
55 | { | 55 | { |
56 | if (mListView) | 56 | if (mListView) |
57 | { | 57 | { |
58 | disconnect(mListView, SIGNAL(selectionChanged()), | 58 | disconnect(mListView, SIGNAL(selectionChanged()), |
59 | this, SLOT(addresseeSelected())); | 59 | this, SLOT(addresseeSelected())); |
60 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), | 60 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), |
61 | this, SLOT(addresseeExecuted(QListViewItem*))); | 61 | this, SLOT(addresseeExecuted(QListViewItem*))); |
62 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 62 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
63 | this, SLOT(addresseeExecuted(QListViewItem*))); | 63 | this, SLOT(addresseeExecuted(QListViewItem*))); |
64 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, | 64 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, |
65 | SIGNAL(startDrag())); | 65 | SIGNAL(startDrag())); |
66 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 66 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
67 | this, SLOT(addresseeExecuted(QListViewItem*))); | 67 | this, SLOT(addresseeExecuted(QListViewItem*))); |
68 | 68 | ||
69 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 69 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
70 | SIGNAL(dropped(QDropEvent*))); | 70 | SIGNAL(dropped(QDropEvent*))); |
71 | delete mListView; | 71 | delete mListView; |
72 | } | 72 | } |
73 | 73 | ||
74 | mListView = new ContactListView( this, addressBook(), viewWidget() ); | 74 | mListView = new ContactListView( this, addressBook(), viewWidget() ); |
75 | 75 | ||
76 | // Add the columns | 76 | // Add the columns |
77 | KABC::Field::List fieldList = fields(); | 77 | KABC::Field::List fieldList = fields(); |
78 | KABC::Field::List::ConstIterator it; | 78 | KABC::Field::List::ConstIterator it; |
79 | 79 | ||
80 | int c = 0; | 80 | int c = 0; |
81 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { | 81 | for( it = fieldList.begin(); it != fieldList.end(); ++it ) { |
82 | mListView->addColumn( (*it)->label() ); | 82 | mListView->addColumn( (*it)->label() ); |
83 | mListView->setColumnWidthMode(c++, QListView::Manual); | 83 | mListView->setColumnWidthMode(c++, QListView::Manual); |
84 | //US | 84 | //US |
85 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); | 85 | // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); |
86 | } | 86 | } |
87 | 87 | ||
88 | connect(mListView, SIGNAL(selectionChanged()), | 88 | connect(mListView, SIGNAL(selectionChanged()), |
89 | this, SLOT(addresseeSelected())); | 89 | this, SLOT(addresseeSelected())); |
90 | connect(mListView, SIGNAL(startAddresseeDrag()), this, | 90 | connect(mListView, SIGNAL(startAddresseeDrag()), this, |
91 | SIGNAL(startDrag())); | 91 | SIGNAL(startDrag())); |
92 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 92 | connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
93 | SIGNAL(dropped(QDropEvent*))); | 93 | SIGNAL(dropped(QDropEvent*))); |
94 | 94 | ||
95 | if (KABPrefs::instance()->mHonorSingleClick) | 95 | if (KABPrefs::instance()->mHonorSingleClick) |
96 | connect(mListView, SIGNAL(executed(QListViewItem*)), | 96 | connect(mListView, SIGNAL(executed(QListViewItem*)), |
97 | this, SLOT(addresseeExecuted(QListViewItem*))); | 97 | this, SLOT(addresseeExecuted(QListViewItem*))); |
98 | else | 98 | else |
99 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 99 | connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
100 | this, SLOT(addresseeExecuted(QListViewItem*))); | 100 | this, SLOT(addresseeExecuted(QListViewItem*))); |
101 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 101 | connect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
102 | this, SLOT(addresseeExecuted(QListViewItem*))); | 102 | this, SLOT(addresseeExecuted(QListViewItem*))); |
103 | connect(mListView, SIGNAL(signalDelete()), | 103 | connect(mListView, SIGNAL(signalDelete()), |
104 | this, SLOT(addresseeDeleted())); | 104 | this, SLOT(addresseeDeleted())); |
105 | 105 | ||
106 | //US performceimprovement. Refresh is done from the outside | 106 | //US performceimprovement. Refresh is done from the outside |
107 | //US refresh(); | 107 | //US refresh(); |
108 | 108 | ||
109 | mListView->setSorting( 0, true ); | 109 | mListView->setSorting( 0, true ); |
110 | mainLayout->addWidget( mListView ); | 110 | mainLayout->addWidget( mListView ); |
111 | mainLayout->activate(); | 111 | mainLayout->activate(); |
112 | mListView->show(); | 112 | mListView->show(); |
113 | } | 113 | } |
114 | 114 | ||
115 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | ||
116 | { | ||
117 | mListView->clear(); | ||
118 | if ( s.isEmpty() || s == "*" ) { | ||
119 | refresh(); | ||
120 | return; | ||
121 | } | ||
122 | QString pattern = s.lower()+"*"; | ||
123 | QRegExp re; | ||
124 | re.setWildcard(true); // most people understand these better. | ||
125 | re.setCaseSensitive(false); | ||
126 | re.setPattern( pattern ); | ||
127 | if (!re.isValid()) | ||
128 | return; | ||
129 | KABC::Addressee::List addresseeList = addressees(); | ||
130 | KABC::Addressee::List::Iterator it; | ||
131 | if ( field ) { | ||
132 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
133 | #if QT_VERSION >= 300 | ||
134 | if (re.search(field->value( *it ).lower()) != -1) | ||
135 | #else | ||
136 | if (re.match(field->value( *it ).lower()) != -1) | ||
137 | #endif | ||
138 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | ||
139 | |||
140 | } | ||
141 | } else { | ||
142 | KABC::Field::List fieldList = fields(); | ||
143 | KABC::Field::List::ConstIterator fieldIt; | ||
144 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
145 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | ||
146 | #if QT_VERSION >= 300 | ||
147 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | ||
148 | #else | ||
149 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | ||
150 | #endif | ||
151 | { | ||
152 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | ||
153 | continue; | ||
154 | } | ||
155 | } | ||
156 | } | ||
157 | } | ||
158 | // Sometimes the background pixmap gets messed up when we add lots | ||
159 | // of items. | ||
160 | mListView->repaint(); | ||
161 | emit selected(QString::null); | ||
162 | |||
163 | } | ||
115 | void KAddressBookTableView::writeConfig(KConfig *config) | 164 | void KAddressBookTableView::writeConfig(KConfig *config) |
116 | { | 165 | { |
117 | KAddressBookView::writeConfig(config); | 166 | KAddressBookView::writeConfig(config); |
118 | 167 | ||
119 | mListView->saveLayout(config, config->group()); | 168 | mListView->saveLayout(config, config->group()); |
120 | } | 169 | } |
121 | 170 | ||
122 | void KAddressBookTableView::readConfig(KConfig *config) | 171 | void KAddressBookTableView::readConfig(KConfig *config) |
123 | { | 172 | { |
124 | KAddressBookView::readConfig( config ); | 173 | KAddressBookView::readConfig( config ); |
125 | // The config could have changed the fields, so we need to reconstruct | 174 | // The config could have changed the fields, so we need to reconstruct |
126 | // the listview. | 175 | // the listview. |
127 | reconstructListView(); | 176 | reconstructListView(); |
128 | 177 | ||
129 | // costum colors? | 178 | // costum colors? |
130 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 179 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
131 | { | 180 | { |
132 | QPalette p( mListView->palette() ); | 181 | QPalette p( mListView->palette() ); |
133 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); | 182 | QColor c = p.color(QPalette::Normal, QColorGroup::Base ); |
134 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); | 183 | p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); |
135 | c = p.color(QPalette::Normal, QColorGroup::Text ); | 184 | c = p.color(QPalette::Normal, QColorGroup::Text ); |
136 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); | 185 | p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); |
137 | c = p.color(QPalette::Normal, QColorGroup::Button ); | 186 | c = p.color(QPalette::Normal, QColorGroup::Button ); |
138 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); | 187 | p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); |
139 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); | 188 | c = p.color(QPalette::Normal, QColorGroup::ButtonText ); |
140 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); | 189 | p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); |
141 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); | 190 | c = p.color(QPalette::Normal, QColorGroup::Highlight ); |
142 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); | 191 | p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); |
143 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); | 192 | c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); |
144 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); | 193 | p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); |
145 | #ifndef KAB_EMBEDDED | 194 | #ifndef KAB_EMBEDDED |
146 | c = KGlobalSettings::alternateBackgroundColor(); | 195 | c = KGlobalSettings::alternateBackgroundColor(); |
147 | #else //KAB_EMBEDDED | 196 | #else //KAB_EMBEDDED |
148 | c = QColor(240, 240, 240); | 197 | c = QColor(240, 240, 240); |
149 | #endif //KAB_EMBEDDED | 198 | #endif //KAB_EMBEDDED |
150 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); | 199 | c = config->readColorEntry ("AlternatingBackgroundColor", &c); |
151 | mListView->setAlternateColor(c); | 200 | mListView->setAlternateColor(c); |
152 | 201 | ||
153 | 202 | ||
154 | //US mListView->viewport()->setPalette( p ); | 203 | //US mListView->viewport()->setPalette( p ); |
155 | mListView->setPalette( p ); | 204 | mListView->setPalette( p ); |
156 | } | 205 | } |
157 | else | 206 | else |
158 | { | 207 | { |
159 | // needed if turned off during a session. | 208 | // needed if turned off during a session. |
160 | //US mListView->viewport()->setPalette( mListView->palette() ); | 209 | //US mListView->viewport()->setPalette( mListView->palette() ); |
161 | mListView->setPalette( mListView->palette() ); | 210 | mListView->setPalette( mListView->palette() ); |
162 | } | 211 | } |
163 | 212 | ||
164 | //custom fonts? | 213 | //custom fonts? |
165 | QFont f( font() ); | 214 | QFont f( font() ); |
166 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) | 215 | if ( config->readBoolEntry( "EnableCustomFonts", false ) ) |
167 | { | 216 | { |
168 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); | 217 | mListView->setFont( config->readFontEntry( "TextFont", &f) ); |
169 | f.setBold( true ); | 218 | f.setBold( true ); |
170 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); | 219 | //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); |
171 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); | 220 | mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); |
172 | } | 221 | } |
173 | else | 222 | else |
174 | { | 223 | { |
175 | mListView->setFont( f ); | 224 | mListView->setFont( f ); |
176 | f.setBold( true ); | 225 | f.setBold( true ); |
177 | //US mListView->setHeaderFont( f ); | 226 | //US mListView->setHeaderFont( f ); |
178 | mListView->header()->setFont( f ); | 227 | mListView->header()->setFont( f ); |
179 | } | 228 | } |
180 | 229 | ||
181 | 230 | ||
182 | 231 | ||
183 | 232 | ||
184 | 233 | ||
185 | // Set the list view options | 234 | // Set the list view options |
186 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", | 235 | mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", |
187 | true)); | 236 | true)); |
188 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); | 237 | mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); |
189 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); | 238 | mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); |
190 | 239 | ||
191 | if (config->readBoolEntry("Background", false)) | 240 | if (config->readBoolEntry("Background", false)) |
192 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); | 241 | mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); |
193 | 242 | ||
194 | // Restore the layout of the listview | 243 | // Restore the layout of the listview |
195 | mListView->restoreLayout(config, config->group()); | 244 | mListView->restoreLayout(config, config->group()); |
196 | } | 245 | } |
197 | 246 | ||
198 | void KAddressBookTableView::refresh(QString uid) | 247 | void KAddressBookTableView::refresh(QString uid) |
199 | { | 248 | { |
200 | // For now just repopulate. In reality this method should | 249 | // For now just repopulate. In reality this method should |
201 | // check the value of uid, and if valid iterate through | 250 | // check the value of uid, and if valid iterate through |
202 | // the listview to find the entry, then tell it to refresh. | 251 | // the listview to find the entry, then tell it to refresh. |
203 | 252 | ||
204 | if (uid.isNull()) { | 253 | if (uid.isNull()) { |
205 | // Clear the list view | 254 | // Clear the list view |
206 | QString currentUID, nextUID; | 255 | QString currentUID, nextUID; |
207 | #ifndef KAB_EMBEDDED | 256 | #ifndef KAB_EMBEDDED |
208 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); | 257 | ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); |
209 | #else //KAB_EMBEDDED | 258 | #else //KAB_EMBEDDED |
210 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); | 259 | ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); |
211 | #endif //KAB_EMBEDDED | 260 | #endif //KAB_EMBEDDED |
212 | 261 | ||
213 | if ( currentItem ) { | 262 | if ( currentItem ) { |
214 | #ifndef KAB_EMBEDDED | 263 | #ifndef KAB_EMBEDDED |
215 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); | 264 | ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); |
216 | #else //KAB_EMBEDDED | 265 | #else //KAB_EMBEDDED |
217 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); | 266 | ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); |
218 | #endif //KAB_EMBEDDED | 267 | #endif //KAB_EMBEDDED |
219 | if ( nextItem ) | 268 | if ( nextItem ) |
220 | nextUID = nextItem->addressee().uid(); | 269 | nextUID = nextItem->addressee().uid(); |
221 | currentUID = currentItem->addressee().uid(); | 270 | currentUID = currentItem->addressee().uid(); |
222 | } | 271 | } |
223 | 272 | ||
224 | mListView->clear(); | 273 | mListView->clear(); |
225 | 274 | ||
226 | currentItem = 0; | 275 | currentItem = 0; |
227 | KABC::Addressee::List addresseeList = addressees(); | 276 | KABC::Addressee::List addresseeList = addressees(); |
228 | KABC::Addressee::List::Iterator it; | 277 | KABC::Addressee::List::Iterator it; |
229 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 278 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
230 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 279 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
231 | if ( (*it).uid() == currentUID ) | 280 | if ( (*it).uid() == currentUID ) |
232 | currentItem = item; | 281 | currentItem = item; |
233 | else if ( (*it).uid() == nextUID && !currentItem ) | 282 | else if ( (*it).uid() == nextUID && !currentItem ) |
234 | currentItem = item; | 283 | currentItem = item; |
235 | } | 284 | } |
236 | 285 | ||
237 | // Sometimes the background pixmap gets messed up when we add lots | 286 | // Sometimes the background pixmap gets messed up when we add lots |
238 | // of items. | 287 | // of items. |
239 | mListView->repaint(); | 288 | mListView->repaint(); |
240 | 289 | ||
241 | if ( currentItem ) { | 290 | if ( currentItem ) { |
242 | mListView->setCurrentItem( currentItem ); | 291 | mListView->setCurrentItem( currentItem ); |
243 | mListView->ensureItemVisible( currentItem ); | 292 | mListView->ensureItemVisible( currentItem ); |
244 | } | 293 | } |
245 | } else { | 294 | } else { |
246 | // Only need to update on entry. Iterate through and try to find it | 295 | // Only need to update on entry. Iterate through and try to find it |
247 | ContactListViewItem *ceItem; | 296 | ContactListViewItem *ceItem; |
248 | QListViewItemIterator it( mListView ); | 297 | QListViewItemIterator it( mListView ); |
249 | while ( it.current() ) { | 298 | while ( it.current() ) { |
250 | #ifndef KAB_EMBEDDED | 299 | #ifndef KAB_EMBEDDED |
251 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); | 300 | ceItem = dynamic_cast<ContactListViewItem*>( it.current() ); |
252 | #else //KAB_EMBEDDED | 301 | #else //KAB_EMBEDDED |
253 | ceItem = (ContactListViewItem*)( it.current() ); | 302 | ceItem = (ContactListViewItem*)( it.current() ); |
254 | #endif //KAB_EMBEDDED | 303 | #endif //KAB_EMBEDDED |
255 | 304 | ||
256 | if ( ceItem && ceItem->addressee().uid() == uid ) { | 305 | if ( ceItem && ceItem->addressee().uid() == uid ) { |
257 | ceItem->refresh(); | 306 | ceItem->refresh(); |
258 | return; | 307 | return; |
259 | } | 308 | } |
260 | ++it; | 309 | ++it; |
261 | } | 310 | } |
262 | 311 | ||
263 | refresh( QString::null ); | 312 | refresh( QString::null ); |
264 | } | 313 | } |
265 | } | 314 | } |
266 | 315 | ||
267 | QStringList KAddressBookTableView::selectedUids() | 316 | QStringList KAddressBookTableView::selectedUids() |
268 | { | 317 | { |
269 | QStringList uidList; | 318 | QStringList uidList; |
270 | QListViewItem *item; | 319 | QListViewItem *item; |
271 | ContactListViewItem *ceItem; | 320 | ContactListViewItem *ceItem; |
272 | 321 | ||
273 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 322 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
274 | { | 323 | { |
275 | if (mListView->isSelected( item )) | 324 | if (mListView->isSelected( item )) |
276 | { | 325 | { |
277 | #ifndef KAB_EMBEDDED | 326 | #ifndef KAB_EMBEDDED |
278 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 327 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
279 | #else //KAB_EMBEDDED | 328 | #else //KAB_EMBEDDED |
280 | ceItem = (ContactListViewItem*)(item); | 329 | ceItem = (ContactListViewItem*)(item); |
281 | #endif //KAB_EMBEDDED | 330 | #endif //KAB_EMBEDDED |
282 | 331 | ||
283 | if (ceItem != 0L) | 332 | if (ceItem != 0L) |
284 | uidList << ceItem->addressee().uid(); | 333 | uidList << ceItem->addressee().uid(); |
285 | } | 334 | } |
286 | } | 335 | } |
287 | if ( uidList.count() == 0 ) | 336 | if ( uidList.count() == 0 ) |
288 | if ( mListView->currentItem() ) { | 337 | if ( mListView->currentItem() ) { |
289 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; | 338 | ceItem = (ContactListViewItem*)(mListView->currentItem()) ; |
290 | uidList << ceItem->addressee().uid(); | 339 | uidList << ceItem->addressee().uid(); |
291 | } | 340 | } |
292 | 341 | ||
293 | return uidList; | 342 | return uidList; |
294 | } | 343 | } |
295 | 344 | ||
296 | void KAddressBookTableView::setSelected(QString uid, bool selected) | 345 | void KAddressBookTableView::setSelected(QString uid, bool selected) |
297 | { | 346 | { |
298 | QListViewItem *item; | 347 | QListViewItem *item; |
299 | ContactListViewItem *ceItem; | 348 | ContactListViewItem *ceItem; |
300 | 349 | ||
301 | if (uid.isNull()) | 350 | if (uid.isNull()) |
302 | { | 351 | { |
303 | mListView->selectAll(selected); | 352 | mListView->selectAll(selected); |
304 | } | 353 | } |
305 | else | 354 | else |
306 | { | 355 | { |
307 | for(item = mListView->firstChild(); item; item = item->itemBelow()) | 356 | for(item = mListView->firstChild(); item; item = item->itemBelow()) |
308 | { | 357 | { |
309 | #ifndef KAB_EMBEDDED | 358 | #ifndef KAB_EMBEDDED |
310 | ceItem = dynamic_cast<ContactListViewItem*>(item); | 359 | ceItem = dynamic_cast<ContactListViewItem*>(item); |
311 | #else //KAB_EMBEDDED | 360 | #else //KAB_EMBEDDED |
312 | ceItem = (ContactListViewItem*)(item); | 361 | ceItem = (ContactListViewItem*)(item); |
313 | #endif //KAB_EMBEDDED | 362 | #endif //KAB_EMBEDDED |
314 | 363 | ||
315 | 364 | ||
316 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) | 365 | if ((ceItem != 0L) && (ceItem->addressee().uid() == uid)) |
317 | { | 366 | { |
318 | mListView->setSelected(item, selected); | 367 | mListView->setSelected(item, selected); |
319 | 368 | ||
320 | if (selected) | 369 | if (selected) |
321 | mListView->ensureItemVisible(item); | 370 | mListView->ensureItemVisible(item); |
322 | } | 371 | } |
323 | } | 372 | } |
324 | } | 373 | } |
325 | } | 374 | } |
326 | 375 | ||
327 | void KAddressBookTableView::addresseeSelected() | 376 | void KAddressBookTableView::addresseeSelected() |
328 | { | 377 | { |
329 | // We need to try to find the first selected item. This might not be the | 378 | // We need to try to find the first selected item. This might not be the |
330 | // last selected item, but when QListView is in multiselection mode, | 379 | // last selected item, but when QListView is in multiselection mode, |
331 | // there is no way to figure out which one was | 380 | // there is no way to figure out which one was |
332 | // selected last. | 381 | // selected last. |
333 | QListViewItem *item; | 382 | QListViewItem *item; |
334 | bool found =false; | 383 | bool found =false; |
335 | for (item = mListView->firstChild(); item && !found; | 384 | for (item = mListView->firstChild(); item && !found; |
336 | item = item->nextSibling()) | 385 | item = item->nextSibling()) |
337 | { | 386 | { |
338 | if (item->isSelected()) | 387 | if (item->isSelected()) |
339 | { | 388 | { |
340 | found = true; | 389 | found = true; |
341 | #ifndef KAB_EMBEDDED | 390 | #ifndef KAB_EMBEDDED |
342 | ContactListViewItem *ceItem | 391 | ContactListViewItem *ceItem |
343 | = dynamic_cast<ContactListViewItem*>(item); | 392 | = dynamic_cast<ContactListViewItem*>(item); |
344 | #else //KAB_EMBEDDED | 393 | #else //KAB_EMBEDDED |
345 | ContactListViewItem *ceItem | 394 | ContactListViewItem *ceItem |
346 | = (ContactListViewItem*)(item); | 395 | = (ContactListViewItem*)(item); |
347 | #endif //KAB_EMBEDDED | 396 | #endif //KAB_EMBEDDED |
348 | 397 | ||
349 | if ( ceItem ) emit selected(ceItem->addressee().uid()); | 398 | if ( ceItem ) emit selected(ceItem->addressee().uid()); |
350 | } | 399 | } |
351 | } | 400 | } |
352 | 401 | ||
353 | if (!found) | 402 | if (!found) |
354 | emit selected(QString::null); | 403 | emit selected(QString::null); |
355 | } | 404 | } |
356 | 405 | ||
357 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) | 406 | void KAddressBookTableView::addresseeExecuted(QListViewItem *item) |
358 | { | 407 | { |
359 | if (item) | 408 | if (item) |
360 | { | 409 | { |
361 | #ifndef KAB_EMBEDDED | 410 | #ifndef KAB_EMBEDDED |
362 | ContactListViewItem *ceItem | 411 | ContactListViewItem *ceItem |
363 | = dynamic_cast<ContactListViewItem*>(item); | 412 | = dynamic_cast<ContactListViewItem*>(item); |
364 | #else //KAB_EMBEDDED | 413 | #else //KAB_EMBEDDED |
365 | ContactListViewItem *ceItem | 414 | ContactListViewItem *ceItem |
366 | = (ContactListViewItem*)(item); | 415 | = (ContactListViewItem*)(item); |
367 | #endif //KAB_EMBEDDED | 416 | #endif //KAB_EMBEDDED |
368 | 417 | ||
369 | if (ceItem) | 418 | if (ceItem) |
370 | { | 419 | { |
371 | emit executed(ceItem->addressee().uid()); | 420 | emit executed(ceItem->addressee().uid()); |
372 | } | 421 | } |
373 | } | 422 | } |
374 | else | 423 | else |
375 | { | 424 | { |
376 | emit executed(QString::null); | 425 | emit executed(QString::null); |
377 | } | 426 | } |
378 | } | 427 | } |
379 | 428 | ||
380 | void KAddressBookTableView::addresseeDeleted() | 429 | void KAddressBookTableView::addresseeDeleted() |
381 | { | 430 | { |
382 | 431 | ||
383 | emit deleteRequest(); | 432 | emit deleteRequest(); |
384 | 433 | ||
385 | } | 434 | } |
386 | 435 | ||
387 | 436 | ||
388 | 437 | ||
389 | 438 | ||
390 | 439 | ||
391 | #ifndef KAB_EMBEDDED | 440 | #ifndef KAB_EMBEDDED |
392 | #include "kaddressbooktableview.moc" | 441 | #include "kaddressbooktableview.moc" |
393 | #endif //KAB_EMBEDDED | 442 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/views/kaddressbooktableview.h b/kaddressbook/views/kaddressbooktableview.h index bb991bc..ecfe7a1 100644 --- a/kaddressbook/views/kaddressbooktableview.h +++ b/kaddressbook/views/kaddressbooktableview.h | |||
@@ -1,114 +1,115 @@ | |||
1 | #ifndef KADDRESSBOOKTABLEVIEW_H | 1 | #ifndef KADDRESSBOOKTABLEVIEW_H |
2 | #define KADDRESSBOOKTABLEVIEW_H | 2 | #define KADDRESSBOOKTABLEVIEW_H |
3 | 3 | ||
4 | 4 | ||
5 | #ifndef KAB_EMBEDDED | 5 | #ifndef KAB_EMBEDDED |
6 | 6 | ||
7 | 7 | ||
8 | #ifdef HAVE_CONFIG_H | 8 | #ifdef HAVE_CONFIG_H |
9 | #include <config.h> | 9 | #include <config.h> |
10 | #endif | 10 | #endif |
11 | 11 | ||
12 | #include <qwidget.h> | 12 | #include <qwidget.h> |
13 | #include <qlistview.h> | 13 | #include <qlistview.h> |
14 | #include <qstring.h> | 14 | #include <qstring.h> |
15 | #include <qdialog.h> | 15 | #include <qdialog.h> |
16 | #include <qtabdialog.h> | 16 | #include <qtabdialog.h> |
17 | #include <qstringlist.h> | 17 | #include <qstringlist.h> |
18 | #include <qvaluelist.h> | 18 | #include <qvaluelist.h> |
19 | 19 | ||
20 | #include "undo.h" | 20 | #include "undo.h" |
21 | 21 | ||
22 | #else //KAB_EMBEDDED | 22 | #else //KAB_EMBEDDED |
23 | #include "views/configuretableviewdialog.h" | 23 | #include "views/configuretableviewdialog.h" |
24 | #endif //KAB_EMBEDDED | 24 | #endif //KAB_EMBEDDED |
25 | 25 | ||
26 | #include "klocale.h" | 26 | #include "klocale.h" |
27 | #include "kaddressbookview.h" | 27 | #include "kaddressbookview.h" |
28 | 28 | ||
29 | class QListViewItem; | 29 | class QListViewItem; |
30 | class QListBox; | 30 | class QListBox; |
31 | class QVBoxLayout; | 31 | class QVBoxLayout; |
32 | class KConfig; | 32 | class KConfig; |
33 | 33 | ||
34 | class ContactListViewItem; | 34 | class ContactListViewItem; |
35 | class ContactListView; | 35 | class ContactListView; |
36 | 36 | ||
37 | 37 | ||
38 | namespace KABC { class AddressBook; } | 38 | namespace KABC { class AddressBook; } |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * This class is the table view for kaddressbook. This view is a KListView | 41 | * This class is the table view for kaddressbook. This view is a KListView |
42 | * with multiple columns for the selected fields. | 42 | * with multiple columns for the selected fields. |
43 | * | 43 | * |
44 | * @short Table View | 44 | * @short Table View |
45 | * @author Don Sanders <dsanders@kde.org> | 45 | * @author Don Sanders <dsanders@kde.org> |
46 | * @version 0.1 | 46 | * @version 0.1 |
47 | */ | 47 | */ |
48 | class KAddressBookTableView : public KAddressBookView | 48 | class KAddressBookTableView : public KAddressBookView |
49 | { | 49 | { |
50 | friend class ContactListView; | 50 | friend class ContactListView; |
51 | 51 | ||
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | public: | 54 | public: |
55 | KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent, | 55 | KAddressBookTableView( KABC::AddressBook *ab, QWidget *parent, |
56 | const char *name = 0 ); | 56 | const char *name = 0 ); |
57 | virtual ~KAddressBookTableView(); | 57 | virtual ~KAddressBookTableView(); |
58 | 58 | ||
59 | virtual void refresh(QString uid = QString::null); | 59 | virtual void refresh(QString uid = QString::null); |
60 | virtual QStringList selectedUids(); | 60 | virtual QStringList selectedUids(); |
61 | virtual void setSelected(QString uid = QString::null, bool selected = false); | 61 | virtual void setSelected(QString uid = QString::null, bool selected = false); |
62 | virtual void readConfig(KConfig *config); | 62 | virtual void readConfig(KConfig *config); |
63 | virtual void writeConfig(KConfig *config); | 63 | virtual void writeConfig(KConfig *config); |
64 | virtual QString type() const { return "Table"; } | 64 | virtual QString type() const { return "Table"; } |
65 | void doSearch( const QString& s ,KABC::Field *field ); | ||
65 | 66 | ||
66 | public slots: | 67 | public slots: |
67 | virtual void reconstructListView(); | 68 | virtual void reconstructListView(); |
68 | 69 | ||
69 | protected slots: | 70 | protected slots: |
70 | /** Called whenever the user selects an addressee in the list view. | 71 | /** Called whenever the user selects an addressee in the list view. |
71 | */ | 72 | */ |
72 | void addresseeSelected(); | 73 | void addresseeSelected(); |
73 | void addresseeDeleted(); | 74 | void addresseeDeleted(); |
74 | 75 | ||
75 | /** Called whenever the user executes an addressee. In terms of the | 76 | /** Called whenever the user executes an addressee. In terms of the |
76 | * list view, this is probably a double click | 77 | * list view, this is probably a double click |
77 | */ | 78 | */ |
78 | void addresseeExecuted(QListViewItem*); | 79 | void addresseeExecuted(QListViewItem*); |
79 | 80 | ||
80 | private: | 81 | private: |
81 | QVBoxLayout *mainLayout; | 82 | QVBoxLayout *mainLayout; |
82 | ContactListView *mListView; | 83 | ContactListView *mListView; |
83 | }; | 84 | }; |
84 | 85 | ||
85 | 86 | ||
86 | class TableViewFactory : public ViewFactory | 87 | class TableViewFactory : public ViewFactory |
87 | { | 88 | { |
88 | public: | 89 | public: |
89 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) | 90 | KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) |
90 | { | 91 | { |
91 | return new KAddressBookTableView( ab, parent, name ); | 92 | return new KAddressBookTableView( ab, parent, name ); |
92 | } | 93 | } |
93 | 94 | ||
94 | QString type() const { return "Table"; } | 95 | QString type() const { return "Table"; } |
95 | 96 | ||
96 | QString description() const { return i18n( "A listing of contacts in a table. Each cell of " | 97 | QString description() const { return i18n( "A listing of contacts in a table. Each cell of " |
97 | "the table holds a field of the contact." ); } | 98 | "the table holds a field of the contact." ); } |
98 | 99 | ||
99 | ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, | 100 | ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent, |
100 | const char *name = 0 ) | 101 | const char *name = 0 ) |
101 | { | 102 | { |
102 | return new ConfigureTableViewWidget( ab, parent, name ); | 103 | return new ConfigureTableViewWidget( ab, parent, name ); |
103 | } | 104 | } |
104 | }; | 105 | }; |
105 | /*US | 106 | /*US |
106 | extern "C" { | 107 | extern "C" { |
107 | void *init_libkaddrbk_tableview() | 108 | void *init_libkaddrbk_tableview() |
108 | { | 109 | { |
109 | return ( new TableViewFactory ); | 110 | return ( new TableViewFactory ); |
110 | } | 111 | } |
111 | } | 112 | } |
112 | */ | 113 | */ |
113 | 114 | ||
114 | #endif | 115 | #endif |