From a08aff328d4393031d5ba7d622c2b05705a89d73 Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Wed, 04 Jul 2007 11:23:42 +0000 Subject: initial public commit of qt4 port --- (limited to 'kaddressbook/xxport/csvimportdialog.cpp') 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 @@ -27,7 +27,7 @@ $Id$ */ -#include +#include #include #include #ifdef DESKTOP_VERSION @@ -39,10 +39,14 @@ $Id$ #include #include #include -#include +#include #include -#include +#include #include +//Added by qt3to4: +#include +#include +#include #include #include @@ -56,7 +60,7 @@ $Id$ #include #ifdef DESKTOP_VERSION -#include "qtable.h" +#include "q3table.h" #else #include "qcombotableitem.h" #endif @@ -161,7 +165,7 @@ CSVImportDialog::CSVImportDialog( KABC::AddressBook *ab, QWidget *parent, this, SLOT( saveTemplate() ) ); // if ( QApplication::desktop()->width() < 321 ) - QIconSet icon = SmallIcon("filesave"); + QIcon icon = SmallIcon("filesave"); findButton( User2 )->setIconSet (icon ) ; icon = SmallIcon("fileopen"); @@ -186,7 +190,7 @@ KABC::AddresseeList CSVImportDialog::contacts() const KABC::Address addrWork( KABC::Address::Work ); for ( int col = 0; col < mTable->numCols(); ++col ) { - QComboTableItem *item = static_cast( mTable->item( 0, col ) ); + Q3ComboTableItem *item = static_cast( mTable->item( 0, col ) ); if ( !item ) { qDebug( "ERROR: item cast failed" ); @@ -229,7 +233,7 @@ KABC::AddresseeList CSVImportDialog::contacts() const // 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: @@ -382,9 +386,9 @@ 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 ); @@ -397,11 +401,11 @@ void CSVImportDialog::initGUI() 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 ); @@ -450,8 +454,8 @@ void CSVImportDialog::initGUI() 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 @@ -483,11 +487,11 @@ void CSVImportDialog::fillTable() QString field = ""; // store previous assignment - QValueList mTypeOld = mTypeStore; + Q3ValueList mTypeOld = mTypeStore; mTypeStore.clear(); for ( column = 0; column < mTable->numCols(); ++column ) { - QComboTableItem *item = static_cast( mTable->item( 0, column ) ); + Q3ComboTableItem *item = static_cast( mTable->item( 0, column ) ); if ( !item || mClearTypeStore ) mTypeStore.append( typeToPos( Undefined ) ); @@ -506,14 +510,14 @@ void CSVImportDialog::fillTable() 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; @@ -526,7 +530,7 @@ void CSVImportDialog::fillTable() 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; @@ -561,7 +565,7 @@ void CSVImportDialog::fillTable() 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' ) { @@ -578,7 +582,7 @@ void CSVImportDialog::fillTable() } 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' ) { @@ -601,7 +605,7 @@ void CSVImportDialog::fillTable() 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' ) { @@ -617,7 +621,7 @@ void CSVImportDialog::fillTable() field += x; } } - if ( x != mDelimiter ) + if ( QString(x) != mDelimiter ) lastCharDelimiter = false; if ( column > maxColumn ) @@ -649,7 +653,7 @@ void CSVImportDialog::fillTable() 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 ] ); @@ -764,7 +768,7 @@ void CSVImportDialog::slotOk() bool assigned = false; for ( int column = 0; column < mTable->numCols(); ++column ) { - QComboTableItem *item = static_cast( mTable->item( 0, + Q3ComboTableItem *item = static_cast( mTable->item( 0, column ) ); if ( item && posToType( item->currentItem() ) != Undefined ) assigned = true; @@ -836,7 +840,7 @@ void CSVImportDialog::applyTemplate() // apply the column map for ( uint column = 0; column < columnMap.count(); ++column ) { int type = columnMap[ column ]; - QComboTableItem *item = static_cast( mTable->item( 0, + Q3ComboTableItem *item = static_cast( mTable->item( 0, column ) ); if ( item ) item->setCurrentItem( typeToPos( type ) ); @@ -878,7 +882,7 @@ void CSVImportDialog::saveTemplate() config.setGroup( "csv column map" ); for ( uint column = 0; column < mTable->numCols(); ++column ) { - QComboTableItem *item = static_cast( mTable->item( 0, + Q3ComboTableItem *item = static_cast( mTable->item( 0, column ) ); if ( item ) config.writeEntry( QString::number( column ), posToType( @@ -934,7 +938,7 @@ void CSVImportDialog::setFile( const QString &fileName ) 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; @@ -964,6 +968,6 @@ void CSVImportDialog::urlChanged( const QString &file ) } -#ifndef KAB_EMBEDDED -#include +#ifndef KAB_EMBEDDED_ +#include #endif //KAB_EMBEDDED -- cgit v0.9.0.2