summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kaddressbookview.cpp
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kaddressbook/kaddressbookview.cpp
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'kaddressbook/kaddressbookview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kaddressbookview.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/kaddressbook/kaddressbookview.cpp b/kaddressbook/kaddressbookview.cpp
index 86898e2..4823b37 100644
--- a/kaddressbook/kaddressbookview.cpp
+++ b/kaddressbook/kaddressbookview.cpp
@@ -1,82 +1,84 @@
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#ifndef KAB_EMBEDDED 24#ifndef KAB_EMBEDDED
25#include <qapplication.h> 25#include <qapplication.h>
26 26
27#include <kabc/distributionlistdialog.h> 27#include <kabc/distributionlistdialog.h>
28#include <kconfig.h> 28#include <kconfig.h>
29#include <klocale.h> 29#include <klocale.h>
30 30
31#include "viewmanager.h" 31#include "viewmanager.h"
32 32
33#endif //KAB_EMBEDDED 33#endif //KAB_EMBEDDED
34#include <qlayout.h> 34#include <qlayout.h>
35//Added by qt3to4:
36#include <Q3VBoxLayout>
35 37
36#include <kabc/distributionlistdialog.h> 38#include <kabc/distributionlistdialog.h>
37#include <kabc/addressbook.h> 39#include <kabc/addressbook.h>
38#include <kdebug.h> 40#include <kdebug.h>
39 41
40#include "kaddressbookview.h" 42#include "kaddressbookview.h"
41 43
42KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent, 44KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent,
43 const char *name ) 45 const char *name )
44 : QWidget( parent, name ), mAddressBook( ab ), mFieldList() 46 : QWidget( parent, name ), mAddressBook( ab ), mFieldList()
45{ 47{
46 48
47 initGUI(); 49 initGUI();
48} 50}
49 51
50KAddressBookView::~KAddressBookView() 52KAddressBookView::~KAddressBookView()
51{ 53{
52 54
53} 55}
54 56
55QRegExp KAddressBookView::getRegExp( const QString s ) 57QRegExp KAddressBookView::getRegExp( const QString s )
56{ 58{
57 QRegExp re; 59 QRegExp re;
58 60
59 if ( s.length() == 3 && s.mid(1,1) == "-" ) { 61 if ( s.length() == 3 && s.mid(1,1) == "-" ) {
60 QString pattern = "^[" + s.lower() +"]"; 62 QString pattern = "^[" + s.lower() +"]";
61 re.setCaseSensitive(false); 63 re.setCaseSensitive(false);
62 re.setPattern( pattern ); 64 re.setPattern( pattern );
63 } else { 65 } else {
64 QString pattern = s.lower()+"*"; 66 QString pattern = s.lower()+"*";
65 re.setWildcard(true); // most people understand these better. 67 re.setWildcard(true); // most people understand these better.
66 re.setCaseSensitive(false); 68 re.setCaseSensitive(false);
67 re.setPattern( pattern ); 69 re.setPattern( pattern );
68 } 70 }
69 return re; 71 return re;
70} 72}
71 73
72void KAddressBookView::readConfig( KConfig *config ) 74void KAddressBookView::readConfig( KConfig *config )
73{ 75{
74 mFieldList = KABC::Field::restoreFields( config, "KABCFields" ); 76 mFieldList = KABC::Field::restoreFields( config, "KABCFields" );
75 77
76 if ( mFieldList.isEmpty() ) 78 if ( mFieldList.isEmpty() )
77 mFieldList = KABC::Field::defaultFields(); 79 mFieldList = KABC::Field::defaultFields();
78 80
79 mDefaultFilterType = (DefaultFilterType)config->readNumEntry( "DefaultFilterType", 1 ); 81 mDefaultFilterType = (DefaultFilterType)config->readNumEntry( "DefaultFilterType", 1 );
80 mDefaultFilterName = config->readEntry( "DefaultFilterName", QString::null ); 82 mDefaultFilterName = config->readEntry( "DefaultFilterName", QString::null );
81} 83}
82 84
@@ -88,101 +90,101 @@ void KAddressBookView::writeConfig( KConfig* )
88QString KAddressBookView::selectedEmails() 90QString KAddressBookView::selectedEmails()
89{ 91{
90 bool first = true; 92 bool first = true;
91 QString emailAddrs; 93 QString emailAddrs;
92 QStringList uidList = selectedUids(); 94 QStringList uidList = selectedUids();
93 KABC::Addressee addr; 95 KABC::Addressee addr;
94 QString email; 96 QString email;
95 97
96 QStringList::Iterator it; 98 QStringList::Iterator it;
97 for ( it = uidList.begin(); it != uidList.end(); ++it ) { 99 for ( it = uidList.begin(); it != uidList.end(); ++it ) {
98 addr = mAddressBook->findByUid( *it ); 100 addr = mAddressBook->findByUid( *it );
99 101
100 if ( !addr.isEmpty() ) { 102 if ( !addr.isEmpty() ) {
101 QString m = QString::null; 103 QString m = QString::null;
102 104
103 if ( addr.emails().count() > 1 ) 105 if ( addr.emails().count() > 1 )
104 m = KABC::EmailSelector::getEmail( addr.emails(), addr.preferredEmail(), this ); 106 m = KABC::EmailSelector::getEmail( addr.emails(), addr.preferredEmail(), this );
105 107
106 email = addr.fullEmail( m ); 108 email = addr.fullEmail( m );
107 109
108 if ( !first ) 110 if ( !first )
109 emailAddrs += ", "; 111 emailAddrs += ", ";
110 else 112 else
111 first = false; 113 first = false;
112 114
113 emailAddrs += email; 115 emailAddrs += email;
114 } 116 }
115 } 117 }
116 118
117 return emailAddrs; 119 return emailAddrs;
118} 120}
119 121
120KABC::Addressee::List KAddressBookView::addressees() 122KABC::Addressee::List KAddressBookView::addressees()
121{ 123{
122 KABC::Addressee::List addresseeList; 124 KABC::Addressee::List addresseeList;
123 125
124 KABC::AddressBook::Iterator it; 126 KABC::AddressBook::Iterator it;
125 for (it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 127 for (it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
126 if ( mFilter.filterAddressee( *it ) ) 128 if ( mFilter.filterAddressee( *it ) )
127 addresseeList.append( *it ); 129 addresseeList.append( *it );
128 } 130 }
129 131
130 return addresseeList; 132 return addresseeList;
131} 133}
132 134
133void KAddressBookView::initGUI() 135void KAddressBookView::initGUI()
134{ 136{
135 // Create the layout 137 // Create the layout
136 QVBoxLayout *layout = new QVBoxLayout( this ); 138 Q3VBoxLayout *layout = new Q3VBoxLayout( this );
137 139
138 // Add the view widget 140 // Add the view widget
139 mViewWidget = new QWidget( this ); 141 mViewWidget = new QWidget( this );
140 layout->addWidget( mViewWidget ); 142 layout->addWidget( mViewWidget );
141} 143}
142 144
143KABC::Field::List KAddressBookView::fields() const 145KABC::Field::List KAddressBookView::fields() const
144{ 146{
145 return mFieldList; 147 return mFieldList;
146} 148}
147KABC::Field::List KAddressBookView::allFields() const 149KABC::Field::List KAddressBookView::allFields() const
148{ 150{
149 return KABC::Field::allFields(); 151 return KABC::Field::allFields();
150} 152}
151 153
152void KAddressBookView::setFilter( const Filter &filter ) 154void KAddressBookView::setFilter( const Filter &filter )
153{ 155{
154 mFilter = filter; 156 mFilter = filter;
155} 157}
156 158
157KAddressBookView::DefaultFilterType KAddressBookView::defaultFilterType() const 159KAddressBookView::DefaultFilterType KAddressBookView::defaultFilterType() const
158{ 160{
159 return mDefaultFilterType; 161 return mDefaultFilterType;
160} 162}
161 163
162const QString &KAddressBookView::defaultFilterName() const 164const QString &KAddressBookView::defaultFilterName() const
163{ 165{
164 return mDefaultFilterName; 166 return mDefaultFilterName;
165} 167}
166 168
167KABC::AddressBook *KAddressBookView::addressBook() const 169KABC::AddressBook *KAddressBookView::addressBook() const
168{ 170{
169 return mAddressBook; 171 return mAddressBook;
170} 172}
171 173
172QWidget *KAddressBookView::viewWidget() 174QWidget *KAddressBookView::viewWidget()
173{ 175{
174 return mViewWidget; 176 return mViewWidget;
175} 177}
176 178
177ViewConfigureWidget *ViewFactory::configureWidget( KABC::AddressBook *ab, 179ViewConfigureWidget *ViewFactory::configureWidget( KABC::AddressBook *ab,
178 QWidget *parent, 180 QWidget *parent,
179 const char *name ) 181 const char *name )
180{ 182{
181 return new ViewConfigureWidget( ab, parent, name ); 183 return new ViewConfigureWidget( ab, parent, name );
182} 184}
183 185
184 186
185 187
186#ifndef KAB_EMBEDDED 188#ifndef KAB_EMBEDDED_
187#include "kaddressbookview.moc" 189#include "moc_kaddressbookview.cpp"
188#endif //KAB_EMBEDDED 190#endif //KAB_EMBEDDED