summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Side-by-side diff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/xxport/csvimportdialog.cpp73
-rw-r--r--kaddressbook/xxport/csvimportdialog.h4
2 files changed, 61 insertions, 16 deletions
diff --git a/kaddressbook/xxport/csvimportdialog.cpp b/kaddressbook/xxport/csvimportdialog.cpp
index cc55a24..41e2612 100644
--- a/kaddressbook/xxport/csvimportdialog.cpp
+++ b/kaddressbook/xxport/csvimportdialog.cpp
@@ -124,2 +124,3 @@ CSVImportDialog::CSVImportDialog( KABC::AddressBook *ab, QWidget *parent,
mTypeMap.insert( KABC::Addressee::urlLabel(), URL );
+ mTypeMap.insert( KABC::Addressee::categoryLabel(), Categories );
@@ -141,2 +142,4 @@ CSVImportDialog::CSVImportDialog( KABC::AddressBook *ab, QWidget *parent,
this, SLOT( lineSelected( const QString& ) ) );
+ connect( mComboCodec, SIGNAL( activated( const QString& ) ),
+ this, SLOT( codecChanged( const QString& ) ) );
connect( mComboQuote, SIGNAL( activated( const QString& ) ),
@@ -251,5 +254,11 @@ KABC::AddresseeList CSVImportDialog::contacts() const
case Note:
- a.setNote( value );
+ if ( a.note().isEmpty() )
+ a.setNote( value );
+ else {
+ a.setNote( a.note()+"\n"+value );
+ }
+ break;
+ case Categories:
+ a.insertCategory( value );
break;
-
case HomePhone:
@@ -387,3 +396,3 @@ void CSVImportDialog::initGUI()
- layout->addMultiCellLayout( hbox, 0, 0, 0, 1 );
+ layout->addMultiCellLayout( hbox, 0, 0, 0, 2 );
@@ -396,3 +405,3 @@ void CSVImportDialog::initGUI()
delimiterLayout->setAlignment( Qt::AlignTop );
- layout->addMultiCellWidget( mDelimiterBox, 1, 1, 0, 1 );
+ layout->addMultiCellWidget( mDelimiterBox, 1, 1, 0, 2 );
@@ -426,3 +435,7 @@ void CSVImportDialog::initGUI()
layout->addWidget( mComboQuote, 3, 0 );
-
+ mComboCodec = new QComboBox( false, page );
+ mComboCodec->insertItem( i18n( "UTF8" ), 0 );
+ mComboCodec->insertItem( i18n( "LATIN1" ), 1 );
+ mComboCodec->insertItem( i18n( "LOCALE" ), 2 );
+ layout->addWidget( mComboCodec, 3, 2 );
label = new QLabel( i18n( "Start at line:" ), page );
@@ -432,2 +445,4 @@ void CSVImportDialog::initGUI()
layout->addWidget( label, 2, 0 );
+ label = new QLabel( i18n( "Codec:" ), page );
+ layout->addWidget( label, 2, 2 );
@@ -435,3 +450,3 @@ void CSVImportDialog::initGUI()
mIgnoreDuplicates->setText( i18n( "Ignore duplicate delimiters" ) );
- layout->addMultiCellWidget( mIgnoreDuplicates, 4, 4, 0, 1 );
+ layout->addMultiCellWidget( mIgnoreDuplicates, 4, 4, 0, 2 );
@@ -440,3 +455,3 @@ void CSVImportDialog::initGUI()
//mTable->horizontalHeader()->hide();
- layout->addMultiCellWidget( mTable, 5, 5, 0, 1 );
+ layout->addMultiCellWidget( mTable, 5, 5, 0, 2 );
/*US
@@ -452,3 +467,3 @@ void CSVImportDialog::initGUI()
#ifdef DESKTOP_VERSION
- resize( 500, 300 );
+ resize( 640, 480 );
#else
@@ -485,6 +500,19 @@ void CSVImportDialog::fillTable()
row = column = 1;
- mData = QString( mFileArray );
+ 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 );
- inputStream.setEncoding( QTextStream::Locale );
+
+ if ( mComboCodec->currentItem () == 0 ) {
+ inputStream.setEncoding( QTextStream::UnicodeUTF8 );
+ } else if ( mComboCodec->currentItem () == 1 ) {
+ inputStream.setEncoding( QTextStream::Latin1 );
+ } else {
+ inputStream.setEncoding( QTextStream::Locale );
+ }
@@ -610,5 +638,10 @@ void CSVImportDialog::fillTable()
QStringList keys;
+ uint iii = 0, count = mTypeMap.count();
+ while ( iii < count ) {
+ keys << "dummy";
+ ++iii;
+ }
QMap<QString, uint>::ConstIterator it;
for ( it = mTypeMap.begin(); it != mTypeMap.end(); ++it)
- keys << it.key();
+ keys[( it.data() )] = it.key();
//US end
@@ -684,2 +717,6 @@ void CSVImportDialog::textChanged ( const QString& )
}
+void CSVImportDialog::codecChanged ( const QString& )
+{
+ fillTable();
+}
@@ -756,3 +793,3 @@ void CSVImportDialog::applyTemplate()
{
- qDebug("for ");
+
//US KSimpleConfig config( *it, true );
@@ -767,3 +804,3 @@ void CSVImportDialog::applyTemplate()
}
- qDebug("weiter ");
+
// let the user chose, what to take
@@ -772,3 +809,3 @@ void CSVImportDialog::applyTemplate()
tmp = QInputDialog::getItem( i18n( "Template Selection" ),
- i18n( "Please select a template, that matches the CSV file." ),
+ i18n( "Please select a template\nthat matches the CSV file." ),
templates, 0, false, &ok, this );
@@ -822,3 +859,3 @@ void CSVImportDialog::saveTemplate()
- if ( !fileName.contains( ".desktop" ) )
+ if ( !fileName.contains( ".desktop" ) )
fileName += ".desktop";
@@ -862,2 +899,4 @@ uint CSVImportDialog::posToType( int pos ) const
{
+ return pos;
+#if 0
uint counter = 0;
@@ -869,2 +908,3 @@ uint CSVImportDialog::posToType( int pos ) const
return 0;
+#endif
}
@@ -873,2 +913,4 @@ int CSVImportDialog::typeToPos( uint type ) const
{
+ return type;
+#if 0
uint counter = 0;
@@ -880,2 +922,3 @@ int CSVImportDialog::typeToPos( uint type ) const
return -1;
+#endif
}
diff --git a/kaddressbook/xxport/csvimportdialog.h b/kaddressbook/xxport/csvimportdialog.h
index 545b5f9..5f55ab2 100644
--- a/kaddressbook/xxport/csvimportdialog.h
+++ b/kaddressbook/xxport/csvimportdialog.h
@@ -70,2 +70,3 @@ class CSVImportDialog : public KDialogBase
void urlChanged( const QString& );
+ void codecChanged ( const QString& );
@@ -83,3 +84,3 @@ class CSVImportDialog : public KDialogBase
HomePhone, BusinessPhone, MobilePhone, HomeFax, BusinessFax, CarPhone,
- Isdn, Pager, Email, Mailer, Title, Role, Organization, Note, URL
+ Isdn, Pager, Email, Mailer, Title, Role, Organization, Note, URL, Categories
};
@@ -96,2 +97,3 @@ class CSVImportDialog : public KDialogBase
QComboBox* mComboQuote;
+ QComboBox* mComboCodec;
QCheckBox* mIgnoreDuplicates;