summaryrefslogtreecommitdiffabout
path: root/kaddressbook/xxport/csvimportdialog.cpp
Side-by-side diff
Diffstat (limited to 'kaddressbook/xxport/csvimportdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/xxport/csvimportdialog.cpp66
1 files changed, 35 insertions, 31 deletions
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
@@ -24,28 +24,32 @@ Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
-#include <qbuttongroup.h>
+#include <q3buttongroup.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#ifdef DESKTOP_VERSION
#include <qinputdialog.h>
#else
#include <qtcompat/qinputdialog.h>
#endif
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
-#include <qtable.h>
+#include <q3table.h>
#include <qlayout.h>
-#include <qtextstream.h>
+#include <q3textstream.h>
#include <qfile.h>
+//Added by qt3to4:
+#include <Q3HBoxLayout>
+#include <Q3ValueList>
+#include <Q3GridLayout>
#include <kapplication.h>
#include <kdebug.h>
#include <kdialogbase.h>
#include <kfiledialog.h>
#include <klineedit.h>
@@ -53,13 +57,13 @@ $Id$
#include <kglobal.h>
#include <kmessagebox.h>
#include <kstandarddirs.h>
#include <kurlrequester.h>
#ifdef DESKTOP_VERSION
-#include "qtable.h"
+#include "q3table.h"
#else
#include "qcombotableitem.h"
#endif
#include "csvimportdialog.h"
CSVImportDialog::CSVImportDialog( KABC::AddressBook *ab, QWidget *parent,
@@ -158,13 +162,13 @@ CSVImportDialog::CSVImportDialog( KABC::AddressBook *ab, QWidget *parent,
this, SLOT( applyTemplate() ) );
connect( this, SIGNAL( user2Clicked() ),
this, SLOT( saveTemplate() ) );
// if ( QApplication::desktop()->width() < 321 )
- QIconSet icon = SmallIcon("filesave");
+ QIcon icon = SmallIcon("filesave");
findButton( User2 )->setIconSet (icon ) ;
icon = SmallIcon("fileopen");
findButton( User1 )->setIconSet (icon ) ;
int wid = findButton( User2 )->sizeHint().height();
findButton( User2 )->setMaximumWidth( wid+4 );
@@ -183,13 +187,13 @@ KABC::AddresseeList CSVImportDialog::contacts() const
KABC::Addressee a;
bool emptyRow = true;
KABC::Address addrHome( KABC::Address::Home );
KABC::Address addrWork( KABC::Address::Work );
for ( int col = 0; col < mTable->numCols(); ++col ) {
- QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, col ) );
+ Q3ComboTableItem *item = static_cast<Q3ComboTableItem*>( mTable->item( 0, col ) );
if ( !item ) {
qDebug( "ERROR: item cast failed" );
continue;
}
@@ -226,13 +230,13 @@ KABC::AddresseeList CSVImportDialog::contacts() const
case Birthday:
//US
//the generated code had the following format: a.setBirthday( QDate::fromString( value, Qt::ISODate ) );
// But Qt::IsoDate and QDate::fromString was not specified. Do I have the wrong QT version ?
{
QDate dt = KGlobal::locale()->readDate( value, "%Y-%m-%d"); // = Qt::ISODate
- a.setBirthday(dt);
+ a.setBirthday(QDateTime(dt));
}
break;
case Email:
if ( !value.isEmpty() )
a.insertEmail( value, true );
break;
@@ -379,32 +383,32 @@ KABC::AddresseeList CSVImportDialog::contacts() const
}
void CSVImportDialog::initGUI()
{
QWidget* page = plainPage();
- QGridLayout *layout = new QGridLayout( page, 1, 1, marginHintSmall(),
+ Q3GridLayout *layout = new Q3GridLayout( page, 1, 1, marginHintSmall(),
spacingHintSmall() );
- QHBoxLayout *hbox = new QHBoxLayout();
+ Q3HBoxLayout *hbox = new Q3HBoxLayout();
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 = new Q3ButtonGroup( i18n( "Delimiter" ), page );
mDelimiterBox->setColumnLayout( 0, Qt::Vertical );
mDelimiterBox->layout()->setSpacing( spacingHint() );
mDelimiterBox->layout()->setMargin( marginHint() );
- QGridLayout *delimiterLayout = new QGridLayout( mDelimiterBox->layout() );
+ Q3GridLayout *delimiterLayout = new Q3GridLayout( 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 );
@@ -447,14 +451,14 @@ void CSVImportDialog::initGUI()
layout->addWidget( label, 2, 2 );
mIgnoreDuplicates = new QCheckBox( page );
mIgnoreDuplicates->setText( i18n( "Ignore duplicate delimiters" ) );
layout->addMultiCellWidget( mIgnoreDuplicates, 4, 4, 0, 2 );
- mTable = new QTable( 0, 0, page );
- mTable->setSelectionMode( QTable::NoSelection );
+ mTable = new Q3Table( 0, 0, page );
+ mTable->setSelectionMode( Q3Table::NoSelection );
//mTable->horizontalHeader()->hide();
layout->addMultiCellWidget( mTable, 5, 5, 0, 2 );
/*US
setButtonText( User1, i18n( "Apply Template" ) );
setButtonText( User2, i18n( "Save Template" ) );
*/
@@ -480,17 +484,17 @@ void CSVImportDialog::fillTable()
S_MAYBE_NORMAL_FIELD, S_NORMAL_FIELD } state = S_START;
QChar x;
QString field = "";
// store previous assignment
- QValueList<int> mTypeOld = mTypeStore;
+ Q3ValueList<int> mTypeOld = mTypeStore;
mTypeStore.clear();
for ( column = 0; column < mTable->numCols(); ++column ) {
- QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, column ) );
+ Q3ComboTableItem *item = static_cast<Q3ComboTableItem*>( mTable->item( 0, column ) );
if ( !item || mClearTypeStore )
mTypeStore.append( typeToPos( Undefined ) );
else if ( item )
mTypeStore.append( item->currentItem() );
}
@@ -503,33 +507,33 @@ void CSVImportDialog::fillTable()
} else if ( mComboCodec->currentItem () == 1 ) {
mData = QString::fromLatin1( mFileArray.data() );
} else {
mData = QString::fromLocal8Bit( mFileArray.data() );
}
- QTextStream inputStream( mData, IO_ReadOnly );
+ Q3TextStream inputStream( mData, QIODevice::ReadOnly );
if ( mComboCodec->currentItem () == 0 ) {
- inputStream.setEncoding( QTextStream::UnicodeUTF8 );
+ inputStream.setEncoding( Q3TextStream::UnicodeUTF8 );
} else if ( mComboCodec->currentItem () == 1 ) {
- inputStream.setEncoding( QTextStream::Latin1 );
+ inputStream.setEncoding( Q3TextStream::Latin1 );
} else {
- inputStream.setEncoding( QTextStream::Locale );
+ inputStream.setEncoding( Q3TextStream::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 ) {
+ } else if ( QString(x) == mDelimiter ) {
if ( ( ignoreDups == false ) || ( lastCharDelimiter == false ) )
++column;
lastCharDelimiter = true;
} else if ( x == '\n' ) {
++row;
column = 1;
@@ -558,13 +562,13 @@ void CSVImportDialog::fillTable()
}
break;
case S_MAYBE_END_OF_QUOTED_FIELD :
if ( x == mTextQuote ) {
field += x;
state = S_QUOTED_FIELD;
- } else if ( x == mDelimiter || x == '\n' ) {
+ } else if ( QString(x) == mDelimiter || x == '\n' ) {
setText( row - mStartLine + 1, column, field );
field = "";
if ( x == '\n' ) {
++row;
column = 1;
} else {
@@ -575,13 +579,13 @@ void CSVImportDialog::fillTable()
state = S_START;
} else {
state = S_END_OF_QUOTED_FIELD;
}
break;
case S_END_OF_QUOTED_FIELD :
- if ( x == mDelimiter || x == '\n' ) {
+ if ( QString(x) == mDelimiter || x == '\n' ) {
setText( row - mStartLine + 1, column, field );
field = "";
if ( x == '\n' ) {
++row;
column = 1;
} else {
@@ -598,13 +602,13 @@ void CSVImportDialog::fillTable()
if ( x == mTextQuote ) {
field = "";
state = S_QUOTED_FIELD;
break;
}
case S_NORMAL_FIELD :
- if ( x == mDelimiter || x == '\n' ) {
+ if ( QString(x) == mDelimiter || x == '\n' ) {
setText( row - mStartLine + 1, column, field );
field = "";
if ( x == '\n' ) {
++row;
column = 1;
} else {
@@ -614,13 +618,13 @@ void CSVImportDialog::fillTable()
}
state = S_START;
} else {
field += x;
}
}
- if ( x != mDelimiter )
+ if ( QString(x) != mDelimiter )
lastCharDelimiter = false;
if ( column > maxColumn )
maxColumn = column;
}
@@ -646,13 +650,13 @@ void CSVImportDialog::fillTable()
keys[( it.data() )] = it.key();
//US end
for ( column = 0; column < mTable->numCols(); ++column ) {
//US QComboTableItem *item = new QComboTableItem( mTable, mTypeMap.keys() );
- QComboTableItem *item = new QComboTableItem( mTable, keys );
+ Q3ComboTableItem *item = new Q3ComboTableItem( mTable, keys );
mTable->setItem( 0, column, item );
if ( column < mTypeStore.count() )
item->setCurrentItem( mTypeStore[ column ] );
else
item->setCurrentItem( typeToPos( Undefined ) );
@@ -761,13 +765,13 @@ void CSVImportDialog::lineSelected( const QString& line )
void CSVImportDialog::slotOk()
{
bool assigned = false;
for ( int column = 0; column < mTable->numCols(); ++column ) {
- QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0,
+ Q3ComboTableItem *item = static_cast<Q3ComboTableItem*>( mTable->item( 0,
column ) );
if ( item && posToType( item->currentItem() ) != Undefined )
assigned = true;
}
if ( assigned )
@@ -833,13 +837,13 @@ void CSVImportDialog::applyTemplate()
columnMap.insert( i, col );
}
// apply the column map
for ( uint column = 0; column < columnMap.count(); ++column ) {
int type = columnMap[ column ];
- QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0,
+ Q3ComboTableItem *item = static_cast<Q3ComboTableItem*>( mTable->item( 0,
column ) );
if ( item )
item->setCurrentItem( typeToPos( type ) );
}
}
@@ -875,13 +879,13 @@ void CSVImportDialog::saveTemplate()
config.setGroup( "Misc" );
config.writeEntry( "Name", name );
config.setGroup( "csv column map" );
for ( uint column = 0; column < mTable->numCols(); ++column ) {
- QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0,
+ Q3ComboTableItem *item = static_cast<Q3ComboTableItem*>( mTable->item( 0,
column ) );
if ( item )
config.writeEntry( QString::number( column ), posToType(
item->currentItem() ) );
else
config.writeEntry( QString::number( column ), 0 );
@@ -931,13 +935,13 @@ void CSVImportDialog::ignoreDuplicatesChanged( int )
void CSVImportDialog::setFile( const QString &fileName )
{
if ( fileName.isEmpty() )
return;
QFile file( fileName );
- if ( !file.open( IO_ReadOnly ) ) {
+ if ( !file.open( QIODevice::ReadOnly ) ) {
KMessageBox::sorry( this, i18n( "Cannot open input file!" ) );
file.close();
return;
}
mFileArray = file.readAll();
@@ -961,9 +965,9 @@ void CSVImportDialog::urlChanged( const QString &file )
findButton( User1 )->setEnabled( state );
findButton( User2 )->setEnabled( state );
}
-#ifndef KAB_EMBEDDED
-#include <csvimportdialog.moc>
+#ifndef KAB_EMBEDDED_
+#include <moc_csvimportdialog.cpp>
#endif //KAB_EMBEDDED