summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kaddressbookview.cpp
authorzautrix <zautrix>2004-06-26 19:01:18 (UTC)
committer zautrix <zautrix>2004-06-26 19:01:18 (UTC)
commitb9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff)
tree2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /kaddressbook/kaddressbookview.cpp
downloadkdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2
Initial revision
Diffstat (limited to 'kaddressbook/kaddressbookview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kaddressbookview.cpp171
1 files changed, 171 insertions, 0 deletions
diff --git a/kaddressbook/kaddressbookview.cpp b/kaddressbook/kaddressbookview.cpp
new file mode 100644
index 0000000..a44fd82
--- a/dev/null
+++ b/kaddressbook/kaddressbookview.cpp
@@ -0,0 +1,171 @@
1/*
2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4
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
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
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
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution.
22*/
23
24#ifndef KAB_EMBEDDED
25#include <qapplication.h>
26
27#include <kabc/distributionlistdialog.h>
28#include <kconfig.h>
29#include <klocale.h>
30
31#include "viewmanager.h"
32
33#endif //KAB_EMBEDDED
34#include <qlayout.h>
35
36#include <kabc/addressbook.h>
37#include <kdebug.h>
38
39#include "kaddressbookview.h"
40
41KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent,
42 const char *name )
43 : QWidget( parent, name ), mAddressBook( ab ), mFieldList()
44{
45 initGUI();
46}
47
48KAddressBookView::~KAddressBookView()
49{
50 kdDebug(5720) << "KAddressBookView::~KAddressBookView: destroying - "
51 << name() << endl;
52}
53
54void KAddressBookView::readConfig( KConfig *config )
55{
56 mFieldList = KABC::Field::restoreFields( config, "KABCFields" );
57
58 if ( mFieldList.isEmpty() )
59 mFieldList = KABC::Field::defaultFields();
60
61 mDefaultFilterType = (DefaultFilterType)config->readNumEntry( "DefaultFilterType", 1 );
62 mDefaultFilterName = config->readEntry( "DefaultFilterName", QString::null );
63}
64
65void KAddressBookView::writeConfig( KConfig* )
66{
67 // Most of writing the config is handled by the ConfigureViewDialog
68}
69
70QString KAddressBookView::selectedEmails()
71{
72#ifndef KAB_EMBEDDED
73
74 bool first = true;
75 QString emailAddrs;
76 QStringList uidList = selectedUids();
77 KABC::Addressee addr;
78 QString email;
79
80 QStringList::Iterator it;
81 for ( it = uidList.begin(); it != uidList.end(); ++it ) {
82 addr = mAddressBook->findByUid( *it );
83
84 if ( !addr.isEmpty() ) {
85 QString m = QString::null;
86
87 if ( addr.emails().count() > 1 )
88 m = KABC::EmailSelector::getEmail( addr.emails(), addr.preferredEmail(), this );
89
90 email = addr.fullEmail( m );
91
92 if ( !first )
93 emailAddrs += ", ";
94 else
95 first = false;
96
97 emailAddrs += email;
98 }
99 }
100
101 return emailAddrs;
102#else //KAB_EMBEDDED
103qDebug("KAddressBookView::selectedEmails() update method");
104return 0;
105#endif //KAB_EMBEDDED
106
107}
108
109KABC::Addressee::List KAddressBookView::addressees()
110{
111 KABC::Addressee::List addresseeList;
112
113 KABC::AddressBook::Iterator it;
114 for (it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
115 if ( mFilter.filterAddressee( *it ) )
116 addresseeList.append( *it );
117 }
118
119 return addresseeList;
120}
121
122void KAddressBookView::initGUI()
123{
124 // Create the layout
125 QVBoxLayout *layout = new QVBoxLayout( this );
126
127 // Add the view widget
128 mViewWidget = new QWidget( this );
129 layout->addWidget( mViewWidget );
130}
131
132KABC::Field::List KAddressBookView::fields() const
133{
134 return mFieldList;
135}
136
137void KAddressBookView::setFilter( const Filter &filter )
138{
139 mFilter = filter;
140}
141
142KAddressBookView::DefaultFilterType KAddressBookView::defaultFilterType() const
143{
144 return mDefaultFilterType;
145}
146
147const QString &KAddressBookView::defaultFilterName() const
148{
149 return mDefaultFilterName;
150}
151
152KABC::AddressBook *KAddressBookView::addressBook() const
153{
154 return mAddressBook;
155}
156
157QWidget *KAddressBookView::viewWidget()
158{
159 return mViewWidget;
160}
161
162ViewConfigureWidget *ViewFactory::configureWidget( KABC::AddressBook *ab,
163 QWidget *parent,
164 const char *name )
165{
166 return new ViewConfigureWidget( ab, parent, name );
167}
168
169#ifndef KAB_EMBEDDED
170#include "kaddressbookview.moc"
171#endif //KAB_EMBEDDED