summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-27 10:38:24 (UTC)
committer zautrix <zautrix>2005-06-27 10:38:24 (UTC)
commit24cdc6d9bf9f31b036fae270b32cc85808280e68 (patch) (unidiff)
tree6b1be13c17453011a1d71b5f0e8a4157282336cc
parent16d3551a207f02679aeaeb943f00684db223934d (diff)
downloadkdepimpi-24cdc6d9bf9f31b036fae270b32cc85808280e68.zip
kdepimpi-24cdc6d9bf9f31b036fae270b32cc85808280e68.tar.gz
kdepimpi-24cdc6d9bf9f31b036fae270b32cc85808280e68.tar.bz2
fixx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/xxport/csv_xxport.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/kaddressbook/xxport/csv_xxport.cpp b/kaddressbook/xxport/csv_xxport.cpp
index 81148d9..7281003 100644
--- a/kaddressbook/xxport/csv_xxport.cpp
+++ b/kaddressbook/xxport/csv_xxport.cpp
@@ -10,48 +10,49 @@
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/* 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#include <qfile.h> 31#include <qfile.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qtextcodec.h>
34 35
35#include <kfiledialog.h> 36#include <kfiledialog.h>
36#ifndef KAB_EMBEDDED 37#ifndef KAB_EMBEDDED
37#include <kio/netaccess.h> 38#include <kio/netaccess.h>
38#endif //KAB_EMBEDDED 39#endif //KAB_EMBEDDED
39 40
40#include <klocale.h> 41#include <klocale.h>
41#include <kmessagebox.h> 42#include <kmessagebox.h>
42#include <ktempfile.h> 43#include <ktempfile.h>
43#include <kurl.h> 44#include <kurl.h>
44 45
45#include "csvimportdialog.h" 46#include "csvimportdialog.h"
46 47
47#include "csv_xxport.h" 48#include "csv_xxport.h"
48 49
49 50
50#ifndef KAB_EMBEDDED 51#ifndef KAB_EMBEDDED
51 52
52class CSVXXPortFactory : public XXPortFactory 53class CSVXXPortFactory : public XXPortFactory
53{ 54{
54 public: 55 public:
55 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name ) 56 XXPortObject *xxportObject( KABC::AddressBook *ab, QWidget *parent, const char *name )
56 { 57 {
57 return new CSVXXPort( ab, parent, name ); 58 return new CSVXXPort( ab, parent, name );
@@ -130,63 +131,64 @@ bool CSVXXPort::exportContacts( const KABC::AddresseeList &list, const QString&
130 } 131 }
131 132
132 doExport( &file, list ); 133 doExport( &file, list );
133 file.close(); 134 file.close();
134 135
135 return true; 136 return true;
136 137
137 138
138#endif //KAB_EMBEDDED 139#endif //KAB_EMBEDDED
139 140
140} 141}
141 142
142KABC::AddresseeList CSVXXPort::importContacts( const QString& ) const 143KABC::AddresseeList CSVXXPort::importContacts( const QString& ) const
143{ 144{
144 CSVImportDialog dlg( addressBook(), parentWidget() ); 145 CSVImportDialog dlg( addressBook(), parentWidget() );
145 if ( dlg.exec() ) 146 if ( dlg.exec() )
146 return dlg.contacts(); 147 return dlg.contacts();
147 else 148 else
148 return KABC::AddresseeList(); 149 return KABC::AddresseeList();
149} 150}
150 151
151void CSVXXPort::doExport( QFile *fp, const KABC::AddresseeList &list ) 152void CSVXXPort::doExport( QFile *fp, const KABC::AddresseeList &list )
152{ 153{
153 QTextStream t( fp ); 154 QTextStream t( fp );
155 t.setCodec( QTextCodec::codecForName("utf8") );
154 156
155 KABC::AddresseeList::ConstIterator iter; 157 KABC::AddresseeList::ConstIterator iter;
156 KABC::Field::List fields = addressBook()->fields(); 158 KABC::Field::List fields = addressBook()->fields();
157 KABC::Field::List::Iterator fieldIter; 159 KABC::Field::List::Iterator fieldIter;
158 bool first = true; 160 bool first = true;
159 161
160 // First output the column headings 162 // First output the column headings
161 for ( fieldIter = fields.begin(); fieldIter != fields.end(); ++fieldIter ) { 163 for ( fieldIter = fields.begin(); fieldIter != fields.end(); ++fieldIter ) {
162 if ( !first ) 164 if ( !first )
163 t << ","; 165 t << ",";
164 166
165 t << "\"" << (*fieldIter)->label() << "\""; 167 t << "\"" << (*fieldIter)->label() << "\"";
166 first = false; 168 first = false;
167 } 169 }
168 t << "\n"; 170 t << "\n";
169 171
170 // Then all the addressee objects 172 // Then all the addressee objects
171 KABC::Addressee addr; 173 KABC::Addressee addr;
172 for ( iter = list.begin(); iter != list.end(); ++iter ) { 174 for ( iter = list.begin(); iter != list.end(); ++iter ) {
173 addr = *iter; 175 addr = *iter;
174 first = true; 176 first = true;
175 177
176 for ( fieldIter = fields.begin(); fieldIter != fields.end(); ++fieldIter ) { 178 for ( fieldIter = fields.begin(); fieldIter != fields.end(); ++fieldIter ) {
177 if ( !first ) 179 if ( !first )
178 t << ","; 180 t << ",";
179 181
180 t << "\"" << (*fieldIter)->value( addr ).replace( QRegExp("\n"), "\\n" ) << "\""; 182 t << "\"" << (*fieldIter)->value( addr ) << "\"";
181 first = false; 183 first = false;
182 } 184 }
183 185
184 t << "\n"; 186 t << "\n";
185 } 187 }
186} 188}
187 189
188#ifndef KAB_EMBEDDED 190#ifndef KAB_EMBEDDED
189#include "csv_xxport.moc" 191#include "csv_xxport.moc"
190#endif //KAB_EMBEDDED 192#endif //KAB_EMBEDDED
191 193
192 194