author | zautrix <zautrix> | 2004-12-13 12:35:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-12-13 12:35:00 (UTC) |
commit | 7ac6c21e832b7d16bd0888d0b66252b6e152005a (patch) (side-by-side diff) | |
tree | c7610e0e25020f19af82ac6257c2debab2638316 /kaddressbook/viewmanager.cpp | |
parent | 17b25691f0332e648dd1d800e89ccf4e1da8955d (diff) | |
download | kdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.zip kdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.tar.gz kdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.tar.bz2 |
many bugfixes
-rw-r--r-- | kaddressbook/viewmanager.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index 0d91c12..33bef5a 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp @@ -1,173 +1,177 @@ /* This file is part of KAddressBook. Copyright (c) 2002 Mike Pilone <mpilone@slac.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ /* Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #ifndef KAB_EMBEDDED #include <libkdepim/kvcarddrag.h> #include <kabc/vcardconverter.h> #include <kconfig.h> #include <kdeversion.h> #include <kiconloader.h> #include <klocale.h> #include <kmessagebox.h> #include <kmultipledrag.h> #include <ktrader.h> #include <kurldrag.h> #include "addresseeutil.h" #else //KAB_EMBEDDED #include "views/kaddressbookiconview.h" #include "views/kaddressbooktableview.h" #include "views/kaddressbookcardview.h" #include "kaddressbookview.h" #include <qaction.h> #include <qmessagebox.h> #include <qpopupmenu.h> #include <kconfigbase.h> #endif //KAB_EMBEDDED #include <kdebug.h> #include <kactionclasses.h> #include <qlayout.h> +#include <qapplication.h> #include <qwidgetstack.h> #include <kabc/addressbook.h> #include "filtereditdialog.h" #include "addviewdialog.h" #include "kabcore.h" #include "kabprefs.h" #include "viewmanager.h" ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) { initGUI(); initActions(); mViewDict.setAutoDelete( true ); createViewFactories(); } ViewManager::~ViewManager() { unloadViews(); mViewFactoryDict.clear(); } void ViewManager::scrollUP() { if ( mActiveView ) mActiveView->scrollUP(); } void ViewManager::scrollDOWN() { if ( mActiveView ) mActiveView->scrollDOWN(); } void ViewManager::restoreSettings() { mViewNameList = KABPrefs::instance()->mViewNames; QString activeViewName = KABPrefs::instance()->mCurrentView; mActionSelectView->setItems( mViewNameList ); // Filter mFilterList = Filter::restore( mCore->config(), "Filter" ); mActionSelectFilter->setItems( filterNames() ); mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); - mActionSelectFilter->setComboWidth( 150 ); + int cw = 150; + if (QApplication::desktop()->width() == 480 ) + cw = 0; + mActionSelectFilter->setComboWidth( cw ); // Tell the views to reread their config, since they may have // been modified by global settings QString _oldgroup = mCore->config()->group(); QDictIterator<KAddressBookView> it( mViewDict ); for ( it.toFirst(); it.current(); ++it ) { KConfigGroupSaver saver( mCore->config(), it.currentKey() ); it.current()->readConfig( mCore->config() ); } setActiveView( activeViewName ); mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); } void ViewManager::saveSettings() { QString _oldgroup = mCore->config()->group(); QDictIterator<KAddressBookView> it( mViewDict ); for ( it.toFirst(); it.current(); ++it ) { KConfigGroupSaver saver( mCore->config(), it.currentKey() ); #ifdef DESKTOP_VERSION (*it)->writeConfig( mCore->config() ); #else (*it).writeConfig( mCore->config() ); #endif } Filter::save( mCore->config(), "Filter", mFilterList ); KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); // write the view name list KABPrefs::instance()->mViewNames = mViewNameList; KABPrefs::instance()->mCurrentView = mActiveView->caption(); } QStringList ViewManager::selectedUids() const { if ( mActiveView ) return mActiveView->selectedUids(); else return QStringList(); } QStringList ViewManager::selectedEmails() const { if ( mActiveView ) return mActiveView->selectedEmails(); else return QStringList(); } KABC::Addressee::List ViewManager::selectedAddressees() const { KABC::Addressee::List list; if ( mActiveView ) { QStringList uids = mActiveView->selectedUids(); QStringList::Iterator it; for ( it = uids.begin(); it != uids.end(); ++it ) { KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); if ( !addr.isEmpty() ) list.append( addr ); } @@ -536,129 +540,132 @@ void ViewManager::startDrag() // Get the list of all the selected addressees KABC::Addressee::List addrList; QStringList uidList = selectedUids(); QStringList::Iterator iter; for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) addrList.append( mCore->addressBook()->findByUid( *iter ) ); KMultipleDrag *drag = new KMultipleDrag( this ); drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); KABC::Addressee::List::Iterator it; QStringList vcards; for ( it = addrList.begin(); it != addrList.end(); ++it ) { QString vcard = QString::null; KABC::VCardConverter converter; if ( converter.addresseeToVCard( *it, vcard ) ) vcards.append( vcard ); } drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); drag->dragCopy(); #else //KAB_EMBEDDED qDebug("ViewManager::startDrag() has to be changed!!" ); #endif //KAB_EMBEDDED } void ViewManager::doSearch( const QString& s,KABC::Field *field ) { if ( mActiveView ) mActiveView->doSearch( s, field ); } void ViewManager::setActiveFilter( int index ) { Filter currentFilter; if ( ( index - 1 ) < 0 ) currentFilter = Filter(); else currentFilter = mFilterList[ index - 1 ]; // Check if we have a view. Since the filter combo is created before // the view, this slot could be called before there is a valid view. if ( mActiveView ) { mActiveView->setFilter( currentFilter ); mActiveView->refresh(); emit selected( QString::null ); } } void ViewManager::configureFilters() { FilterDialog dlg( this ); dlg.setFilters( mFilterList ); if ( dlg.exec() ) mFilterList = dlg.filters(); uint pos = mActionSelectFilter->currentItem(); mActionSelectFilter->setItems( filterNames() ); mActionSelectFilter->setCurrentItem( pos ); setActiveFilter( pos ); - mActionSelectFilter->setComboWidth( 150 ); + int cw = 150; + if (QApplication::desktop()->width() == 480 ) + cw = 0; + mActionSelectFilter->setComboWidth( cw ); } QStringList ViewManager::filterNames() const { QStringList names( i18n( "No Filter" ) ); Filter::List::ConstIterator it; for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) names.append( (*it).name() ); return names; } int ViewManager::filterPosition( const QString &name ) const { int pos = 0; Filter::List::ConstIterator it; for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) if ( name == (*it).name() ) return pos + 1; return 0; } void ViewManager::initActions() { //US <ActionList name="view_loadedviews"/> //US <Separator/> #ifdef KAB_EMBEDDED QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); #endif //KAB_EMBEDDED mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); #if KDE_VERSION >= 309 mActionSelectView->setMenuAccelsEnabled( false ); #endif connect( mActionSelectView, SIGNAL( activated( const QString& ) ), SLOT( setActiveView( const QString& ) ) ); #ifdef KAB_EMBEDDED mActionSelectView->plug(viewmenu); viewmenu->insertSeparator(); #endif //KAB_EMBEDDED KAction *action; action = new KAction( i18n( "Modify View..." ), "configure", 0, this, SLOT( editView() ), mCore->actionCollection(), "view_modify" ); #ifndef KAB_EMBEDDED 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." ) ); #else //KAB_EMBEDDED action->plug(viewmenu); #endif //KAB_EMBEDDED action = new KAction( i18n( "Add View..." ), "window_new", 0, this, SLOT( addView() ), mCore->actionCollection(), "view_add" ); #ifndef KAB_EMBEDDED 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." ) ); #else //KAB_EMBEDDED |