author | zautrix <zautrix> | 2005-04-22 18:54:01 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-22 18:54:01 (UTC) |
commit | 3fa082fb01716c63546df5d753c1b677e54c59ce (patch) (unidiff) | |
tree | f19e79e515174aab2cea0e8016eb9aa59bcc5095 /kaddressbook/viewmanager.cpp | |
parent | e6feb1ca0c45397ba7b922198c87fe9b95b7d872 (diff) | |
download | kdepimpi-3fa082fb01716c63546df5d753c1b677e54c59ce.zip kdepimpi-3fa082fb01716c63546df5d753c1b677e54c59ce.tar.gz kdepimpi-3fa082fb01716c63546df5d753c1b677e54c59ce.tar.bz2 |
fixxx
Diffstat (limited to 'kaddressbook/viewmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/viewmanager.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index 0614d06..c738ad8 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp | |||
@@ -15,192 +15,194 @@ | |||
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 <qapplication.h> | 63 | #include <qapplication.h> |
64 | #include <qwidgetstack.h> | 64 | #include <qwidgetstack.h> |
65 | 65 | ||
66 | #include <kabc/addressbook.h> | 66 | #include <kabc/addressbook.h> |
67 | #include "filtereditdialog.h" | 67 | #include "filtereditdialog.h" |
68 | #include "addviewdialog.h" | 68 | #include "addviewdialog.h" |
69 | #include "kabcore.h" | 69 | #include "kabcore.h" |
70 | #include "kabprefs.h" | 70 | #include "kabprefs.h" |
71 | #include "viewmanager.h" | 71 | #include "viewmanager.h" |
72 | 72 | ||
73 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) | 73 | ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) |
74 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) | 74 | : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) |
75 | { | 75 | { |
76 | initGUI(); | 76 | initGUI(); |
77 | initActions(); | 77 | initActions(); |
78 | 78 | ||
79 | mViewDict.setAutoDelete( true ); | 79 | mViewDict.setAutoDelete( true ); |
80 | 80 | ||
81 | createViewFactories(); | 81 | createViewFactories(); |
82 | } | 82 | } |
83 | 83 | ||
84 | ViewManager::~ViewManager() | 84 | ViewManager::~ViewManager() |
85 | { | 85 | { |
86 | unloadViews(); | 86 | unloadViews(); |
87 | mViewFactoryDict.clear(); | 87 | mViewFactoryDict.clear(); |
88 | } | 88 | } |
89 | void ViewManager::scrollUP() | 89 | void ViewManager::scrollUP() |
90 | { | 90 | { |
91 | if ( mActiveView ) | 91 | if ( mActiveView ) |
92 | mActiveView->scrollUP(); | 92 | mActiveView->scrollUP(); |
93 | } | 93 | } |
94 | void ViewManager::scrollDOWN() | 94 | void ViewManager::scrollDOWN() |
95 | { | 95 | { |
96 | if ( mActiveView ) | 96 | if ( mActiveView ) |
97 | mActiveView->scrollDOWN(); | 97 | mActiveView->scrollDOWN(); |
98 | } | 98 | } |
99 | void ViewManager::restoreSettings() | 99 | void ViewManager::restoreSettings() |
100 | { | 100 | { |
101 | mViewNameList = KABPrefs::instance()->mViewNames; | 101 | mViewNameList = KABPrefs::instance()->mViewNames; |
102 | QString activeViewName = KABPrefs::instance()->mCurrentView; | 102 | QString activeViewName = KABPrefs::instance()->mCurrentView; |
103 | 103 | ||
104 | mActionSelectView->setItems( mViewNameList ); | 104 | mActionSelectView->setItems( mViewNameList ); |
105 | 105 | ||
106 | // Filter | 106 | // Filter |
107 | mFilterList = Filter::restore( mCore->config(), "Filter" ); | 107 | mFilterList = Filter::restore( mCore->config(), "Filter" ); |
108 | mActionSelectFilter->setItems( filterNames() ); | 108 | mActionSelectFilter->setItems( filterNames() ); |
109 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); | 109 | mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); |
110 | int cw = 150; | 110 | int cw = 150; |
111 | if ( QApplication::desktop()->width() >= 800 ) | ||
112 | cw = 200; | ||
111 | if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch) | 113 | if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch) |
112 | cw = 0; | 114 | cw = 0; |
113 | mActionSelectFilter->setComboWidth( cw ); | 115 | mActionSelectFilter->setComboWidth( cw ); |
114 | // Tell the views to reread their config, since they may have | 116 | // Tell the views to reread their config, since they may have |
115 | // been modified by global settings | 117 | // been modified by global settings |
116 | QString _oldgroup = mCore->config()->group(); | 118 | QString _oldgroup = mCore->config()->group(); |
117 | 119 | ||
118 | QDictIterator<KAddressBookView> it( mViewDict ); | 120 | QDictIterator<KAddressBookView> it( mViewDict ); |
119 | for ( it.toFirst(); it.current(); ++it ) { | 121 | for ( it.toFirst(); it.current(); ++it ) { |
120 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 122 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
121 | it.current()->readConfig( mCore->config() ); | 123 | it.current()->readConfig( mCore->config() ); |
122 | } | 124 | } |
123 | setActiveView( activeViewName ); | 125 | setActiveView( activeViewName ); |
124 | 126 | ||
125 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); | 127 | mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); |
126 | } | 128 | } |
127 | 129 | ||
128 | void ViewManager::saveSettings() | 130 | void ViewManager::saveSettings() |
129 | { | 131 | { |
130 | QString _oldgroup = mCore->config()->group(); | 132 | QString _oldgroup = mCore->config()->group(); |
131 | 133 | ||
132 | QDictIterator<KAddressBookView> it( mViewDict ); | 134 | QDictIterator<KAddressBookView> it( mViewDict ); |
133 | for ( it.toFirst(); it.current(); ++it ) { | 135 | for ( it.toFirst(); it.current(); ++it ) { |
134 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); | 136 | KConfigGroupSaver saver( mCore->config(), it.currentKey() ); |
135 | #ifdef DESKTOP_VERSION | 137 | #ifdef DESKTOP_VERSION |
136 | (*it)->writeConfig( mCore->config() ); | 138 | (*it)->writeConfig( mCore->config() ); |
137 | #else | 139 | #else |
138 | (*it).writeConfig( mCore->config() ); | 140 | (*it).writeConfig( mCore->config() ); |
139 | #endif | 141 | #endif |
140 | } | 142 | } |
141 | 143 | ||
142 | Filter::save( mCore->config(), "Filter", mFilterList ); | 144 | Filter::save( mCore->config(), "Filter", mFilterList ); |
143 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); | 145 | KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); |
144 | 146 | ||
145 | // write the view name list | 147 | // write the view name list |
146 | KABPrefs::instance()->mViewNames = mViewNameList; | 148 | KABPrefs::instance()->mViewNames = mViewNameList; |
147 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); | 149 | KABPrefs::instance()->mCurrentView = mActiveView->caption(); |
148 | 150 | ||
149 | } | 151 | } |
150 | 152 | ||
151 | QStringList ViewManager::selectedUids() const | 153 | QStringList ViewManager::selectedUids() const |
152 | { | 154 | { |
153 | if ( mActiveView ) | 155 | if ( mActiveView ) |
154 | return mActiveView->selectedUids(); | 156 | return mActiveView->selectedUids(); |
155 | else | 157 | else |
156 | return QStringList(); | 158 | return QStringList(); |
157 | } | 159 | } |
158 | 160 | ||
159 | QStringList ViewManager::selectedEmails() const | 161 | QStringList ViewManager::selectedEmails() const |
160 | { | 162 | { |
161 | if ( mActiveView ) | 163 | if ( mActiveView ) |
162 | return mActiveView->selectedEmails(); | 164 | return mActiveView->selectedEmails(); |
163 | else | 165 | else |
164 | return QStringList(); | 166 | return QStringList(); |
165 | } | 167 | } |
166 | 168 | ||
167 | KABC::Addressee::List ViewManager::selectedAddressees() const | 169 | KABC::Addressee::List ViewManager::selectedAddressees() const |
168 | { | 170 | { |
169 | KABC::Addressee::List list; | 171 | KABC::Addressee::List list; |
170 | if ( mActiveView ) { | 172 | if ( mActiveView ) { |
171 | QStringList uids = mActiveView->selectedUids(); | 173 | QStringList uids = mActiveView->selectedUids(); |
172 | QStringList::Iterator it; | 174 | QStringList::Iterator it; |
173 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 175 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
174 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); | 176 | KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); |
175 | if ( !addr.isEmpty() ) | 177 | if ( !addr.isEmpty() ) |
176 | list.append( addr ); | 178 | list.append( addr ); |
177 | } | 179 | } |
178 | } | 180 | } |
179 | 181 | ||
180 | return list; | 182 | return list; |
181 | } | 183 | } |
182 | //US added another method with no parameter, since my moc compiler does not support default parameters. | 184 | //US added another method with no parameter, since my moc compiler does not support default parameters. |
183 | void ViewManager::setSelected() | 185 | void ViewManager::setSelected() |
184 | { | 186 | { |
185 | setSelected( QString::null, true ); | 187 | setSelected( QString::null, true ); |
186 | } | 188 | } |
187 | 189 | ||
188 | void ViewManager::setSelected( const QString &uid, bool selected ) | 190 | void ViewManager::setSelected( const QString &uid, bool selected ) |
189 | { | 191 | { |
190 | if ( mActiveView ) | 192 | if ( mActiveView ) |
191 | mActiveView->setSelected( uid, selected ); | 193 | mActiveView->setSelected( uid, selected ); |
192 | } | 194 | } |
193 | 195 | ||
194 | void ViewManager::setListSelected(QStringList list) | 196 | void ViewManager::setListSelected(QStringList list) |
195 | { | 197 | { |
196 | int i, count = list.count(); | 198 | int i, count = list.count(); |
197 | for ( i = 0; i < count;++i ) | 199 | for ( i = 0; i < count;++i ) |
198 | setSelected( list[i], true ); | 200 | setSelected( list[i], true ); |
199 | 201 | ||
200 | } | 202 | } |
201 | void ViewManager::unloadViews() | 203 | void ViewManager::unloadViews() |
202 | { | 204 | { |
203 | mViewDict.clear(); | 205 | mViewDict.clear(); |
204 | mActiveView = 0; | 206 | mActiveView = 0; |
205 | } | 207 | } |
206 | 208 | ||
@@ -511,192 +513,194 @@ void ViewManager::dropped( QDropEvent *e ) | |||
511 | } else if ( c == 1 ) | 513 | } else if ( c == 1 ) |
512 | emit urlDropped( *it ); | 514 | emit urlDropped( *it ); |
513 | } else if ( KVCardDrag::decode( e, vcards ) ) { | 515 | } else if ( KVCardDrag::decode( e, vcards ) ) { |
514 | KABC::Addressee addr; | 516 | KABC::Addressee addr; |
515 | KABC::VCardConverter converter; | 517 | KABC::VCardConverter converter; |
516 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); | 518 | QStringList list = QStringList::split( "\r\n\r\n", vcards ); |
517 | QStringList::Iterator it; | 519 | QStringList::Iterator it; |
518 | for ( it = list.begin(); it != list.end(); ++it ) { | 520 | for ( it = list.begin(); it != list.end(); ++it ) { |
519 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { | 521 | if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { |
520 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); | 522 | KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); |
521 | if ( a.isEmpty() ) { | 523 | if ( a.isEmpty() ) { |
522 | mCore->addressBook()->insertAddressee( addr ); | 524 | mCore->addressBook()->insertAddressee( addr ); |
523 | emit modified(); | 525 | emit modified(); |
524 | } | 526 | } |
525 | } | 527 | } |
526 | } | 528 | } |
527 | 529 | ||
528 | mActiveView->refresh(); | 530 | mActiveView->refresh(); |
529 | } | 531 | } |
530 | #else //KAB_EMBEDDED | 532 | #else //KAB_EMBEDDED |
531 | qDebug("ViewManager::dropped() has to be changed!!" ); | 533 | qDebug("ViewManager::dropped() has to be changed!!" ); |
532 | #endif //KAB_EMBEDDED | 534 | #endif //KAB_EMBEDDED |
533 | 535 | ||
534 | } | 536 | } |
535 | 537 | ||
536 | void ViewManager::startDrag() | 538 | void ViewManager::startDrag() |
537 | { | 539 | { |
538 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; | 540 | kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; |
539 | 541 | ||
540 | #ifndef KAB_EMBEDDED | 542 | #ifndef KAB_EMBEDDED |
541 | 543 | ||
542 | // Get the list of all the selected addressees | 544 | // Get the list of all the selected addressees |
543 | KABC::Addressee::List addrList; | 545 | KABC::Addressee::List addrList; |
544 | QStringList uidList = selectedUids(); | 546 | QStringList uidList = selectedUids(); |
545 | QStringList::Iterator iter; | 547 | QStringList::Iterator iter; |
546 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) | 548 | for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) |
547 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); | 549 | addrList.append( mCore->addressBook()->findByUid( *iter ) ); |
548 | 550 | ||
549 | KMultipleDrag *drag = new KMultipleDrag( this ); | 551 | KMultipleDrag *drag = new KMultipleDrag( this ); |
550 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); | 552 | drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); |
551 | KABC::Addressee::List::Iterator it; | 553 | KABC::Addressee::List::Iterator it; |
552 | QStringList vcards; | 554 | QStringList vcards; |
553 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { | 555 | for ( it = addrList.begin(); it != addrList.end(); ++it ) { |
554 | QString vcard = QString::null; | 556 | QString vcard = QString::null; |
555 | KABC::VCardConverter converter; | 557 | KABC::VCardConverter converter; |
556 | if ( converter.addresseeToVCard( *it, vcard ) ) | 558 | if ( converter.addresseeToVCard( *it, vcard ) ) |
557 | vcards.append( vcard ); | 559 | vcards.append( vcard ); |
558 | } | 560 | } |
559 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); | 561 | drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); |
560 | 562 | ||
561 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); | 563 | drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); |
562 | drag->dragCopy(); | 564 | drag->dragCopy(); |
563 | 565 | ||
564 | #else //KAB_EMBEDDED | 566 | #else //KAB_EMBEDDED |
565 | qDebug("ViewManager::startDrag() has to be changed!!" ); | 567 | qDebug("ViewManager::startDrag() has to be changed!!" ); |
566 | #endif //KAB_EMBEDDED | 568 | #endif //KAB_EMBEDDED |
567 | 569 | ||
568 | } | 570 | } |
569 | void ViewManager::doSearch( const QString& s,KABC::Field *field ) | 571 | void ViewManager::doSearch( const QString& s,KABC::Field *field ) |
570 | { | 572 | { |
571 | if ( mActiveView ) | 573 | if ( mActiveView ) |
572 | mActiveView->doSearch( s, field ); | 574 | mActiveView->doSearch( s, field ); |
573 | 575 | ||
574 | } | 576 | } |
575 | void ViewManager::setActiveFilter( int index ) | 577 | void ViewManager::setActiveFilter( int index ) |
576 | { | 578 | { |
577 | Filter currentFilter; | 579 | Filter currentFilter; |
578 | 580 | ||
579 | if ( ( index - 1 ) < 0 ) | 581 | if ( ( index - 1 ) < 0 ) |
580 | currentFilter = Filter(); | 582 | currentFilter = Filter(); |
581 | else | 583 | else |
582 | currentFilter = mFilterList[ index - 1 ]; | 584 | currentFilter = mFilterList[ index - 1 ]; |
583 | 585 | ||
584 | // Check if we have a view. Since the filter combo is created before | 586 | // Check if we have a view. Since the filter combo is created before |
585 | // the view, this slot could be called before there is a valid view. | 587 | // the view, this slot could be called before there is a valid view. |
586 | if ( mActiveView ) { | 588 | if ( mActiveView ) { |
587 | mActiveView->setFilter( currentFilter ); | 589 | mActiveView->setFilter( currentFilter ); |
588 | mActiveView->refresh(); | 590 | mActiveView->refresh(); |
589 | emit selected( QString::null ); | 591 | emit selected( QString::null ); |
590 | } | 592 | } |
591 | } | 593 | } |
592 | 594 | ||
593 | void ViewManager::configureFilters() | 595 | void ViewManager::configureFilters() |
594 | { | 596 | { |
595 | FilterDialog dlg( this ); | 597 | FilterDialog dlg( this ); |
596 | 598 | ||
597 | dlg.setFilters( mFilterList ); | 599 | dlg.setFilters( mFilterList ); |
598 | 600 | ||
599 | if ( dlg.exec() ) | 601 | if ( dlg.exec() ) |
600 | mFilterList = dlg.filters(); | 602 | mFilterList = dlg.filters(); |
601 | 603 | ||
602 | uint pos = mActionSelectFilter->currentItem(); | 604 | uint pos = mActionSelectFilter->currentItem(); |
603 | mActionSelectFilter->setItems( filterNames() ); | 605 | mActionSelectFilter->setItems( filterNames() ); |
604 | mActionSelectFilter->setCurrentItem( pos ); | 606 | mActionSelectFilter->setCurrentItem( pos ); |
605 | setActiveFilter( pos ); | 607 | setActiveFilter( pos ); |
606 | int cw = 150; | 608 | int cw = 150; |
609 | if ( QApplication::desktop()->width() >= 800 ) | ||
610 | cw = 200; | ||
607 | if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch) | 611 | if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch) |
608 | cw = 0; | 612 | cw = 0; |
609 | mActionSelectFilter->setComboWidth( cw ); | 613 | mActionSelectFilter->setComboWidth( cw ); |
610 | saveSettings(); | 614 | saveSettings(); |
611 | } | 615 | } |
612 | 616 | ||
613 | QStringList ViewManager::filterNames() const | 617 | QStringList ViewManager::filterNames() const |
614 | { | 618 | { |
615 | QStringList names( i18n( "No Filter" ) ); | 619 | QStringList names( i18n( "No Filter" ) ); |
616 | 620 | ||
617 | Filter::List::ConstIterator it; | 621 | Filter::List::ConstIterator it; |
618 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) | 622 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) |
619 | names.append( (*it).name() ); | 623 | names.append( (*it).name() ); |
620 | 624 | ||
621 | return names; | 625 | return names; |
622 | } | 626 | } |
623 | Filter ViewManager::getFilterByName( const QString &name ) const | 627 | Filter ViewManager::getFilterByName( const QString &name ) const |
624 | { | 628 | { |
625 | Filter::List::ConstIterator it; | 629 | Filter::List::ConstIterator it; |
626 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) | 630 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) |
627 | if ( name == (*it).name() ) | 631 | if ( name == (*it).name() ) |
628 | return (*it); | 632 | return (*it); |
629 | 633 | ||
630 | return Filter(); | 634 | return Filter(); |
631 | } | 635 | } |
632 | 636 | ||
633 | int ViewManager::filterPosition( const QString &name ) const | 637 | int ViewManager::filterPosition( const QString &name ) const |
634 | { | 638 | { |
635 | int pos = 0; | 639 | int pos = 0; |
636 | 640 | ||
637 | Filter::List::ConstIterator it; | 641 | Filter::List::ConstIterator it; |
638 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) | 642 | for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) |
639 | if ( name == (*it).name() ) | 643 | if ( name == (*it).name() ) |
640 | return pos + 1; | 644 | return pos + 1; |
641 | 645 | ||
642 | return 0; | 646 | return 0; |
643 | } | 647 | } |
644 | 648 | ||
645 | void ViewManager::initActions() | 649 | void ViewManager::initActions() |
646 | { | 650 | { |
647 | //US <ActionList name="view_loadedviews"/> | 651 | //US <ActionList name="view_loadedviews"/> |
648 | //US <Separator/> | 652 | //US <Separator/> |
649 | 653 | ||
650 | #ifdef KAB_EMBEDDED | 654 | #ifdef KAB_EMBEDDED |
651 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); | 655 | QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); |
652 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); | 656 | QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); |
653 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); | 657 | QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); |
654 | #endif //KAB_EMBEDDED | 658 | #endif //KAB_EMBEDDED |
655 | 659 | ||
656 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); | 660 | mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); |
657 | #if KDE_VERSION >= 309 | 661 | #if KDE_VERSION >= 309 |
658 | mActionSelectView->setMenuAccelsEnabled( false ); | 662 | mActionSelectView->setMenuAccelsEnabled( false ); |
659 | #endif | 663 | #endif |
660 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), | 664 | connect( mActionSelectView, SIGNAL( activated( const QString& ) ), |
661 | SLOT( selectView( const QString& ) ) ); | 665 | SLOT( selectView( const QString& ) ) ); |
662 | 666 | ||
663 | 667 | ||
664 | #ifdef KAB_EMBEDDED | 668 | #ifdef KAB_EMBEDDED |
665 | mActionSelectView->plug(viewmenu); | 669 | mActionSelectView->plug(viewmenu); |
666 | viewmenu->insertSeparator(); | 670 | viewmenu->insertSeparator(); |
667 | #endif //KAB_EMBEDDED | 671 | #endif //KAB_EMBEDDED |
668 | 672 | ||
669 | KAction *action; | 673 | KAction *action; |
670 | 674 | ||
671 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, | 675 | action = new KAction( i18n( "Modify View..." ), "configure", 0, this, |
672 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); | 676 | SLOT( editView() ), mCore->actionCollection(), "view_modify" ); |
673 | #ifndef KAB_EMBEDDED | 677 | #ifndef KAB_EMBEDDED |
674 | 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." ) ); | 678 | 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." ) ); |
675 | #else //KAB_EMBEDDED | 679 | #else //KAB_EMBEDDED |
676 | action->plug(viewmenu); | 680 | action->plug(viewmenu); |
677 | #endif //KAB_EMBEDDED | 681 | #endif //KAB_EMBEDDED |
678 | 682 | ||
679 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, | 683 | action = new KAction( i18n( "Add View..." ), "window_new", 0, this, |
680 | SLOT( addView() ), mCore->actionCollection(), "view_add" ); | 684 | SLOT( addView() ), mCore->actionCollection(), "view_add" ); |
681 | #ifndef KAB_EMBEDDED | 685 | #ifndef KAB_EMBEDDED |
682 | 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." ) ); | 686 | 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." ) ); |
683 | #else //KAB_EMBEDDED | 687 | #else //KAB_EMBEDDED |
684 | action->plug(viewmenu); | 688 | action->plug(viewmenu); |
685 | #endif //KAB_EMBEDDED | 689 | #endif //KAB_EMBEDDED |
686 | 690 | ||
687 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, | 691 | mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, |
688 | this, SLOT( deleteView() ), | 692 | this, SLOT( deleteView() ), |
689 | mCore->actionCollection(), "view_delete" ); | 693 | mCore->actionCollection(), "view_delete" ); |
690 | #ifndef KAB_EMBEDDED | 694 | #ifndef KAB_EMBEDDED |
691 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); | 695 | mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); |
692 | #else //KAB_EMBEDDED | 696 | #else //KAB_EMBEDDED |
693 | mActionDeleteView->plug(viewmenu); | 697 | mActionDeleteView->plug(viewmenu); |
694 | viewmenu->insertSeparator(); | 698 | viewmenu->insertSeparator(); |
695 | #endif //KAB_EMBEDDED | 699 | #endif //KAB_EMBEDDED |
696 | 700 | ||
697 | #ifndef KAB_EMBEDDED | 701 | #ifndef KAB_EMBEDDED |
698 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, | 702 | action = new KAction( i18n( "Refresh View" ), "reload", 0, this, |
699 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), | 703 | SLOT( refreshView(const QString &) ), mCore->actionCollection(), |
700 | "view_refresh" ); | 704 | "view_refresh" ); |
701 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); | 705 | action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); |
702 | #else //KAB_EMBEDDED | 706 | #else //KAB_EMBEDDED |