summaryrefslogtreecommitdiffabout
path: root/kaddressbook/xxport
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (side-by-side diff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kaddressbook/xxport
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'kaddressbook/xxport') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/xxport/csv_xxport.cpp14
-rw-r--r--kaddressbook/xxport/csvimportdialog.cpp66
-rw-r--r--kaddressbook/xxport/csvimportdialog.h12
-rw-r--r--kaddressbook/xxport/kde2_xxport.cpp4
-rw-r--r--kaddressbook/xxport/vcard_xxport.cpp20
5 files changed, 60 insertions, 56 deletions
diff --git a/kaddressbook/xxport/csv_xxport.cpp b/kaddressbook/xxport/csv_xxport.cpp
index 7281003..ed5807f 100644
--- a/kaddressbook/xxport/csv_xxport.cpp
+++ b/kaddressbook/xxport/csv_xxport.cpp
@@ -27,13 +27,13 @@ Copyright (c) 2004 Ulf Schenk
$Id$
*/
#include <qfile.h>
#include <qregexp.h>
-#include <qtextstream.h>
+#include <q3textstream.h>
#include <qtextcodec.h>
#include <kfiledialog.h>
#ifndef KAB_EMBEDDED
#include <kio/netaccess.h>
#endif //KAB_EMBEDDED
@@ -101,13 +101,13 @@ bool CSVXXPort::exportContacts( const KABC::AddresseeList &list, const QString&
doExport( tmpFile.file(), list );
tmpFile.close();
return KIO::NetAccess::upload( tmpFile.name(), url, parentWidget() );
} else {
QFile file( url.path() );
- if ( !file.open( IO_WriteOnly ) ) {
+ if ( !file.open( QIODevice::WriteOnly ) ) {
QString txt = i18n( "<qt>Unable to open file <b>%1</b>.</qt>" );
KMessageBox::error( parentWidget(), txt.arg( url.path() ) );
return false;
}
doExport( &file, list );
@@ -121,13 +121,13 @@ bool CSVXXPort::exportContacts( const KABC::AddresseeList &list, const QString&
QString fileName = KFileDialog::getSaveFileName( "addressbook.csv", i18n("Save file"), parentWidget() );
if ( fileName.isEmpty() )
return false;
QFile file( fileName );
- if ( !file.open( IO_WriteOnly ) ) {
+ if ( !file.open( QIODevice::WriteOnly ) ) {
QString txt = i18n( "<qt>Unable to open file <b>%1</b>.</qt>" );
KMessageBox::error( parentWidget(), txt.arg( fileName ) );
return false;
}
doExport( &file, list );
@@ -148,13 +148,13 @@ KABC::AddresseeList CSVXXPort::importContacts( const QString& ) const
else
return KABC::AddresseeList();
}
void CSVXXPort::doExport( QFile *fp, const KABC::AddresseeList &list )
{
- QTextStream t( fp );
+ Q3TextStream t( fp );
t.setCodec( QTextCodec::codecForName("utf8") );
KABC::AddresseeList::ConstIterator iter;
KABC::Field::List fields = addressBook()->fields();
KABC::Field::List::Iterator fieldIter;
bool first = true;
@@ -184,11 +184,9 @@ void CSVXXPort::doExport( QFile *fp, const KABC::AddresseeList &list )
}
t << "\n";
}
}
-#ifndef KAB_EMBEDDED
-#include "csv_xxport.moc"
+#ifndef KAB_EMBEDDED_
+#include "moc_csv_xxport.cpp"
#endif //KAB_EMBEDDED
-
-
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
diff --git a/kaddressbook/xxport/csvimportdialog.h b/kaddressbook/xxport/csvimportdialog.h
index 2661420..520f3fa 100644
--- a/kaddressbook/xxport/csvimportdialog.h
+++ b/kaddressbook/xxport/csvimportdialog.h
@@ -30,23 +30,23 @@ $Id$
#define CSV_IMPORT_DLG_H
#include <kabc/addressbook.h>
#include <kabc/addresseelist.h>
#include <kdialogbase.h>
-#include <qvaluelist.h>
+#include <q3valuelist.h>
class KURLRequester;
-class QButtonGroup;
+class Q3ButtonGroup;
class QComboBox;
class QCheckBox;
class QLineEdit;
class QPushButton;
class QRadioButton;
-class QTable;
+class Q3Table;
class CSVImportDialog : public KDialogBase
{
Q_OBJECT
public:
@@ -82,14 +82,14 @@ class CSVImportDialog : public KDialogBase
BusinessAddressPostalCode, BusinessAddressCountry,
BusinessAddressLabel,
HomePhone, BusinessPhone, MobilePhone, HomeFax, BusinessFax, MobileWorkPhone,
Isdn, Pager, Email, Mailer, Title, Role, Organization, Note, URL, Categories
};
- QTable* mTable;
- QButtonGroup* mDelimiterBox;
+ Q3Table* mTable;
+ Q3ButtonGroup* mDelimiterBox;
QRadioButton* mRadioComma;
QRadioButton* mRadioSemicolon;
QRadioButton* mRadioTab;
QRadioButton* mRadioSpace;
QRadioButton* mRadioOther;
QLineEdit* mDelimiterEdit;
@@ -116,11 +116,11 @@ class CSVImportDialog : public KDialogBase
QString mData;
QByteArray mFileArray;
QMap<QString, uint> mTypeMap;
KABC::AddressBook *mAddressBook;
int mCustomCounter;
bool mClearTypeStore;
- QValueList<int> mTypeStore;
+ Q3ValueList<int> mTypeStore;
};
#endif
diff --git a/kaddressbook/xxport/kde2_xxport.cpp b/kaddressbook/xxport/kde2_xxport.cpp
index 03efc1b..72d3fc2 100644
--- a/kaddressbook/xxport/kde2_xxport.cpp
+++ b/kaddressbook/xxport/kde2_xxport.cpp
@@ -113,9 +113,9 @@ KABC::AddresseeList KDE2XXPort::importContacts( const QString& ) const
addressBook()->load();
return KABC::AddresseeList();
}
-#ifndef KAB_EMBEDDED
-#include "kde2_xxport.moc"
+#ifndef KAB_EMBEDDED_
+#include "moc_kde2_xxport.cpp"
#endif //KAB_EMBEDDED
diff --git a/kaddressbook/xxport/vcard_xxport.cpp b/kaddressbook/xxport/vcard_xxport.cpp
index 9a8fa68..64b9071 100644
--- a/kaddressbook/xxport/vcard_xxport.cpp
+++ b/kaddressbook/xxport/vcard_xxport.cpp
@@ -26,14 +26,16 @@
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#include <qfile.h>
-#include <qtextstream.h>
+#include <q3textstream.h>
#include <qfileinfo.h>
+//Added by qt3to4:
+#include <Q3CString>
#include <kabc/vcardconverter.h>
#include <kabc/vcardparser/vcardtool.h>
#include <kfiledialog.h>
#ifndef KAB_EMBEDDED
#include <kio/netaccess.h>
@@ -99,20 +101,20 @@ bool VCardXXPort::exportContacts( const KABC::AddresseeList &list, const QString
#endif //KAB_EMBEDDED
if ( fileName.isEmpty() )
return false;
QFile outFile( fileName );
- if ( !outFile.open( IO_WriteOnly ) ) {
+ if ( !outFile.open( QIODevice::WriteOnly ) ) {
QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
KMessageBox::error( parentWidget(), text.arg( fileName ) );
return false;
}
- QTextStream t( &outFile );
- t.setEncoding( QTextStream::UnicodeUTF8 );
+ Q3TextStream t( &outFile );
+ t.setEncoding( Q3TextStream::UnicodeUTF8 );
KABC::Addressee::List::ConstIterator it;
for ( it = list.begin(); it != list.end(); ++it ) {
KABC::VCardConverter converter;
QString vcard;
@@ -150,13 +152,13 @@ KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const
if ( url.isEmpty() )
return addrList;
QString caption( i18n( "vCard Import Failed" ) );
if ( KIO::NetAccess::download( url, fileName ) ) {
QFile file( fileName );
- file.open( IO_ReadOnly );
+ file.open( QIODevice::ReadOnly );
QByteArray rawData = file.readAll();
file.close();
QString data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
addrList = parseVCard( data );
@@ -193,14 +195,14 @@ KABC::AddresseeList VCardXXPort::importContacts( const QString& ) const
qDebug("VCardXXPort::importContacts Urls at the moment not supported");
if ( url.isEmpty() )
return addrList;
}
QFile file( fileName );
- if ( file.open( IO_ReadOnly ) ) {
- QCString rawData ( file.readAll().data(),file.size()+1);
+ if ( file.open( QIODevice::ReadOnly ) ) {
+ Q3CString rawData ( file.readAll().data(),file.size()+1);
file.close();
int start = 0;
#ifndef DESKTOP_VERSION
while ( start < rawData.size()-2 ) {
if ( rawData.at( start ) == '\r' )
if ( rawData.at( start+1 ) == '\n' )
@@ -264,9 +266,9 @@ KABC::AddresseeList VCardXXPort::parseVCard( const QString &data ) const
KMessageBox::sorry( parentWidget(), text );
}
return addrList;
}
-#ifndef KAB_EMBEDDED
-#include "vcard_xxport.moc"
+#ifndef KAB_EMBEDDED_
+#include "moc_vcard_xxport.cpp"
#endif //KAB_EMBEDDED