-rw-r--r-- | kaddressbook/xxport/csvimportdialog.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kaddressbook/xxport/csvimportdialog.cpp b/kaddressbook/xxport/csvimportdialog.cpp index 41e2612..4044fa8 100644 --- a/kaddressbook/xxport/csvimportdialog.cpp +++ b/kaddressbook/xxport/csvimportdialog.cpp @@ -297,129 +297,129 @@ KABC::AddresseeList CSVImportDialog::contacts() const if ( !value.isEmpty() ) { KABC::PhoneNumber number( value, KABC::PhoneNumber::Car ); a.insertPhoneNumber( number ); } break; case Isdn: if ( !value.isEmpty() ) { KABC::PhoneNumber number( value, KABC::PhoneNumber::Isdn ); a.insertPhoneNumber( number ); } break; case Pager: if ( !value.isEmpty() ) { KABC::PhoneNumber number( value, KABC::PhoneNumber::Pager ); a.insertPhoneNumber( number ); } break; case HomeAddressStreet: addrHome.setStreet( value ); break; case HomeAddressLocality: addrHome.setLocality( value ); break; case HomeAddressRegion: addrHome.setRegion( value ); break; case HomeAddressPostalCode: addrHome.setPostalCode( value ); break; case HomeAddressCountry: addrHome.setCountry( value ); break; case HomeAddressLabel: addrHome.setLabel( value ); break; case BusinessAddressStreet: addrWork.setStreet( value ); break; case BusinessAddressLocality: addrWork.setLocality( value ); break; case BusinessAddressRegion: addrWork.setRegion( value ); break; case BusinessAddressPostalCode: addrWork.setPostalCode( value ); break; case BusinessAddressCountry: addrWork.setCountry( value ); break; case BusinessAddressLabel: addrWork.setLabel( value ); break; default: KABC::Field::List fields = mAddressBook->fields( KABC::Field::CustomCategory ); KABC::Field::List::Iterator it; int counter = 0; for ( it = fields.begin(); it != fields.end(); ++it ) { if ( counter == (int)( posToType( item->currentItem() ) - mCustomCounter ) ) { (*it)->setValue( a, value ); - continue; + break; } ++counter; } break; } } if ( !addrHome.isEmpty() ) a.insertAddress( addrHome ); if ( !addrWork.isEmpty() ) a.insertAddress( addrWork ); if ( !emptyRow && !a.isEmpty() ) contacts.append( a ); } return contacts; } void CSVImportDialog::initGUI() { QWidget* page = plainPage(); QGridLayout *layout = new QGridLayout( page, 1, 1, marginHintSmall(), spacingHintSmall() ); QHBoxLayout *hbox = new QHBoxLayout(); hbox->setSpacing( spacingHint() ); QLabel *label = new QLabel( i18n( "File to import:" ), page ); hbox->addWidget( label ); mUrlRequester = new KURLRequester( page ); mUrlRequester->setFilter( "*.csv" ); hbox->addWidget( mUrlRequester ); layout->addMultiCellLayout( hbox, 0, 0, 0, 2 ); // Delimiter: comma, semicolon, tab, space, other mDelimiterBox = new QButtonGroup( i18n( "Delimiter" ), page ); mDelimiterBox->setColumnLayout( 0, Qt::Vertical ); mDelimiterBox->layout()->setSpacing( spacingHint() ); mDelimiterBox->layout()->setMargin( marginHint() ); QGridLayout *delimiterLayout = new QGridLayout( mDelimiterBox->layout() ); delimiterLayout->setAlignment( Qt::AlignTop ); layout->addMultiCellWidget( mDelimiterBox, 1, 1, 0, 2 ); mRadioComma = new QRadioButton( i18n( "Comma" ), mDelimiterBox ); mRadioComma->setChecked( true ); delimiterLayout->addWidget( mRadioComma, 0, 0 ); mRadioSemicolon = new QRadioButton( i18n( "Semicolon" ), mDelimiterBox ); delimiterLayout->addWidget( mRadioSemicolon, 0, 1 ); mRadioTab = new QRadioButton( i18n( "Tabulator" ), mDelimiterBox ); delimiterLayout->addWidget( mRadioTab, 1, 0 ); mRadioSpace = new QRadioButton( i18n( "Space" ), mDelimiterBox ); delimiterLayout->addWidget( mRadioSpace, 1, 1 ); mRadioOther = new QRadioButton( i18n( "Other" ), mDelimiterBox ); delimiterLayout->addWidget( mRadioOther, 0, 2 ); mDelimiterEdit = new QLineEdit( mDelimiterBox ); delimiterLayout->addWidget( mDelimiterEdit, 1, 2 ); @@ -480,129 +480,129 @@ void CSVImportDialog::fillTable() S_MAYBE_NORMAL_FIELD, S_NORMAL_FIELD } state = S_START; QChar x; QString field = ""; // store previous assignment QValueList<int> mTypeOld = mTypeStore; mTypeStore.clear(); for ( column = 0; column < mTable->numCols(); ++column ) { QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, column ) ); if ( !item || mClearTypeStore ) mTypeStore.append( typeToPos( Undefined ) ); else if ( item ) mTypeStore.append( item->currentItem() ); } clearTable(); row = column = 1; if ( mComboCodec->currentItem () == 0 ) { mData = QString::fromUtf8( mFileArray.data() ); } else if ( mComboCodec->currentItem () == 1 ) { mData = QString::fromLatin1( mFileArray.data() ); } else { mData = QString::fromLocal8Bit( mFileArray.data() ); } QTextStream inputStream( mData, IO_ReadOnly ); if ( mComboCodec->currentItem () == 0 ) { inputStream.setEncoding( QTextStream::UnicodeUTF8 ); } else if ( mComboCodec->currentItem () == 1 ) { inputStream.setEncoding( QTextStream::Latin1 ); } else { inputStream.setEncoding( QTextStream::Locale ); } int maxColumn = 0; while ( !inputStream.atEnd() ) { inputStream >> x; // read one char if ( x == '\r' ) inputStream >> x; // eat '\r', to handle DOS/LOSEDOWS files correctly switch ( state ) { case S_START : if ( x == mTextQuote ) { state = S_QUOTED_FIELD; } else if ( x == mDelimiter ) { if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) ) ++column; lastCharDelimiter = true; } else if ( x == '\n' ) { ++row; column = 1; } else { field += x; state = S_MAYBE_NORMAL_FIELD; } break; case S_QUOTED_FIELD : if ( x == mTextQuote ) { state = S_MAYBE_END_OF_QUOTED_FIELD; - } else if ( x == '\n' ) { + } else if ( x == '\n' && mTextQuote.isNull() ) { setText( row - mStartLine + 1, column, field ); field = ""; if ( x == '\n' ) { ++row; column = 1; } else { if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) ) ++column; lastCharDelimiter = true; } state = S_START; } else { field += x; } break; case S_MAYBE_END_OF_QUOTED_FIELD : if ( x == mTextQuote ) { field += x; state = S_QUOTED_FIELD; } else if ( x == mDelimiter || x == '\n' ) { setText( row - mStartLine + 1, column, field ); field = ""; if ( x == '\n' ) { ++row; column = 1; } else { if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) ) ++column; lastCharDelimiter = true; } state = S_START; } else { state = S_END_OF_QUOTED_FIELD; } break; case S_END_OF_QUOTED_FIELD : if ( x == mDelimiter || x == '\n' ) { setText( row - mStartLine + 1, column, field ); field = ""; if ( x == '\n' ) { ++row; column = 1; } else { if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) ) ++column; lastCharDelimiter = true; } state = S_START; } else { state = S_END_OF_QUOTED_FIELD; } break; case S_MAYBE_NORMAL_FIELD : if ( x == mTextQuote ) { field = ""; state = S_QUOTED_FIELD; break; } case S_NORMAL_FIELD : if ( x == mDelimiter || x == '\n' ) { setText( row - mStartLine + 1, column, field ); field = ""; if ( x == '\n' ) { ++row; |