author | zautrix <zautrix> | 2004-10-28 07:46:21 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-28 07:46:21 (UTC) |
commit | aada2527dee908aa96bfc16f5faddd3b29372bee (patch) (unidiff) | |
tree | 7ca9bbe5dc64684ec94110becf63d80ae9ad0edd /kaddressbook/viewmanager.cpp | |
parent | 2fe1a56682ef4dc1fa0a30f764c7313b583631c5 (diff) | |
download | kdepimpi-aada2527dee908aa96bfc16f5faddd3b29372bee.zip kdepimpi-aada2527dee908aa96bfc16f5faddd3b29372bee.tar.gz kdepimpi-aada2527dee908aa96bfc16f5faddd3b29372bee.tar.bz2 |
compile fixes
Diffstat (limited to 'kaddressbook/viewmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/viewmanager.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index 3d0c275..0d91c12 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp | |||
@@ -1,237 +1,237 @@ | |||
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 | void ViewManager::scrollUP() | 88 | void ViewManager::scrollUP() |
89 | { | 89 | { |
90 | if ( mActiveView ) | 90 | if ( mActiveView ) |
91 | mActiveView->scrollUP(); | 91 | mActiveView->scrollUP(); |
92 | } | 92 | } |
93 | void ViewManager::scrollDOWN() | 93 | void ViewManager::scrollDOWN() |
94 | { | 94 | { |
95 | if ( mActiveView ) | 95 | if ( mActiveView ) |
96 | mActiveView->scrollDOWN(); | 96 | mActiveView->scrollDOWN(); |
97 | } | 97 | } |
98 | void ViewManager::restoreSettings() | 98 | void ViewManager::restoreSettings() |
99 | { | 99 | { |
100 | mViewNameList = KABPrefs::instance()->mViewNames; | 100 | mViewNameList = KABPrefs::instance()->mViewNames; |
101 | QString activeViewName = KABPrefs::instance()->mCurrentView; | 101 | QString activeViewName = KABPrefs::instance()->mCurrentView; |
102 | 102 | ||
103 | mActionSelectView->setItems( mViewNameList ); | 103 | mActionSelectView->setItems( mViewNameList ); |
104 | 104 | ||
105 | // Filter | 105 | // Filter |
106 | mFilterList = Filter::restore( mCore->config(), "Filter" ); | 106 | mFilterList = Filter::restore( mCore->config(), "Filter" ); |
107 | mActionSelectFilter->setItems( filterNames() ); | 107 | mActionSelectFilter->setItems( filterNames() ); |
108 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); | 108 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); |
109 | mActionSelectFilter->setComboWidth( 100 ); | 109 | mActionSelectFilter->setComboWidth( 150 ); |
110 | // Tell the views to reread their config, since they may have | 110 | // Tell the views to reread their config, since they may have |
111 | // been modified by global settings | 111 | // been modified by global settings |
112 | QString _oldgroup = mCore->config()->group(); | 112 | QString _oldgroup = mCore->config()->group(); |
113 | 113 | ||
114 | QDictIterator<KAddressBookView> it( mViewDict ); | 114 | QDictIterator<KAddressBookView> it( mViewDict ); |
115 | for ( it.toFirst(); it.current(); ++it ) { | 115 | for ( it.toFirst(); it.current(); ++it ) { |
116 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 116 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
117 | it.current()->readConfig( mCore->config() ); | 117 | it.current()->readConfig( mCore->config() ); |
118 | } | 118 | } |
119 | setActiveView( activeViewName ); | 119 | setActiveView( activeViewName ); |
120 | 120 | ||
121 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 121 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
122 | } | 122 | } |
123 | 123 | ||
124 | void ViewManager::saveSettings() | 124 | void ViewManager::saveSettings() |
125 | { | 125 | { |
126 | QString _oldgroup = mCore->config()->group(); | 126 | QString _oldgroup = mCore->config()->group(); |
127 | 127 | ||
128 | QDictIterator<KAddressBookView> it( mViewDict ); | 128 | QDictIterator<KAddressBookView> it( mViewDict ); |
129 | for ( it.toFirst(); it.current(); ++it ) { | 129 | for ( it.toFirst(); it.current(); ++it ) { |
130 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 130 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
131 | #ifdef DESKTOP_VERSION | 131 | #ifdef DESKTOP_VERSION |
132 | (*it)->writeConfig( mCore->config() ); | 132 | (*it)->writeConfig( mCore->config() ); |
133 | #else | 133 | #else |
134 | (*it).writeConfig( mCore->config() ); | 134 | (*it).writeConfig( mCore->config() ); |
135 | #endif | 135 | #endif |
136 | } | 136 | } |
137 | 137 | ||
138 | Filter::save( mCore->config(), "Filter", mFilterList ); | 138 | Filter::save( mCore->config(), "Filter", mFilterList ); |
139 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); | 139 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); |
140 | 140 | ||
141 | // write the view name list | 141 | // write the view name list |
142 | KABPrefs::instance()->mViewNames = mViewNameList; | 142 | KABPrefs::instance()->mViewNames = mViewNameList; |
143 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); | 143 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); |
144 | 144 | ||
145 | } | 145 | } |
146 | 146 | ||
147 | QStringList ViewManager::selectedUids() const | 147 | QStringList ViewManager::selectedUids() const |
148 | { | 148 | { |
149 | if ( mActiveView ) | 149 | if ( mActiveView ) |
150 | return mActiveView->selectedUids(); | 150 | return mActiveView->selectedUids(); |
151 | else | 151 | else |
152 | return QStringList(); | 152 | return QStringList(); |
153 | } | 153 | } |
154 | 154 | ||
155 | QStringList ViewManager::selectedEmails() const | 155 | QStringList ViewManager::selectedEmails() const |
156 | { | 156 | { |
157 | if ( mActiveView ) | 157 | if ( mActiveView ) |
158 | return mActiveView->selectedEmails(); | 158 | return mActiveView->selectedEmails(); |
159 | else | 159 | else |
160 | return QStringList(); | 160 | return QStringList(); |
161 | } | 161 | } |
162 | 162 | ||
163 | KABC::Addressee::List ViewManager::selectedAddressees() const | 163 | KABC::Addressee::List ViewManager::selectedAddressees() const |
164 | { | 164 | { |
165 | KABC::Addressee::List list; | 165 | KABC::Addressee::List list; |
166 | if ( mActiveView ) { | 166 | if ( mActiveView ) { |
167 | QStringList uids = mActiveView->selectedUids(); | 167 | QStringList uids = mActiveView->selectedUids(); |
168 | QStringList::Iterator it; | 168 | QStringList::Iterator it; |
169 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 169 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
170 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); | 170 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); |
171 | if ( !addr.isEmpty() ) | 171 | if ( !addr.isEmpty() ) |
172 | list.append( addr ); | 172 | list.append( addr ); |
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | return list; | 176 | return list; |
177 | } | 177 | } |
178 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 178 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
179 | void ViewManager::setSelected() | 179 | void ViewManager::setSelected() |
180 | { | 180 | { |
181 | setSelected( QString::null, true ); | 181 | setSelected( QString::null, true ); |
182 | } | 182 | } |
183 | 183 | ||
184 | void ViewManager::setSelected( const QString &uid, bool selected ) | 184 | void ViewManager::setSelected( const QString &uid, bool selected ) |
185 | { | 185 | { |
186 | if ( mActiveView ) | 186 | if ( mActiveView ) |
187 | mActiveView->setSelected( uid, selected ); | 187 | mActiveView->setSelected( uid, selected ); |
188 | } | 188 | } |
189 | 189 | ||
190 | void ViewManager::setListSelected(QStringList list) | 190 | void ViewManager::setListSelected(QStringList list) |
191 | { | 191 | { |
192 | int i, count = list.count(); | 192 | int i, count = list.count(); |
193 | for ( i = 0; i < count;++i ) | 193 | for ( i = 0; i < count;++i ) |
194 | setSelected( list[i], true ); | 194 | setSelected( list[i], true ); |
195 | 195 | ||
196 | } | 196 | } |
197 | void ViewManager::unloadViews() | 197 | void ViewManager::unloadViews() |
198 | { | 198 | { |
199 | mViewDict.clear(); | 199 | mViewDict.clear(); |
200 | mActiveView = 0; | 200 | mActiveView = 0; |
201 | } | 201 | } |
202 | 202 | ||
203 | void ViewManager::setActiveView( const QString &name ) | 203 | void ViewManager::setActiveView( const QString &name ) |
204 | { | 204 | { |
205 | KAddressBookView *view = 0; | 205 | KAddressBookView *view = 0; |
206 | 206 | ||
207 | // Check that this isn't the same as the current active view | 207 | // Check that this isn't the same as the current active view |
208 | if ( mActiveView && ( mActiveView->caption() == name ) ) | 208 | if ( mActiveView && ( mActiveView->caption() == name ) ) |
209 | return; | 209 | return; |
210 | 210 | ||
211 | // At this point we know the view that should be active is not | 211 | // At this point we know the view that should be active is not |
212 | // currently active. We will try to find the new on in the list. If | 212 | // currently active. We will try to find the new on in the list. If |
213 | // we can't find it, it means it hasn't been instantiated, so we will | 213 | // we can't find it, it means it hasn't been instantiated, so we will |
214 | // create it on demand. | 214 | // create it on demand. |
215 | 215 | ||
216 | view = mViewDict.find( name ); | 216 | view = mViewDict.find( name ); |
217 | 217 | ||
218 | // Check if we found the view. If we didn't, then we need to create it | 218 | // Check if we found the view. If we didn't, then we need to create it |
219 | if ( view == 0 ) { | 219 | if ( view == 0 ) { |
220 | KConfig *config = mCore->config(); | 220 | KConfig *config = mCore->config(); |
221 | 221 | ||
222 | KConfigGroupSaver saver( config, name ); | 222 | KConfigGroupSaver saver( config, name ); |
223 | 223 | ||
224 | QString type = config->readEntry( "Type", "Table" ); | 224 | QString type = config->readEntry( "Type", "Table" ); |
225 | 225 | ||
226 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; | 226 | kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; |
227 | 227 | ||
228 | ViewFactory *factory = mViewFactoryDict.find( type ); | 228 | ViewFactory *factory = mViewFactoryDict.find( type ); |
229 | if ( factory ) | 229 | if ( factory ) |
230 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); | 230 | view = factory->view( mCore->addressBook(), mViewWidgetStack ); |
231 | 231 | ||
232 | if ( view ) { | 232 | if ( view ) { |
233 | view->setCaption( name ); | 233 | view->setCaption( name ); |
234 | mViewDict.insert( name, view ); | 234 | mViewDict.insert( name, view ); |
235 | //US my version needs an int as second parameter to addWidget | 235 | //US my version needs an int as second parameter to addWidget |
236 | mViewWidgetStack->addWidget( view, -1 ); | 236 | mViewWidgetStack->addWidget( view, -1 ); |
237 | view->readConfig( config ); | 237 | view->readConfig( config ); |
@@ -472,247 +472,247 @@ void ViewManager::createViewFactories() | |||
472 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 472 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
473 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 473 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
474 | 474 | ||
475 | viewFactory = new TableViewFactory(); | 475 | viewFactory = new TableViewFactory(); |
476 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 476 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
477 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 477 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
478 | 478 | ||
479 | viewFactory = new CardViewFactory(); | 479 | viewFactory = new CardViewFactory(); |
480 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); | 480 | mViewFactoryDict.insert( viewFactory->type(), viewFactory ); |
481 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); | 481 | // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); |
482 | 482 | ||
483 | #endif //KAB_EMBEDDED | 483 | #endif //KAB_EMBEDDED |
484 | 484 | ||
485 | } | 485 | } |
486 | 486 | ||
487 | void ViewManager::dropped( QDropEvent *e ) | 487 | void ViewManager::dropped( QDropEvent *e ) |
488 | { | 488 | { |
489 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; | 489 | kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl; |
490 | 490 | ||
491 | #ifndef KAB_EMBEDDED | 491 | #ifndef KAB_EMBEDDED |
492 | 492 | ||
493 | QString clipText, vcards; | 493 | QString clipText, vcards; |
494 | KURL::List urls; | 494 | KURL::List urls; |
495 | 495 | ||
496 | if ( KURLDrag::decode( e, urls) ) { | 496 | if ( KURLDrag::decode( e, urls) ) { |
497 | KURL::List::Iterator it = urls.begin(); | 497 | KURL::List::Iterator it = urls.begin(); |
498 | int c = urls.count(); | 498 | int c = urls.count(); |
499 | if ( c > 1 ) { | 499 | if ( c > 1 ) { |
500 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); | 500 | QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); |
501 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { | 501 | if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { |
502 | for ( ; it != urls.end(); ++it ) | 502 | for ( ; it != urls.end(); ++it ) |
503 | emit urlDropped( *it ); | 503 | emit urlDropped( *it ); |
504 | } | 504 | } |
505 | } else if ( c == 1 ) | 505 | } else if ( c == 1 ) |
506 | emit urlDropped( *it ); | 506 | emit urlDropped( *it ); |
507 | } else if ( KVCardDrag::decode( e, vcards ) ) { | 507 | } else if ( KVCardDrag::decode( e, vcards ) ) { |
508 | KABC::Addressee addr; | 508 | KABC::Addressee addr; |
509 | KABC::VCardConverter converter; | 509 | KABC::VCardConverter converter; |
510 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); | 510 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); |
511 | QStringList::Iterator it; | 511 | QStringList::Iterator it; |
512 | for ( it = list.begin(); it != list.end(); ++it ) { | 512 | for ( it = list.begin(); it != list.end(); ++it ) { |
513 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { | 513 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { |
514 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); | 514 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); |
515 | if ( a.isEmpty() ) { | 515 | if ( a.isEmpty() ) { |
516 | mCore->addressBook()->insertAddressee( addr ); | 516 | mCore->addressBook()->insertAddressee( addr ); |
517 | emit modified(); | 517 | emit modified(); |
518 | } | 518 | } |
519 | } | 519 | } |
520 | } | 520 | } |
521 | 521 | ||
522 | mActiveView->refresh(); | 522 | mActiveView->refresh(); |
523 | } | 523 | } |
524 | #else //KAB_EMBEDDED | 524 | #else //KAB_EMBEDDED |
525 | qDebug("ViewManager::dropped() has to be changed!!" ); | 525 | qDebug("ViewManager::dropped() has to be changed!!" ); |
526 | #endif //KAB_EMBEDDED | 526 | #endif //KAB_EMBEDDED |
527 | 527 | ||
528 | } | 528 | } |
529 | 529 | ||
530 | void ViewManager::startDrag() | 530 | void ViewManager::startDrag() |
531 | { | 531 | { |
532 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; | 532 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; |
533 | 533 | ||
534 | #ifndef KAB_EMBEDDED | 534 | #ifndef KAB_EMBEDDED |
535 | 535 | ||
536 | // Get the list of all the selected addressees | 536 | // Get the list of all the selected addressees |
537 | KABC::Addressee::List addrList; | 537 | KABC::Addressee::List addrList; |
538 | QStringList uidList = selectedUids(); | 538 | QStringList uidList = selectedUids(); |
539 | QStringList::Iterator iter; | 539 | QStringList::Iterator iter; |
540 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) | 540 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) |
541 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); | 541 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); |
542 | 542 | ||
543 | KMultipleDrag *drag = new KMultipleDrag( this ); | 543 | KMultipleDrag *drag = new KMultipleDrag( this ); |
544 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); | 544 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); |
545 | KABC::Addressee::List::Iterator it; | 545 | KABC::Addressee::List::Iterator it; |
546 | QStringList vcards; | 546 | QStringList vcards; |
547 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { | 547 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { |
548 | QString vcard = QString::null; | 548 | QString vcard = QString::null; |
549 | KABC::VCardConverter converter; | 549 | KABC::VCardConverter converter; |
550 | if ( converter.addresseeToVCard( *it, vcard ) ) | 550 | if ( converter.addresseeToVCard( *it, vcard ) ) |
551 | vcards.append( vcard ); | 551 | vcards.append( vcard ); |
552 | } | 552 | } |
553 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); | 553 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); |
554 | 554 | ||
555 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); | 555 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); |
556 | drag->dragCopy(); | 556 | drag->dragCopy(); |
557 | 557 | ||
558 | #else //KAB_EMBEDDED | 558 | #else //KAB_EMBEDDED |
559 | qDebug("ViewManager::startDrag() has to be changed!!" ); | 559 | qDebug("ViewManager::startDrag() has to be changed!!" ); |
560 | #endif //KAB_EMBEDDED | 560 | #endif //KAB_EMBEDDED |
561 | 561 | ||
562 | } | 562 | } |
563 | void ViewManager::doSearch( const QString& s,KABC::Field *field ) | 563 | void ViewManager::doSearch( const QString& s,KABC::Field *field ) |
564 | { | 564 | { |
565 | if ( mActiveView ) | 565 | if ( mActiveView ) |
566 | mActiveView->doSearch( s, field ); | 566 | mActiveView->doSearch( s, field ); |
567 | 567 | ||
568 | } | 568 | } |
569 | void ViewManager::setActiveFilter( int index ) | 569 | void ViewManager::setActiveFilter( int index ) |
570 | { | 570 | { |
571 | Filter currentFilter; | 571 | Filter currentFilter; |
572 | 572 | ||
573 | if ( ( index - 1 ) < 0 ) | 573 | if ( ( index - 1 ) < 0 ) |
574 | currentFilter = Filter(); | 574 | currentFilter = Filter(); |
575 | else | 575 | else |
576 | currentFilter = mFilterList[ index - 1 ]; | 576 | currentFilter = mFilterList[ index - 1 ]; |
577 | 577 | ||
578 | // Check if we have a view. Since the filter combo is created before | 578 | // Check if we have a view. Since the filter combo is created before |
579 | // the view, this slot could be called before there is a valid view. | 579 | // the view, this slot could be called before there is a valid view. |
580 | if ( mActiveView ) { | 580 | if ( mActiveView ) { |
581 | mActiveView->setFilter( currentFilter ); | 581 | mActiveView->setFilter( currentFilter ); |
582 | mActiveView->refresh(); | 582 | mActiveView->refresh(); |
583 | emit selected( QString::null ); | 583 | emit selected( QString::null ); |
584 | } | 584 | } |
585 | } | 585 | } |
586 | 586 | ||
587 | void ViewManager::configureFilters() | 587 | void ViewManager::configureFilters() |
588 | { | 588 | { |
589 | FilterDialog dlg( this ); | 589 | FilterDialog dlg( this ); |
590 | 590 | ||
591 | dlg.setFilters( mFilterList ); | 591 | dlg.setFilters( mFilterList ); |
592 | 592 | ||
593 | if ( dlg.exec() ) | 593 | if ( dlg.exec() ) |
594 | mFilterList = dlg.filters(); | 594 | mFilterList = dlg.filters(); |
595 | 595 | ||
596 | uint pos = mActionSelectFilter->currentItem(); | 596 | uint pos = mActionSelectFilter->currentItem(); |
597 | mActionSelectFilter->setItems( filterNames() ); | 597 | mActionSelectFilter->setItems( filterNames() ); |
598 | mActionSelectFilter->setCurrentItem( pos ); | 598 | mActionSelectFilter->setCurrentItem( pos ); |
599 | setActiveFilter( pos ); | 599 | setActiveFilter( pos ); |
600 | //mActionSelectFilter->setComboWidth( 150 ); | 600 | mActionSelectFilter->setComboWidth( 150 ); |
601 | } | 601 | } |
602 | 602 | ||
603 | QStringList ViewManager::filterNames() const | 603 | QStringList ViewManager::filterNames() const |
604 | { | 604 | { |
605 | QStringList names( i18n( "No Filter" ) ); | 605 | QStringList names( i18n( "No Filter" ) ); |
606 | 606 | ||
607 | Filter::List::ConstIterator it; | 607 | Filter::List::ConstIterator it; |
608 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) | 608 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) |
609 | names.append( (*it).name() ); | 609 | names.append( (*it).name() ); |
610 | 610 | ||
611 | return names; | 611 | return names; |
612 | } | 612 | } |
613 | 613 | ||
614 | int ViewManager::filterPosition( const QString &name ) const | 614 | int ViewManager::filterPosition( const QString &name ) const |
615 | { | 615 | { |
616 | int pos = 0; | 616 | int pos = 0; |
617 | 617 | ||
618 | Filter::List::ConstIterator it; | 618 | Filter::List::ConstIterator it; |
619 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) | 619 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) |
620 | if ( name == (*it).name() ) | 620 | if ( name == (*it).name() ) |
621 | return pos + 1; | 621 | return pos + 1; |
622 | 622 | ||
623 | return 0; | 623 | return 0; |
624 | } | 624 | } |
625 | 625 | ||
626 | void ViewManager::initActions() | 626 | void ViewManager::initActions() |
627 | { | 627 | { |
628 | //US <ActionList name="view_loadedviews"/> | 628 | //US <ActionList name="view_loadedviews"/> |
629 | //US <Separator/> | 629 | //US <Separator/> |
630 | 630 | ||
631 | #ifdef KAB_EMBEDDED | 631 | #ifdef KAB_EMBEDDED |
632 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); | 632 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); |
633 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); | 633 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); |
634 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); | 634 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); |
635 | #endif //KAB_EMBEDDED | 635 | #endif //KAB_EMBEDDED |
636 | 636 | ||
637 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); | 637 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); |
638 | #if KDE_VERSION >= 309 | 638 | #if KDE_VERSION >= 309 |
639 | mActionSelectView->setMenuAccelsEnabled( false ); | 639 | mActionSelectView->setMenuAccelsEnabled( false ); |
640 | #endif | 640 | #endif |
641 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), | 641 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), |
642 | SLOT( setActiveView( const QString& ) ) ); | 642 | SLOT( setActiveView( const QString& ) ) ); |
643 | 643 | ||
644 | 644 | ||
645 | #ifdef KAB_EMBEDDED | 645 | #ifdef KAB_EMBEDDED |
646 | mActionSelectView->plug(viewmenu); | 646 | mActionSelectView->plug(viewmenu); |
647 | viewmenu->insertSeparator(); | 647 | viewmenu->insertSeparator(); |
648 | #endif //KAB_EMBEDDED | 648 | #endif //KAB_EMBEDDED |
649 | 649 | ||
650 | KAction *action; | 650 | KAction *action; |
651 | 651 | ||
652 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, | 652 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, |
653 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); | 653 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); |
654 | #ifndef KAB_EMBEDDED | 654 | #ifndef KAB_EMBEDDED |
655 | 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." ) ); | 655 | 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." ) ); |
656 | #else //KAB_EMBEDDED | 656 | #else //KAB_EMBEDDED |
657 | action->plug(viewmenu); | 657 | action->plug(viewmenu); |
658 | #endif //KAB_EMBEDDED | 658 | #endif //KAB_EMBEDDED |
659 | 659 | ||
660 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, | 660 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, |
661 | SLOT( addView() ), mCore->actionCollection(), "view_add" ); | 661 | SLOT( addView() ), mCore->actionCollection(), "view_add" ); |
662 | #ifndef KAB_EMBEDDED | 662 | #ifndef KAB_EMBEDDED |
663 | 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." ) ); | 663 | 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." ) ); |
664 | #else //KAB_EMBEDDED | 664 | #else //KAB_EMBEDDED |
665 | action->plug(viewmenu); | 665 | action->plug(viewmenu); |
666 | #endif //KAB_EMBEDDED | 666 | #endif //KAB_EMBEDDED |
667 | 667 | ||
668 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, | 668 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, |
669 | this, SLOT( deleteView() ), | 669 | this, SLOT( deleteView() ), |
670 | mCore->actionCollection(), "view_delete" ); | 670 | mCore->actionCollection(), "view_delete" ); |
671 | #ifndef KAB_EMBEDDED | 671 | #ifndef KAB_EMBEDDED |
672 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); | 672 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); |
673 | #else //KAB_EMBEDDED | 673 | #else //KAB_EMBEDDED |
674 | mActionDeleteView->plug(viewmenu); | 674 | mActionDeleteView->plug(viewmenu); |
675 | viewmenu->insertSeparator(); | 675 | viewmenu->insertSeparator(); |
676 | #endif //KAB_EMBEDDED | 676 | #endif //KAB_EMBEDDED |
677 | 677 | ||
678 | #ifndef KAB_EMBEDDED | 678 | #ifndef KAB_EMBEDDED |
679 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, | 679 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, |
680 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), | 680 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), |
681 | "view_refresh" ); | 681 | "view_refresh" ); |
682 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); | 682 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); |
683 | #else //KAB_EMBEDDED | 683 | #else //KAB_EMBEDDED |
684 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, | 684 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, |
685 | SLOT( refreshView()), mCore->actionCollection(), | 685 | SLOT( refreshView()), mCore->actionCollection(), |
686 | "view_refresh" ); | 686 | "view_refresh" ); |
687 | action->plug(viewmenu); | 687 | action->plug(viewmenu); |
688 | viewmenu->insertSeparator(); | 688 | viewmenu->insertSeparator(); |
689 | #endif //KAB_EMBEDDED | 689 | #endif //KAB_EMBEDDED |
690 | 690 | ||
691 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, | 691 | action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, |
692 | SLOT( configureFilters() ), mCore->actionCollection(), | 692 | SLOT( configureFilters() ), mCore->actionCollection(), |
693 | "options_edit_filters" ); | 693 | "options_edit_filters" ); |
694 | 694 | ||
695 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); | 695 | mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); |
696 | #if KDE_VERSION >= 309 | 696 | #if KDE_VERSION >= 309 |
697 | mActionSelectFilter->setMenuAccelsEnabled( false ); | 697 | mActionSelectFilter->setMenuAccelsEnabled( false ); |
698 | #endif | 698 | #endif |
699 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), | 699 | connect( mActionSelectFilter, SIGNAL( activated( int ) ), |
700 | SLOT( setActiveFilter( int ) ) ); | 700 | SLOT( setActiveFilter( int ) ) ); |
701 | 701 | ||
702 | #ifdef KAB_EMBEDDED | 702 | #ifdef KAB_EMBEDDED |
703 | action->plug(settingsmenu); | 703 | action->plug(settingsmenu); |
704 | mActionSelectFilter->plug(viewmenu); | 704 | mActionSelectFilter->plug(viewmenu); |
705 | #endif //KAB_EMBEDDED | 705 | #endif //KAB_EMBEDDED |
706 | 706 | ||
707 | } | 707 | } |
708 | 708 | ||
709 | void ViewManager::initGUI() | 709 | void ViewManager::initGUI() |
710 | { | 710 | { |
711 | QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); | 711 | QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); |
712 | mViewWidgetStack = new QWidgetStack( this ); | 712 | mViewWidgetStack = new QWidgetStack( this ); |
713 | layout->addWidget( mViewWidgetStack ); | 713 | layout->addWidget( mViewWidgetStack ); |
714 | } | 714 | } |
715 | 715 | ||
716 | #ifndef KAB_EMBEDDED | 716 | #ifndef KAB_EMBEDDED |
717 | #include "viewmanager.moc" | 717 | #include "viewmanager.moc" |
718 | #endif //KAB_EMBEDDED | 718 | #endif //KAB_EMBEDDED |