author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kaddressbook/xxport | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | kaddressbook/xxport/csv_xxport.cpp | 14 | ||||
-rw-r--r-- | kaddressbook/xxport/csvimportdialog.cpp | 66 | ||||
-rw-r--r-- | kaddressbook/xxport/csvimportdialog.h | 12 | ||||
-rw-r--r-- | kaddressbook/xxport/kde2_xxport.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/xxport/vcard_xxport.cpp | 20 |
5 files changed, 60 insertions, 56 deletions
diff --git a/kaddressbook/xxport/csv_xxport.cpp b/kaddressbook/xxport/csv_xxport.cpp index 7281003..ed5807f 100644 --- a/kaddressbook/xxport/csv_xxport.cpp +++ b/kaddressbook/xxport/csv_xxport.cpp | |||
@@ -25,17 +25,17 @@ | |||
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (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 <q3textstream.h> |
34 | #include <qtextcodec.h> | 34 | #include <qtextcodec.h> |
35 | 35 | ||
36 | #include <kfiledialog.h> | 36 | #include <kfiledialog.h> |
37 | #ifndef KAB_EMBEDDED | 37 | #ifndef KAB_EMBEDDED |
38 | #include <kio/netaccess.h> | 38 | #include <kio/netaccess.h> |
39 | #endif //KAB_EMBEDDED | 39 | #endif //KAB_EMBEDDED |
40 | 40 | ||
41 | #include <klocale.h> | 41 | #include <klocale.h> |
@@ -99,17 +99,17 @@ bool CSVXXPort::exportContacts( const KABC::AddresseeList &list, const QString& | |||
99 | } | 99 | } |
100 | 100 | ||
101 | doExport( tmpFile.file(), list ); | 101 | doExport( tmpFile.file(), list ); |
102 | tmpFile.close(); | 102 | tmpFile.close(); |
103 | 103 | ||
104 | return KIO::NetAccess::upload( tmpFile.name(), url, parentWidget() ); | 104 | return KIO::NetAccess::upload( tmpFile.name(), url, parentWidget() ); |
105 | } else { | 105 | } else { |
106 | QFile file( url.path() ); | 106 | QFile file( url.path() ); |
107 | if ( !file.open( IO_WriteOnly ) ) { | 107 | if ( !file.open( QIODevice::WriteOnly ) ) { |
108 | QString txt = i18n( "<qt>Unable to open file <b>%1</b>.</qt>" ); | 108 | QString txt = i18n( "<qt>Unable to open file <b>%1</b>.</qt>" ); |
109 | KMessageBox::error( parentWidget(), txt.arg( url.path() ) ); | 109 | KMessageBox::error( parentWidget(), txt.arg( url.path() ) ); |
110 | return false; | 110 | return false; |
111 | } | 111 | } |
112 | 112 | ||
113 | doExport( &file, list ); | 113 | doExport( &file, list ); |
114 | file.close(); | 114 | file.close(); |
115 | 115 | ||
@@ -119,17 +119,17 @@ bool CSVXXPort::exportContacts( const KABC::AddresseeList &list, const QString& | |||
119 | #else //KAB_EMBEDDED | 119 | #else //KAB_EMBEDDED |
120 | 120 | ||
121 | QString fileName = KFileDialog::getSaveFileName( "addressbook.csv", i18n("Save file"), parentWidget() ); | 121 | QString fileName = KFileDialog::getSaveFileName( "addressbook.csv", i18n("Save file"), parentWidget() ); |
122 | 122 | ||
123 | if ( fileName.isEmpty() ) | 123 | if ( fileName.isEmpty() ) |
124 | return false; | 124 | return false; |
125 | 125 | ||
126 | QFile file( fileName ); | 126 | QFile file( fileName ); |
127 | if ( !file.open( IO_WriteOnly ) ) { | 127 | if ( !file.open( QIODevice::WriteOnly ) ) { |
128 | QString txt = i18n( "<qt>Unable to open file <b>%1</b>.</qt>" ); | 128 | QString txt = i18n( "<qt>Unable to open file <b>%1</b>.</qt>" ); |
129 | KMessageBox::error( parentWidget(), txt.arg( fileName ) ); | 129 | KMessageBox::error( parentWidget(), txt.arg( fileName ) ); |
130 | return false; | 130 | return false; |
131 | } | 131 | } |
132 | 132 | ||
133 | doExport( &file, list ); | 133 | doExport( &file, list ); |
134 | file.close(); | 134 | file.close(); |
135 | 135 | ||
@@ -146,17 +146,17 @@ KABC::AddresseeList CSVXXPort::importContacts( const QString& ) const | |||
146 | if ( dlg.exec() ) | 146 | if ( dlg.exec() ) |
147 | return dlg.contacts(); | 147 | return dlg.contacts(); |
148 | else | 148 | else |
149 | return KABC::AddresseeList(); | 149 | return KABC::AddresseeList(); |
150 | } | 150 | } |
151 | 151 | ||
152 | void CSVXXPort::doExport( QFile *fp, const KABC::AddresseeList &list ) | 152 | void CSVXXPort::doExport( QFile *fp, const KABC::AddresseeList &list ) |
153 | { | 153 | { |
154 | QTextStream t( fp ); | 154 | Q3TextStream t( fp ); |
155 | t.setCodec( QTextCodec::codecForName("utf8") ); | 155 | t.setCodec( QTextCodec::codecForName("utf8") ); |
156 | 156 | ||
157 | KABC::AddresseeList::ConstIterator iter; | 157 | KABC::AddresseeList::ConstIterator iter; |
158 | KABC::Field::List fields = addressBook()->fields(); | 158 | KABC::Field::List fields = addressBook()->fields(); |
159 | KABC::Field::List::Iterator fieldIter; | 159 | KABC::Field::List::Iterator fieldIter; |
160 | bool first = true; | 160 | bool first = true; |
161 | 161 | ||
162 | // First output the column headings | 162 | // First output the column headings |
@@ -182,13 +182,11 @@ void CSVXXPort::doExport( QFile *fp, const KABC::AddresseeList &list ) | |||
182 | t << "\"" << (*fieldIter)->value( addr ) << "\""; | 182 | t << "\"" << (*fieldIter)->value( addr ) << "\""; |
183 | first = false; | 183 | first = false; |
184 | } | 184 | } |
185 | 185 | ||
186 | t << "\n"; | 186 | t << "\n"; |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | #ifndef KAB_EMBEDDED | 190 | #ifndef KAB_EMBEDDED_ |
191 | #include "csv_xxport.moc" | 191 | #include "moc_csv_xxport.cpp" |
192 | #endif //KAB_EMBEDDED | 192 | #endif //KAB_EMBEDDED |
193 | |||
194 | |||
diff --git a/kaddressbook/xxport/csvimportdialog.cpp b/kaddressbook/xxport/csvimportdialog.cpp index 862241e..7959cac 100644 --- a/kaddressbook/xxport/csvimportdialog.cpp +++ b/kaddressbook/xxport/csvimportdialog.cpp | |||
@@ -22,46 +22,50 @@ | |||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | 29 | ||
30 | #include <qbuttongroup.h> | 30 | #include <q3buttongroup.h> |
31 | #include <qcheckbox.h> | 31 | #include <qcheckbox.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #ifdef DESKTOP_VERSION | 33 | #ifdef DESKTOP_VERSION |
34 | #include <qinputdialog.h> | 34 | #include <qinputdialog.h> |
35 | #else | 35 | #else |
36 | #include <qtcompat/qinputdialog.h> | 36 | #include <qtcompat/qinputdialog.h> |
37 | #endif | 37 | #endif |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #include <qtable.h> | 42 | #include <q3table.h> |
43 | #include <qlayout.h> | 43 | #include <qlayout.h> |
44 | #include <qtextstream.h> | 44 | #include <q3textstream.h> |
45 | #include <qfile.h> | 45 | #include <qfile.h> |
46 | //Added by qt3to4: | ||
47 | #include <Q3HBoxLayout> | ||
48 | #include <Q3ValueList> | ||
49 | #include <Q3GridLayout> | ||
46 | 50 | ||
47 | #include <kapplication.h> | 51 | #include <kapplication.h> |
48 | #include <kdebug.h> | 52 | #include <kdebug.h> |
49 | #include <kdialogbase.h> | 53 | #include <kdialogbase.h> |
50 | #include <kfiledialog.h> | 54 | #include <kfiledialog.h> |
51 | #include <klineedit.h> | 55 | #include <klineedit.h> |
52 | #include <klocale.h> | 56 | #include <klocale.h> |
53 | #include <kglobal.h> | 57 | #include <kglobal.h> |
54 | #include <kmessagebox.h> | 58 | #include <kmessagebox.h> |
55 | #include <kstandarddirs.h> | 59 | #include <kstandarddirs.h> |
56 | #include <kurlrequester.h> | 60 | #include <kurlrequester.h> |
57 | 61 | ||
58 | #ifdef DESKTOP_VERSION | 62 | #ifdef DESKTOP_VERSION |
59 | #include "qtable.h" | 63 | #include "q3table.h" |
60 | #else | 64 | #else |
61 | #include "qcombotableitem.h" | 65 | #include "qcombotableitem.h" |
62 | #endif | 66 | #endif |
63 | #include "csvimportdialog.h" | 67 | #include "csvimportdialog.h" |
64 | 68 | ||
65 | CSVImportDialog::CSVImportDialog( KABC::AddressBook *ab, QWidget *parent, | 69 | CSVImportDialog::CSVImportDialog( KABC::AddressBook *ab, QWidget *parent, |
66 | const char * name ) | 70 | const char * name ) |
67 | : KDialogBase( Plain, i18n ( "CSV Import Dialog" ), Ok | Cancel | User1 | | 71 | : KDialogBase( Plain, i18n ( "CSV Import Dialog" ), Ok | Cancel | User1 | |
@@ -156,17 +160,17 @@ CSVImportDialog::CSVImportDialog( KABC::AddressBook *ab, QWidget *parent, | |||
156 | 160 | ||
157 | connect( this, SIGNAL( user1Clicked() ), | 161 | connect( this, SIGNAL( user1Clicked() ), |
158 | this, SLOT( applyTemplate() ) ); | 162 | this, SLOT( applyTemplate() ) ); |
159 | 163 | ||
160 | connect( this, SIGNAL( user2Clicked() ), | 164 | connect( this, SIGNAL( user2Clicked() ), |
161 | this, SLOT( saveTemplate() ) ); | 165 | this, SLOT( saveTemplate() ) ); |
162 | 166 | ||
163 | // if ( QApplication::desktop()->width() < 321 ) | 167 | // if ( QApplication::desktop()->width() < 321 ) |
164 | QIconSet icon = SmallIcon("filesave"); | 168 | QIcon icon = SmallIcon("filesave"); |
165 | 169 | ||
166 | findButton( User2 )->setIconSet (icon ) ; | 170 | findButton( User2 )->setIconSet (icon ) ; |
167 | icon = SmallIcon("fileopen"); | 171 | icon = SmallIcon("fileopen"); |
168 | findButton( User1 )->setIconSet (icon ) ; | 172 | findButton( User1 )->setIconSet (icon ) ; |
169 | int wid = findButton( User2 )->sizeHint().height(); | 173 | int wid = findButton( User2 )->sizeHint().height(); |
170 | findButton( User2 )->setMaximumWidth( wid+4 ); | 174 | findButton( User2 )->setMaximumWidth( wid+4 ); |
171 | findButton( User1 )->setMaximumWidth( wid+4 ); | 175 | findButton( User1 )->setMaximumWidth( wid+4 ); |
172 | } | 176 | } |
@@ -181,17 +185,17 @@ KABC::AddresseeList CSVImportDialog::contacts() const | |||
181 | 185 | ||
182 | for ( int row = 1; row < mTable->numRows(); ++row ) { | 186 | for ( int row = 1; row < mTable->numRows(); ++row ) { |
183 | KABC::Addressee a; | 187 | KABC::Addressee a; |
184 | bool emptyRow = true; | 188 | bool emptyRow = true; |
185 | KABC::Address addrHome( KABC::Address::Home ); | 189 | KABC::Address addrHome( KABC::Address::Home ); |
186 | KABC::Address addrWork( KABC::Address::Work ); | 190 | KABC::Address addrWork( KABC::Address::Work ); |
187 | for ( int col = 0; col < mTable->numCols(); ++col ) { | 191 | for ( int col = 0; col < mTable->numCols(); ++col ) { |
188 | 192 | ||
189 | QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, col ) ); | 193 | Q3ComboTableItem *item = static_cast<Q3ComboTableItem*>( mTable->item( 0, col ) ); |
190 | 194 | ||
191 | if ( !item ) { | 195 | if ( !item ) { |
192 | qDebug( "ERROR: item cast failed" ); | 196 | qDebug( "ERROR: item cast failed" ); |
193 | continue; | 197 | continue; |
194 | } | 198 | } |
195 | 199 | ||
196 | QString value = mTable->text( row, col ); | 200 | QString value = mTable->text( row, col ); |
197 | if ( !value.isEmpty() ) | 201 | if ( !value.isEmpty() ) |
@@ -224,17 +228,17 @@ KABC::AddresseeList CSVImportDialog::contacts() const | |||
224 | a.setNickName( value ); | 228 | a.setNickName( value ); |
225 | break; | 229 | break; |
226 | case Birthday: | 230 | case Birthday: |
227 | //US | 231 | //US |
228 | //the generated code had the following format: a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); | 232 | //the generated code had the following format: a.setBirthday( QDate::fromString( value, Qt::ISODate ) ); |
229 | // But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? | 233 | // But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ? |
230 | { | 234 | { |
231 | QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate | 235 | QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate |
232 | a.setBirthday(dt); | 236 | a.setBirthday(QDateTime(dt)); |
233 | } | 237 | } |
234 | break; | 238 | break; |
235 | case Email: | 239 | case Email: |
236 | if ( !value.isEmpty() ) | 240 | if ( !value.isEmpty() ) |
237 | a.insertEmail( value, true ); | 241 | a.insertEmail( value, true ); |
238 | break; | 242 | break; |
239 | case Role: | 243 | case Role: |
240 | a.setRole( value ); | 244 | a.setRole( value ); |
@@ -377,36 +381,36 @@ KABC::AddresseeList CSVImportDialog::contacts() const | |||
377 | 381 | ||
378 | return contacts; | 382 | return contacts; |
379 | } | 383 | } |
380 | 384 | ||
381 | void CSVImportDialog::initGUI() | 385 | void CSVImportDialog::initGUI() |
382 | { | 386 | { |
383 | QWidget* page = plainPage(); | 387 | QWidget* page = plainPage(); |
384 | 388 | ||
385 | QGridLayout *layout = new QGridLayout( page, 1, 1, marginHintSmall(), | 389 | Q3GridLayout *layout = new Q3GridLayout( page, 1, 1, marginHintSmall(), |
386 | spacingHintSmall() ); | 390 | spacingHintSmall() ); |
387 | QHBoxLayout *hbox = new QHBoxLayout(); | 391 | Q3HBoxLayout *hbox = new Q3HBoxLayout(); |
388 | hbox->setSpacing( spacingHint() ); | 392 | hbox->setSpacing( spacingHint() ); |
389 | 393 | ||
390 | QLabel *label = new QLabel( i18n( "File to import:" ), page ); | 394 | QLabel *label = new QLabel( i18n( "File to import:" ), page ); |
391 | hbox->addWidget( label ); | 395 | hbox->addWidget( label ); |
392 | 396 | ||
393 | mUrlRequester = new KURLRequester( page ); | 397 | mUrlRequester = new KURLRequester( page ); |
394 | mUrlRequester->setFilter( "*.csv" ); | 398 | mUrlRequester->setFilter( "*.csv" ); |
395 | hbox->addWidget( mUrlRequester ); | 399 | hbox->addWidget( mUrlRequester ); |
396 | 400 | ||
397 | layout->addMultiCellLayout( hbox, 0, 0, 0, 2 ); | 401 | layout->addMultiCellLayout( hbox, 0, 0, 0, 2 ); |
398 | 402 | ||
399 | // Delimiter: comma, semicolon, tab, space, other | 403 | // Delimiter: comma, semicolon, tab, space, other |
400 | mDelimiterBox = new QButtonGroup( i18n( "Delimiter" ), page ); | 404 | mDelimiterBox = new Q3ButtonGroup( i18n( "Delimiter" ), page ); |
401 | mDelimiterBox->setColumnLayout( 0, Qt::Vertical ); | 405 | mDelimiterBox->setColumnLayout( 0, Qt::Vertical ); |
402 | mDelimiterBox->layout()->setSpacing( spacingHint() ); | 406 | mDelimiterBox->layout()->setSpacing( spacingHint() ); |
403 | mDelimiterBox->layout()->setMargin( marginHint() ); | 407 | mDelimiterBox->layout()->setMargin( marginHint() ); |
404 | QGridLayout *delimiterLayout = new QGridLayout( mDelimiterBox->layout() ); | 408 | Q3GridLayout *delimiterLayout = new Q3GridLayout( mDelimiterBox->layout() ); |
405 | delimiterLayout->setAlignment( Qt::AlignTop ); | 409 | delimiterLayout->setAlignment( Qt::AlignTop ); |
406 | layout->addMultiCellWidget( mDelimiterBox, 1, 1, 0, 2 ); | 410 | layout->addMultiCellWidget( mDelimiterBox, 1, 1, 0, 2 ); |
407 | 411 | ||
408 | mRadioComma = new QRadioButton( i18n( "Comma" ), mDelimiterBox ); | 412 | mRadioComma = new QRadioButton( i18n( "Comma" ), mDelimiterBox ); |
409 | mRadioComma->setChecked( true ); | 413 | mRadioComma->setChecked( true ); |
410 | delimiterLayout->addWidget( mRadioComma, 0, 0 ); | 414 | delimiterLayout->addWidget( mRadioComma, 0, 0 ); |
411 | 415 | ||
412 | mRadioSemicolon = new QRadioButton( i18n( "Semicolon" ), mDelimiterBox ); | 416 | mRadioSemicolon = new QRadioButton( i18n( "Semicolon" ), mDelimiterBox ); |
@@ -445,18 +449,18 @@ void CSVImportDialog::initGUI() | |||
445 | layout->addWidget( label, 2, 0 ); | 449 | layout->addWidget( label, 2, 0 ); |
446 | label = new QLabel( i18n( "Codec:" ), page ); | 450 | label = new QLabel( i18n( "Codec:" ), page ); |
447 | layout->addWidget( label, 2, 2 ); | 451 | layout->addWidget( label, 2, 2 ); |
448 | 452 | ||
449 | mIgnoreDuplicates = new QCheckBox( page ); | 453 | mIgnoreDuplicates = new QCheckBox( page ); |
450 | mIgnoreDuplicates->setText( i18n( "Ignore duplicate delimiters" ) ); | 454 | mIgnoreDuplicates->setText( i18n( "Ignore duplicate delimiters" ) ); |
451 | layout->addMultiCellWidget( mIgnoreDuplicates, 4, 4, 0, 2 ); | 455 | layout->addMultiCellWidget( mIgnoreDuplicates, 4, 4, 0, 2 ); |
452 | 456 | ||
453 | mTable = new QTable( 0, 0, page ); | 457 | mTable = new Q3Table( 0, 0, page ); |
454 | mTable->setSelectionMode( QTable::NoSelection ); | 458 | mTable->setSelectionMode( Q3Table::NoSelection ); |
455 | //mTable->horizontalHeader()->hide(); | 459 | //mTable->horizontalHeader()->hide(); |
456 | layout->addMultiCellWidget( mTable, 5, 5, 0, 2 ); | 460 | layout->addMultiCellWidget( mTable, 5, 5, 0, 2 ); |
457 | /*US | 461 | /*US |
458 | setButtonText( User1, i18n( "Apply Template" ) ); | 462 | setButtonText( User1, i18n( "Apply Template" ) ); |
459 | setButtonText( User2, i18n( "Save Template" ) ); | 463 | setButtonText( User2, i18n( "Save Template" ) ); |
460 | */ | 464 | */ |
461 | 465 | ||
462 | enableButtonOK( false ); | 466 | enableButtonOK( false ); |
@@ -478,21 +482,21 @@ void CSVImportDialog::fillTable() | |||
478 | bool ignoreDups = mIgnoreDuplicates->isChecked(); | 482 | bool ignoreDups = mIgnoreDuplicates->isChecked(); |
479 | enum { S_START, S_QUOTED_FIELD, S_MAYBE_END_OF_QUOTED_FIELD, S_END_OF_QUOTED_FIELD, | 483 | enum { S_START, S_QUOTED_FIELD, S_MAYBE_END_OF_QUOTED_FIELD, S_END_OF_QUOTED_FIELD, |
480 | S_MAYBE_NORMAL_FIELD, S_NORMAL_FIELD } state = S_START; | 484 | S_MAYBE_NORMAL_FIELD, S_NORMAL_FIELD } state = S_START; |
481 | 485 | ||
482 | QChar x; | 486 | QChar x; |
483 | QString field = ""; | 487 | QString field = ""; |
484 | 488 | ||
485 | // store previous assignment | 489 | // store previous assignment |
486 | QValueList<int> mTypeOld = mTypeStore; | 490 | Q3ValueList<int> mTypeOld = mTypeStore; |
487 | 491 | ||
488 | mTypeStore.clear(); | 492 | mTypeStore.clear(); |
489 | for ( column = 0; column < mTable->numCols(); ++column ) { | 493 | for ( column = 0; column < mTable->numCols(); ++column ) { |
490 | QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, column ) ); | 494 | Q3ComboTableItem *item = static_cast<Q3ComboTableItem*>( mTable->item( 0, column ) ); |
491 | 495 | ||
492 | if ( !item || mClearTypeStore ) | 496 | if ( !item || mClearTypeStore ) |
493 | mTypeStore.append( typeToPos( Undefined ) ); | 497 | mTypeStore.append( typeToPos( Undefined ) ); |
494 | else if ( item ) | 498 | else if ( item ) |
495 | mTypeStore.append( item->currentItem() ); | 499 | mTypeStore.append( item->currentItem() ); |
496 | } | 500 | } |
497 | 501 | ||
498 | clearTable(); | 502 | clearTable(); |
@@ -501,37 +505,37 @@ void CSVImportDialog::fillTable() | |||
501 | if ( mComboCodec->currentItem () == 0 ) { | 505 | if ( mComboCodec->currentItem () == 0 ) { |
502 | mData = QString::fromUtf8( mFileArray.data() ); | 506 | mData = QString::fromUtf8( mFileArray.data() ); |
503 | } else if ( mComboCodec->currentItem () == 1 ) { | 507 | } else if ( mComboCodec->currentItem () == 1 ) { |
504 | mData = QString::fromLatin1( mFileArray.data() ); | 508 | mData = QString::fromLatin1( mFileArray.data() ); |
505 | } else { | 509 | } else { |
506 | mData = QString::fromLocal8Bit( mFileArray.data() ); | 510 | mData = QString::fromLocal8Bit( mFileArray.data() ); |
507 | } | 511 | } |
508 | 512 | ||
509 | QTextStream inputStream( mData, IO_ReadOnly ); | 513 | Q3TextStream inputStream( mData, QIODevice::ReadOnly ); |
510 | 514 | ||
511 | if ( mComboCodec->currentItem () == 0 ) { | 515 | if ( mComboCodec->currentItem () == 0 ) { |
512 | inputStream.setEncoding( QTextStream::UnicodeUTF8 ); | 516 | inputStream.setEncoding( Q3TextStream::UnicodeUTF8 ); |
513 | } else if ( mComboCodec->currentItem () == 1 ) { | 517 | } else if ( mComboCodec->currentItem () == 1 ) { |
514 | inputStream.setEncoding( QTextStream::Latin1 ); | 518 | inputStream.setEncoding( Q3TextStream::Latin1 ); |
515 | } else { | 519 | } else { |
516 | inputStream.setEncoding( QTextStream::Locale ); | 520 | inputStream.setEncoding( Q3TextStream::Locale ); |
517 | } | 521 | } |
518 | 522 | ||
519 | int maxColumn = 0; | 523 | int maxColumn = 0; |
520 | while ( !inputStream.atEnd() ) { | 524 | while ( !inputStream.atEnd() ) { |
521 | inputStream >> x; // read one char | 525 | inputStream >> x; // read one char |
522 | 526 | ||
523 | if ( x == '\r' ) inputStream >> x; // eat '\r', to handle DOS/LOSEDOWS files correctly | 527 | if ( x == '\r' ) inputStream >> x; // eat '\r', to handle DOS/LOSEDOWS files correctly |
524 | 528 | ||
525 | switch ( state ) { | 529 | switch ( state ) { |
526 | case S_START : | 530 | case S_START : |
527 | if ( x == mTextQuote ) { | 531 | if ( x == mTextQuote ) { |
528 | state = S_QUOTED_FIELD; | 532 | state = S_QUOTED_FIELD; |
529 | } else if ( x == mDelimiter ) { | 533 | } else if ( QString(x) == mDelimiter ) { |
530 | if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) ) | 534 | if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) ) |
531 | ++column; | 535 | ++column; |
532 | lastCharDelimiter = true; | 536 | lastCharDelimiter = true; |
533 | } else if ( x == '\n' ) { | 537 | } else if ( x == '\n' ) { |
534 | ++row; | 538 | ++row; |
535 | column = 1; | 539 | column = 1; |
536 | } else { | 540 | } else { |
537 | field += x; | 541 | field += x; |
@@ -556,34 +560,34 @@ void CSVImportDialog::fillTable() | |||
556 | } else { | 560 | } else { |
557 | field += x; | 561 | field += x; |
558 | } | 562 | } |
559 | break; | 563 | break; |
560 | case S_MAYBE_END_OF_QUOTED_FIELD : | 564 | case S_MAYBE_END_OF_QUOTED_FIELD : |
561 | if ( x == mTextQuote ) { | 565 | if ( x == mTextQuote ) { |
562 | field += x; | 566 | field += x; |
563 | state = S_QUOTED_FIELD; | 567 | state = S_QUOTED_FIELD; |
564 | } else if ( x == mDelimiter || x == '\n' ) { | 568 | } else if ( QString(x) == mDelimiter || x == '\n' ) { |
565 | setText( row - mStartLine + 1, column, field ); | 569 | setText( row - mStartLine + 1, column, field ); |
566 | field = ""; | 570 | field = ""; |
567 | if ( x == '\n' ) { | 571 | if ( x == '\n' ) { |
568 | ++row; | 572 | ++row; |
569 | column = 1; | 573 | column = 1; |
570 | } else { | 574 | } else { |
571 | if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) ) | 575 | if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) ) |
572 | ++column; | 576 | ++column; |
573 | lastCharDelimiter = true; | 577 | lastCharDelimiter = true; |
574 | } | 578 | } |
575 | state = S_START; | 579 | state = S_START; |
576 | } else { | 580 | } else { |
577 | state = S_END_OF_QUOTED_FIELD; | 581 | state = S_END_OF_QUOTED_FIELD; |
578 | } | 582 | } |
579 | break; | 583 | break; |
580 | case S_END_OF_QUOTED_FIELD : | 584 | case S_END_OF_QUOTED_FIELD : |
581 | if ( x == mDelimiter || x == '\n' ) { | 585 | if ( QString(x) == mDelimiter || x == '\n' ) { |
582 | setText( row - mStartLine + 1, column, field ); | 586 | setText( row - mStartLine + 1, column, field ); |
583 | field = ""; | 587 | field = ""; |
584 | if ( x == '\n' ) { | 588 | if ( x == '\n' ) { |
585 | ++row; | 589 | ++row; |
586 | column = 1; | 590 | column = 1; |
587 | } else { | 591 | } else { |
588 | if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) ) | 592 | if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) ) |
589 | ++column; | 593 | ++column; |
@@ -596,33 +600,33 @@ void CSVImportDialog::fillTable() | |||
596 | break; | 600 | break; |
597 | case S_MAYBE_NORMAL_FIELD : | 601 | case S_MAYBE_NORMAL_FIELD : |
598 | if ( x == mTextQuote ) { | 602 | if ( x == mTextQuote ) { |
599 | field = ""; | 603 | field = ""; |
600 | state = S_QUOTED_FIELD; | 604 | state = S_QUOTED_FIELD; |
601 | break; | 605 | break; |
602 | } | 606 | } |
603 | case S_NORMAL_FIELD : | 607 | case S_NORMAL_FIELD : |
604 | if ( x == mDelimiter || x == '\n' ) { | 608 | if ( QString(x) == mDelimiter || x == '\n' ) { |
605 | setText( row - mStartLine + 1, column, field ); | 609 | setText( row - mStartLine + 1, column, field ); |
606 | field = ""; | 610 | field = ""; |
607 | if ( x == '\n' ) { | 611 | if ( x == '\n' ) { |
608 | ++row; | 612 | ++row; |
609 | column = 1; | 613 | column = 1; |
610 | } else { | 614 | } else { |
611 | if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) ) | 615 | if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) ) |
612 | ++column; | 616 | ++column; |
613 | lastCharDelimiter = true; | 617 | lastCharDelimiter = true; |
614 | } | 618 | } |
615 | state = S_START; | 619 | state = S_START; |
616 | } else { | 620 | } else { |
617 | field += x; | 621 | field += x; |
618 | } | 622 | } |
619 | } | 623 | } |
620 | if ( x != mDelimiter ) | 624 | if ( QString(x) != mDelimiter ) |
621 | lastCharDelimiter = false; | 625 | lastCharDelimiter = false; |
622 | 626 | ||
623 | if ( column > maxColumn ) | 627 | if ( column > maxColumn ) |
624 | maxColumn = column; | 628 | maxColumn = column; |
625 | } | 629 | } |
626 | 630 | ||
627 | // file with only one line without '\n' | 631 | // file with only one line without '\n' |
628 | if ( field.length() > 0 ) { | 632 | if ( field.length() > 0 ) { |
@@ -644,17 +648,17 @@ void CSVImportDialog::fillTable() | |||
644 | QMap<QString, uint>::ConstIterator it; | 648 | QMap<QString, uint>::ConstIterator it; |
645 | for ( it = mTypeMap.begin(); it != mTypeMap.end(); ++it) | 649 | for ( it = mTypeMap.begin(); it != mTypeMap.end(); ++it) |
646 | keys[( it.data() )] = it.key(); | 650 | keys[( it.data() )] = it.key(); |
647 | //US end | 651 | //US end |
648 | 652 | ||
649 | for ( column = 0; column < mTable->numCols(); ++column ) { | 653 | for ( column = 0; column < mTable->numCols(); ++column ) { |
650 | 654 | ||
651 | //US QComboTableItem *item = new QComboTableItem( mTable, mTypeMap.keys() ); | 655 | //US QComboTableItem *item = new QComboTableItem( mTable, mTypeMap.keys() ); |
652 | QComboTableItem *item = new QComboTableItem( mTable, keys ); | 656 | Q3ComboTableItem *item = new Q3ComboTableItem( mTable, keys ); |
653 | mTable->setItem( 0, column, item ); | 657 | mTable->setItem( 0, column, item ); |
654 | if ( column < mTypeStore.count() ) | 658 | if ( column < mTypeStore.count() ) |
655 | item->setCurrentItem( mTypeStore[ column ] ); | 659 | item->setCurrentItem( mTypeStore[ column ] ); |
656 | else | 660 | else |
657 | item->setCurrentItem( typeToPos( Undefined ) ); | 661 | item->setCurrentItem( typeToPos( Undefined ) ); |
658 | 662 | ||
659 | mTable->adjustColumn( column ); | 663 | mTable->adjustColumn( column ); |
660 | } | 664 | } |
@@ -759,17 +763,17 @@ void CSVImportDialog::lineSelected( const QString& line ) | |||
759 | fillTable(); | 763 | fillTable(); |
760 | } | 764 | } |
761 | 765 | ||
762 | void CSVImportDialog::slotOk() | 766 | void CSVImportDialog::slotOk() |
763 | { | 767 | { |
764 | bool assigned = false; | 768 | bool assigned = false; |
765 | 769 | ||
766 | for ( int column = 0; column < mTable->numCols(); ++column ) { | 770 | for ( int column = 0; column < mTable->numCols(); ++column ) { |
767 | QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, | 771 | Q3ComboTableItem *item = static_cast<Q3ComboTableItem*>( mTable->item( 0, |
768 | column ) ); | 772 | column ) ); |
769 | if ( item && posToType( item->currentItem() ) != Undefined ) | 773 | if ( item && posToType( item->currentItem() ) != Undefined ) |
770 | assigned = true; | 774 | assigned = true; |
771 | } | 775 | } |
772 | 776 | ||
773 | if ( assigned ) | 777 | if ( assigned ) |
774 | KDialogBase::slotOk(); | 778 | KDialogBase::slotOk(); |
775 | else | 779 | else |
@@ -831,17 +835,17 @@ void CSVImportDialog::applyTemplate() | |||
831 | for ( uint i = 0; i < numColumns; ++i ) { | 835 | for ( uint i = 0; i < numColumns; ++i ) { |
832 | int col = config.readNumEntry( QString::number( i ) ); | 836 | int col = config.readNumEntry( QString::number( i ) ); |
833 | columnMap.insert( i, col ); | 837 | columnMap.insert( i, col ); |
834 | } | 838 | } |
835 | 839 | ||
836 | // apply the column map | 840 | // apply the column map |
837 | for ( uint column = 0; column < columnMap.count(); ++column ) { | 841 | for ( uint column = 0; column < columnMap.count(); ++column ) { |
838 | int type = columnMap[ column ]; | 842 | int type = columnMap[ column ]; |
839 | QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, | 843 | Q3ComboTableItem *item = static_cast<Q3ComboTableItem*>( mTable->item( 0, |
840 | column ) ); | 844 | column ) ); |
841 | if ( item ) | 845 | if ( item ) |
842 | item->setCurrentItem( typeToPos( type ) ); | 846 | item->setCurrentItem( typeToPos( type ) ); |
843 | } | 847 | } |
844 | } | 848 | } |
845 | 849 | ||
846 | void CSVImportDialog::saveTemplate() | 850 | void CSVImportDialog::saveTemplate() |
847 | { | 851 | { |
@@ -873,17 +877,17 @@ void CSVImportDialog::saveTemplate() | |||
873 | config.writeEntry( "QuoteType", mComboQuote->currentItem() ); | 877 | config.writeEntry( "QuoteType", mComboQuote->currentItem() ); |
874 | 878 | ||
875 | config.setGroup( "Misc" ); | 879 | config.setGroup( "Misc" ); |
876 | config.writeEntry( "Name", name ); | 880 | config.writeEntry( "Name", name ); |
877 | 881 | ||
878 | config.setGroup( "csv column map" ); | 882 | config.setGroup( "csv column map" ); |
879 | 883 | ||
880 | for ( uint column = 0; column < mTable->numCols(); ++column ) { | 884 | for ( uint column = 0; column < mTable->numCols(); ++column ) { |
881 | QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, | 885 | Q3ComboTableItem *item = static_cast<Q3ComboTableItem*>( mTable->item( 0, |
882 | column ) ); | 886 | column ) ); |
883 | if ( item ) | 887 | if ( item ) |
884 | config.writeEntry( QString::number( column ), posToType( | 888 | config.writeEntry( QString::number( column ), posToType( |
885 | item->currentItem() ) ); | 889 | item->currentItem() ) ); |
886 | else | 890 | else |
887 | config.writeEntry( QString::number( column ), 0 ); | 891 | config.writeEntry( QString::number( column ), 0 ); |
888 | } | 892 | } |
889 | 893 | ||
@@ -929,17 +933,17 @@ void CSVImportDialog::ignoreDuplicatesChanged( int ) | |||
929 | } | 933 | } |
930 | 934 | ||
931 | void CSVImportDialog::setFile( const QString &fileName ) | 935 | void CSVImportDialog::setFile( const QString &fileName ) |
932 | { | 936 | { |
933 | if ( fileName.isEmpty() ) | 937 | if ( fileName.isEmpty() ) |
934 | return; | 938 | return; |
935 | 939 | ||
936 | QFile file( fileName ); | 940 | QFile file( fileName ); |
937 | if ( !file.open( IO_ReadOnly ) ) { | 941 | if ( !file.open( QIODevice::ReadOnly ) ) { |
938 | KMessageBox::sorry( this, i18n( "Cannot open input file!" ) ); | 942 | KMessageBox::sorry( this, i18n( "Cannot open input file!" ) ); |
939 | file.close(); | 943 | file.close(); |
940 | return; | 944 | return; |
941 | } | 945 | } |
942 | 946 | ||
943 | mFileArray = file.readAll(); | 947 | mFileArray = file.readAll(); |
944 | file.close(); | 948 | file.close(); |
945 | 949 | ||
@@ -959,11 +963,11 @@ void CSVImportDialog::urlChanged( const QString &file ) | |||
959 | 963 | ||
960 | enableButtonOK( state ); | 964 | enableButtonOK( state ); |
961 | 965 | ||
962 | findButton( User1 )->setEnabled( state ); | 966 | findButton( User1 )->setEnabled( state ); |
963 | findButton( User2 )->setEnabled( state ); | 967 | findButton( User2 )->setEnabled( state ); |
964 | 968 | ||
965 | } | 969 | } |
966 | 970 | ||
967 | #ifndef KAB_EMBEDDED | 971 | #ifndef KAB_EMBEDDED_ |
968 | #include <csvimportdialog.moc> | 972 | #include <moc_csvimportdialog.cpp> |
969 | #endif //KAB_EMBEDDED | 973 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/xxport/csvimportdialog.h b/kaddressbook/xxport/csvimportdialog.h index 2661420..520f3fa 100644 --- a/kaddressbook/xxport/csvimportdialog.h +++ b/kaddressbook/xxport/csvimportdialog.h | |||
@@ -28,27 +28,27 @@ $Id$ | |||
28 | 28 | ||
29 | #ifndef CSV_IMPORT_DLG_H | 29 | #ifndef CSV_IMPORT_DLG_H |
30 | #define CSV_IMPORT_DLG_H | 30 | #define CSV_IMPORT_DLG_H |
31 | 31 | ||
32 | #include <kabc/addressbook.h> | 32 | #include <kabc/addressbook.h> |
33 | #include <kabc/addresseelist.h> | 33 | #include <kabc/addresseelist.h> |
34 | #include <kdialogbase.h> | 34 | #include <kdialogbase.h> |
35 | 35 | ||
36 | #include <qvaluelist.h> | 36 | #include <q3valuelist.h> |
37 | 37 | ||
38 | class KURLRequester; | 38 | class KURLRequester; |
39 | 39 | ||
40 | class QButtonGroup; | 40 | class Q3ButtonGroup; |
41 | class QComboBox; | 41 | class QComboBox; |
42 | class QCheckBox; | 42 | class QCheckBox; |
43 | class QLineEdit; | 43 | class QLineEdit; |
44 | class QPushButton; | 44 | class QPushButton; |
45 | class QRadioButton; | 45 | class QRadioButton; |
46 | class QTable; | 46 | class Q3Table; |
47 | 47 | ||
48 | class CSVImportDialog : public KDialogBase | 48 | class CSVImportDialog : public KDialogBase |
49 | { | 49 | { |
50 | Q_OBJECT | 50 | Q_OBJECT |
51 | 51 | ||
52 | public: | 52 | public: |
53 | CSVImportDialog( KABC::AddressBook *ab, QWidget *parent, | 53 | CSVImportDialog( KABC::AddressBook *ab, QWidget *parent, |
54 | const char *name = 0 ); | 54 | const char *name = 0 ); |
@@ -80,18 +80,18 @@ class CSVImportDialog : public KDialogBase | |||
80 | HomeAddressPostalCode, HomeAddressCountry, HomeAddressLabel, | 80 | HomeAddressPostalCode, HomeAddressCountry, HomeAddressLabel, |
81 | BusinessAddressStreet, BusinessAddressLocality, BusinessAddressRegion, | 81 | BusinessAddressStreet, BusinessAddressLocality, BusinessAddressRegion, |
82 | BusinessAddressPostalCode, BusinessAddressCountry, | 82 | BusinessAddressPostalCode, BusinessAddressCountry, |
83 | BusinessAddressLabel, | 83 | BusinessAddressLabel, |
84 | HomePhone, BusinessPhone, MobilePhone, HomeFax, BusinessFax, MobileWorkPhone, | 84 | HomePhone, BusinessPhone, MobilePhone, HomeFax, BusinessFax, MobileWorkPhone, |
85 | Isdn, Pager, Email, Mailer, Title, Role, Organization, Note, URL, Categories | 85 | Isdn, Pager, Email, Mailer, Title, Role, Organization, Note, URL, Categories |
86 | }; | 86 | }; |
87 | 87 | ||
88 | QTable* mTable; | 88 | Q3Table* mTable; |
89 | QButtonGroup* mDelimiterBox; | 89 | Q3ButtonGroup* mDelimiterBox; |
90 | QRadioButton* mRadioComma; | 90 | QRadioButton* mRadioComma; |
91 | QRadioButton* mRadioSemicolon; | 91 | QRadioButton* mRadioSemicolon; |
92 | QRadioButton* mRadioTab; | 92 | QRadioButton* mRadioTab; |
93 | QRadioButton* mRadioSpace; | 93 | QRadioButton* mRadioSpace; |
94 | QRadioButton* mRadioOther; | 94 | QRadioButton* mRadioOther; |
95 | QLineEdit* mDelimiterEdit; | 95 | QLineEdit* mDelimiterEdit; |
96 | QComboBox* mComboLine; | 96 | QComboBox* mComboLine; |
97 | QComboBox* mComboQuote; | 97 | QComboBox* mComboQuote; |
@@ -114,13 +114,13 @@ class CSVImportDialog : public KDialogBase | |||
114 | QChar mTextQuote; | 114 | QChar mTextQuote; |
115 | QString mDelimiter; | 115 | QString mDelimiter; |
116 | QString mData; | 116 | QString mData; |
117 | QByteArray mFileArray; | 117 | QByteArray mFileArray; |
118 | QMap<QString, uint> mTypeMap; | 118 | QMap<QString, uint> mTypeMap; |
119 | KABC::AddressBook *mAddressBook; | 119 | KABC::AddressBook *mAddressBook; |
120 | int mCustomCounter; | 120 | int mCustomCounter; |
121 | bool mClearTypeStore; | 121 | bool mClearTypeStore; |
122 | QValueList<int> mTypeStore; | 122 | Q3ValueList<int> mTypeStore; |
123 | 123 | ||
124 | }; | 124 | }; |
125 | 125 | ||
126 | #endif | 126 | #endif |
diff --git a/kaddressbook/xxport/kde2_xxport.cpp b/kaddressbook/xxport/kde2_xxport.cpp index 03efc1b..72d3fc2 100644 --- a/kaddressbook/xxport/kde2_xxport.cpp +++ b/kaddressbook/xxport/kde2_xxport.cpp | |||
@@ -111,11 +111,11 @@ KABC::AddresseeList KDE2XXPort::importContacts( const QString& ) const | |||
111 | 111 | ||
112 | proc.start( KProcess::Block ); | 112 | proc.start( KProcess::Block ); |
113 | 113 | ||
114 | addressBook()->load(); | 114 | addressBook()->load(); |
115 | 115 | ||
116 | return KABC::AddresseeList(); | 116 | return KABC::AddresseeList(); |
117 | } | 117 | } |
118 | 118 | ||
119 | #ifndef KAB_EMBEDDED | 119 | #ifndef KAB_EMBEDDED_ |
120 | #include "kde2_xxport.moc" | 120 | #include "moc_kde2_xxport.cpp" |
121 | #endif //KAB_EMBEDDED | 121 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/xxport/vcard_xxport.cpp b/kaddressbook/xxport/vcard_xxport.cpp index 9a8fa68..64b9071 100644 --- a/kaddressbook/xxport/vcard_xxport.cpp +++ b/kaddressbook/xxport/vcard_xxport.cpp | |||
@@ -24,18 +24,20 @@ | |||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtextstream.h> | 32 | #include <q3textstream.h> |
33 | #include <qfileinfo.h> | 33 | #include <qfileinfo.h> |
34 | //Added by qt3to4: | ||
35 | #include <Q3CString> | ||
34 | 36 | ||
35 | #include <kabc/vcardconverter.h> | 37 | #include <kabc/vcardconverter.h> |
36 | #include <kabc/vcardparser/vcardtool.h> | 38 | #include <kabc/vcardparser/vcardtool.h> |
37 | #include <kfiledialog.h> | 39 | #include <kfiledialog.h> |
38 | #ifndef KAB_EMBEDDED | 40 | #ifndef KAB_EMBEDDED |
39 | #include <kio/netaccess.h> | 41 | #include <kio/netaccess.h> |
40 | #endif //KAB_EMBEDDED | 42 | #endif //KAB_EMBEDDED |
41 | 43 | ||
@@ -97,24 +99,24 @@ bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString | |||
97 | #else //KAB_EMBEDDED | 99 | #else //KAB_EMBEDDED |
98 | QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); | 100 | QString fileName = KFileDialog::getSaveFileName( name, i18n("Save file"), parentWidget() ); |
99 | #endif //KAB_EMBEDDED | 101 | #endif //KAB_EMBEDDED |
100 | 102 | ||
101 | if ( fileName.isEmpty() ) | 103 | if ( fileName.isEmpty() ) |
102 | return false; | 104 | return false; |
103 | 105 | ||
104 | QFile outFile( fileName ); | 106 | QFile outFile( fileName ); |
105 | if ( !outFile.open( IO_WriteOnly ) ) { | 107 | if ( !outFile.open( QIODevice::WriteOnly ) ) { |
106 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 108 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
107 | KMessageBox::error( parentWidget(), text.arg( fileName ) ); | 109 | KMessageBox::error( parentWidget(), text.arg( fileName ) ); |
108 | return false; | 110 | return false; |
109 | } | 111 | } |
110 | 112 | ||
111 | QTextStream t( &outFile ); | 113 | Q3TextStream t( &outFile ); |
112 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 114 | t.setEncoding( Q3TextStream::UnicodeUTF8 ); |
113 | 115 | ||
114 | KABC::Addressee::List::ConstIterator it; | 116 | KABC::Addressee::List::ConstIterator it; |
115 | for ( it = list.begin(); it != list.end(); ++it ) { | 117 | for ( it = list.begin(); it != list.end(); ++it ) { |
116 | KABC::VCardConverter converter; | 118 | KABC::VCardConverter converter; |
117 | QString vcard; | 119 | QString vcard; |
118 | 120 | ||
119 | KABC::VCardConverter::Version version; | 121 | KABC::VCardConverter::Version version; |
120 | if ( data == "v21" ) | 122 | if ( data == "v21" ) |
@@ -148,17 +150,17 @@ KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const | |||
148 | else | 150 | else |
149 | url = XXPortManager::importURL; | 151 | url = XXPortManager::importURL; |
150 | if ( url.isEmpty() ) | 152 | if ( url.isEmpty() ) |
151 | return addrList; | 153 | return addrList; |
152 | QString caption( i18n( "vCard Import Failed" ) ); | 154 | QString caption( i18n( "vCard Import Failed" ) ); |
153 | if ( KIO::NetAccess::download( url, fileName ) ) { | 155 | if ( KIO::NetAccess::download( url, fileName ) ) { |
154 | QFile file( fileName ); | 156 | QFile file( fileName ); |
155 | 157 | ||
156 | file.open( IO_ReadOnly ); | 158 | file.open( QIODevice::ReadOnly ); |
157 | QByteArray rawData = file.readAll(); | 159 | QByteArray rawData = file.readAll(); |
158 | file.close(); | 160 | file.close(); |
159 | 161 | ||
160 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 162 | QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
161 | addrList = parseVCard( data ); | 163 | addrList = parseVCard( data ); |
162 | 164 | ||
163 | if ( !url.isLocalFile() ) | 165 | if ( !url.isLocalFile() ) |
164 | KIO::NetAccess::removeTempFile( fileName ); | 166 | KIO::NetAccess::removeTempFile( fileName ); |
@@ -191,18 +193,18 @@ KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const | |||
191 | { | 193 | { |
192 | //US url = XXPortManager::importURL; | 194 | //US url = XXPortManager::importURL; |
193 | qDebug("VCardXXPort::importContacts Urls at the moment not supported"); | 195 | qDebug("VCardXXPort::importContacts Urls at the moment not supported"); |
194 | if ( url.isEmpty() ) | 196 | if ( url.isEmpty() ) |
195 | return addrList; | 197 | return addrList; |
196 | 198 | ||
197 | } | 199 | } |
198 | QFile file( fileName ); | 200 | QFile file( fileName ); |
199 | if ( file.open( IO_ReadOnly ) ) { | 201 | if ( file.open( QIODevice::ReadOnly ) ) { |
200 | QCString rawData ( file.readAll().data(),file.size()+1); | 202 | Q3CString rawData ( file.readAll().data(),file.size()+1); |
201 | file.close(); | 203 | file.close(); |
202 | int start = 0; | 204 | int start = 0; |
203 | #ifndef DESKTOP_VERSION | 205 | #ifndef DESKTOP_VERSION |
204 | while ( start < rawData.size()-2 ) { | 206 | while ( start < rawData.size()-2 ) { |
205 | if ( rawData.at( start ) == '\r' ) | 207 | if ( rawData.at( start ) == '\r' ) |
206 | if ( rawData.at( start+1 ) == '\n' ) | 208 | if ( rawData.at( start+1 ) == '\n' ) |
207 | if ( rawData.at( start+2 ) == ' ' ) { | 209 | if ( rawData.at( start+2 ) == ' ' ) { |
208 | rawData.remove(start,3); | 210 | rawData.remove(start,3); |
@@ -262,11 +264,11 @@ KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const | |||
262 | if ( addrList.isEmpty() ) { | 264 | if ( addrList.isEmpty() ) { |
263 | QString text = i18n( "The selected file does not\ninclude a valid vCard.\nPlease check the file and try again.\n" ); | 265 | QString text = i18n( "The selected file does not\ninclude a valid vCard.\nPlease check the file and try again.\n" ); |
264 | KMessageBox::sorry( parentWidget(), text ); | 266 | KMessageBox::sorry( parentWidget(), text ); |
265 | } | 267 | } |
266 | return addrList; | 268 | return addrList; |
267 | } | 269 | } |
268 | 270 | ||
269 | 271 | ||
270 | #ifndef KAB_EMBEDDED | 272 | #ifndef KAB_EMBEDDED_ |
271 | #include "vcard_xxport.moc" | 273 | #include "moc_vcard_xxport.cpp" |
272 | #endif //KAB_EMBEDDED | 274 | #endif //KAB_EMBEDDED |