summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/xxport/csvimportdialog.cpp4
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
@@ -313,97 +313,97 @@ KABC::AddresseeList CSVImportDialog::contacts() const
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 );
@@ -496,97 +496,97 @@ void CSVImportDialog::fillTable()
}
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;