summaryrefslogtreecommitdiffabout
path: root/kaddressbook/viewmanager.cpp
Unidiff
Diffstat (limited to 'kaddressbook/viewmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/viewmanager.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index c6baeac..f4fb08b 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -24,129 +24,138 @@
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (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
72ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) 72ViewManager::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
83ViewManager::~ViewManager() 83ViewManager::~ViewManager()
84{ 84{
85 unloadViews(); 85 unloadViews();
86 mViewFactoryDict.clear(); 86 mViewFactoryDict.clear();
87} 87}
88 88void ViewManager::scrollUP()
89{
90 if ( mActiveView )
91 mActiveView->scrollUP();
92}
93void ViewManager::scrollDOWN()
94{
95 if ( mActiveView )
96 mActiveView->scrollDOWN();
97}
89void ViewManager::restoreSettings() 98void ViewManager::restoreSettings()
90{ 99{
91 mViewNameList = KABPrefs::instance()->mViewNames; 100 mViewNameList = KABPrefs::instance()->mViewNames;
92 QString activeViewName = KABPrefs::instance()->mCurrentView; 101 QString activeViewName = KABPrefs::instance()->mCurrentView;
93 102
94 mActionSelectView->setItems( mViewNameList ); 103 mActionSelectView->setItems( mViewNameList );
95 104
96 // Filter 105 // Filter
97 mFilterList = Filter::restore( mCore->config(), "Filter" ); 106 mFilterList = Filter::restore( mCore->config(), "Filter" );
98 mActionSelectFilter->setItems( filterNames() ); 107 mActionSelectFilter->setItems( filterNames() );
99 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); 108 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter );
100 109
101 // Tell the views to reread their config, since they may have 110 // Tell the views to reread their config, since they may have
102 // been modified by global settings 111 // been modified by global settings
103 QString _oldgroup = mCore->config()->group(); 112 QString _oldgroup = mCore->config()->group();
104 113
105 QDictIterator<KAddressBookView> it( mViewDict ); 114 QDictIterator<KAddressBookView> it( mViewDict );
106 for ( it.toFirst(); it.current(); ++it ) { 115 for ( it.toFirst(); it.current(); ++it ) {
107 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 116 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
108 it.current()->readConfig( mCore->config() ); 117 it.current()->readConfig( mCore->config() );
109 } 118 }
110 setActiveView( activeViewName ); 119 setActiveView( activeViewName );
111 120
112 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 121 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
113} 122}
114 123
115void ViewManager::saveSettings() 124void ViewManager::saveSettings()
116{ 125{
117 QString _oldgroup = mCore->config()->group(); 126 QString _oldgroup = mCore->config()->group();
118 127
119 QDictIterator<KAddressBookView> it( mViewDict ); 128 QDictIterator<KAddressBookView> it( mViewDict );
120 for ( it.toFirst(); it.current(); ++it ) { 129 for ( it.toFirst(); it.current(); ++it ) {
121 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 130 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
122#ifdef DESKTOP_VERSION 131#ifdef DESKTOP_VERSION
123 (*it)->writeConfig( mCore->config() ); 132 (*it)->writeConfig( mCore->config() );
124#else 133#else
125 (*it).writeConfig( mCore->config() ); 134 (*it).writeConfig( mCore->config() );
126#endif 135#endif
127 } 136 }
128 137
129 Filter::save( mCore->config(), "Filter", mFilterList ); 138 Filter::save( mCore->config(), "Filter", mFilterList );
130 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); 139 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem();
131 140
132 // write the view name list 141 // write the view name list
133 KABPrefs::instance()->mViewNames = mViewNameList; 142 KABPrefs::instance()->mViewNames = mViewNameList;
134 KABPrefs::instance()->mCurrentView = mActiveView->caption(); 143 KABPrefs::instance()->mCurrentView = mActiveView->caption();
135 144
136} 145}
137 146
138QStringList ViewManager::selectedUids() const 147QStringList ViewManager::selectedUids() const
139{ 148{
140 if ( mActiveView ) 149 if ( mActiveView )
141 return mActiveView->selectedUids(); 150 return mActiveView->selectedUids();
142 else 151 else
143 return QStringList(); 152 return QStringList();
144} 153}
145 154
146QStringList ViewManager::selectedEmails() const 155QStringList ViewManager::selectedEmails() const
147{ 156{
148 if ( mActiveView ) 157 if ( mActiveView )
149 return mActiveView->selectedEmails(); 158 return mActiveView->selectedEmails();
150 else 159 else
151 return QStringList(); 160 return QStringList();
152} 161}