diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:53:50 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:53:50 +0000 |
commit | 7be55ffa061c026e35e2d6a0effe1161ddb0d41f (patch) | |
tree | 8474f9b444b2756228600050f07a7ff25de532b2 /kaddressbook/xxport/csvimportdialog.cpp | |
parent | f587f20a6d09f1729dd0a8c1cd8ee0110aec7451 (diff) | |
download | tdepim-7be55ffa061c026e35e2d6a0effe1161ddb0d41f.tar.gz tdepim-7be55ffa061c026e35e2d6a0effe1161ddb0d41f.zip |
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1157655 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kaddressbook/xxport/csvimportdialog.cpp')
-rw-r--r-- | kaddressbook/xxport/csvimportdialog.cpp | 210 |
1 files changed, 105 insertions, 105 deletions
diff --git a/kaddressbook/xxport/csvimportdialog.cpp b/kaddressbook/xxport/csvimportdialog.cpp index f89222aff..cfcac0fec 100644 --- a/kaddressbook/xxport/csvimportdialog.cpp +++ b/kaddressbook/xxport/csvimportdialog.cpp @@ -20,17 +20,17 @@ */ -#include <qbuttongroup.h> -#include <qcheckbox.h> -#include <qcombobox.h> -#include <qlabel.h> -#include <qlayout.h> -#include <qlineedit.h> -#include <qpushbutton.h> -#include <qradiobutton.h> -#include <qtable.h> -#include <qtextcodec.h> -#include <qtooltip.h> +#include <tqbuttongroup.h> +#include <tqcheckbox.h> +#include <tqcombobox.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqlineedit.h> +#include <tqpushbutton.h> +#include <tqradiobutton.h> +#include <tqtable.h> +#include <tqtextcodec.h> +#include <tqtooltip.h> #include <kapplication.h> #include <kdebug.h> @@ -50,7 +50,7 @@ enum { Local = 0, Guess = 1, Latin1 = 2, Uni = 3, MSBug = 4, Codec = 5 }; -CSVImportDialog::CSVImportDialog( KABC::AddressBook *ab, QWidget *parent, +CSVImportDialog::CSVImportDialog( KABC::AddressBook *ab, TQWidget *parent, const char * name ) : KDialogBase( Plain, i18n ( "CSV Import Dialog" ), Ok | Cancel | User1 | User2, Ok, parent, name, true, true ), @@ -121,33 +121,33 @@ CSVImportDialog::CSVImportDialog( KABC::AddressBook *ab, QWidget *parent, reloadCodecs(); - connect( mDelimiterBox, SIGNAL( clicked( int ) ), - this, SLOT( delimiterClicked( int ) ) ); - connect( mDelimiterEdit, SIGNAL( returnPressed() ), - this, SLOT( returnPressed() ) ); - connect( mDelimiterEdit, SIGNAL( textChanged ( const QString& ) ), - this, SLOT( textChanged ( const QString& ) ) ); - connect( mComboLine, SIGNAL( activated( const QString& ) ), - this, SLOT( lineSelected( const QString& ) ) ); - connect( mComboQuote, SIGNAL( activated( const QString& ) ), - this, SLOT( textquoteSelected( const QString& ) ) ); - connect( mIgnoreDuplicates, SIGNAL( stateChanged( int ) ), - this, SLOT( ignoreDuplicatesChanged( int ) ) ); - connect( mCodecCombo, SIGNAL( activated( const QString& ) ), - this, SLOT( codecChanged() ) ); - - connect( mUrlRequester, SIGNAL( returnPressed( const QString& ) ), - this, SLOT( setFile( const QString& ) ) ); - connect( mUrlRequester, SIGNAL( urlSelected( const QString& ) ), - this, SLOT( setFile( const QString& ) ) ); - connect( mUrlRequester->lineEdit(), SIGNAL( textChanged ( const QString& ) ), - this, SLOT( urlChanged( const QString& ) ) ); - - connect( this, SIGNAL( user1Clicked() ), - this, SLOT( applyTemplate() ) ); - - connect( this, SIGNAL( user2Clicked() ), - this, SLOT( saveTemplate() ) ); + connect( mDelimiterBox, TQT_SIGNAL( clicked( int ) ), + this, TQT_SLOT( delimiterClicked( int ) ) ); + connect( mDelimiterEdit, TQT_SIGNAL( returnPressed() ), + this, TQT_SLOT( returnPressed() ) ); + connect( mDelimiterEdit, TQT_SIGNAL( textChanged ( const TQString& ) ), + this, TQT_SLOT( textChanged ( const TQString& ) ) ); + connect( mComboLine, TQT_SIGNAL( activated( const TQString& ) ), + this, TQT_SLOT( lineSelected( const TQString& ) ) ); + connect( mComboQuote, TQT_SIGNAL( activated( const TQString& ) ), + this, TQT_SLOT( textquoteSelected( const TQString& ) ) ); + connect( mIgnoreDuplicates, TQT_SIGNAL( stateChanged( int ) ), + this, TQT_SLOT( ignoreDuplicatesChanged( int ) ) ); + connect( mCodecCombo, TQT_SIGNAL( activated( const TQString& ) ), + this, TQT_SLOT( codecChanged() ) ); + + connect( mUrlRequester, TQT_SIGNAL( returnPressed( const TQString& ) ), + this, TQT_SLOT( setFile( const TQString& ) ) ); + connect( mUrlRequester, TQT_SIGNAL( urlSelected( const TQString& ) ), + this, TQT_SLOT( setFile( const TQString& ) ) ); + connect( mUrlRequester->lineEdit(), TQT_SIGNAL( textChanged ( const TQString& ) ), + this, TQT_SLOT( urlChanged( const TQString& ) ) ); + + connect( this, TQT_SIGNAL( user1Clicked() ), + this, TQT_SLOT( applyTemplate() ) ); + + connect( this, TQT_SIGNAL( user2Clicked() ), + this, TQT_SLOT( saveTemplate() ) ); } CSVImportDialog::~CSVImportDialog() @@ -174,15 +174,15 @@ KABC::AddresseeList CSVImportDialog::contacts() const 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, + TQComboTableItem *item = static_cast<TQComboTableItem*>( mTable->item( 0, col ) ); if ( !item ) { kdError() << "ERROR: item cast failed" << endl; continue; } - QString value = mTable->text( row, col ); - if ( 1 == row && static_cast<QTableItem *>(item)->text() == value ) + TQString value = mTable->text( row, col ); + if ( 1 == row && static_cast<TQTableItem *>(item)->text() == value ) // we are looking at a header row, stop now break; @@ -367,12 +367,12 @@ void CSVImportDialog::initGUI() { mPage = plainPage(); - QGridLayout *layout = new QGridLayout( mPage, 1, 1, marginHint(), + TQGridLayout *layout = new TQGridLayout( mPage, 1, 1, marginHint(), spacingHint() ); - QHBoxLayout *hbox = new QHBoxLayout(); + TQHBoxLayout *hbox = new TQHBoxLayout(); hbox->setSpacing( spacingHint() ); - QLabel *label = new QLabel( i18n( "File to import:" ), mPage ); + TQLabel *label = new TQLabel( i18n( "File to import:" ), mPage ); hbox->addWidget( label ); mUrlRequester = new KURLRequester( mPage ); @@ -382,46 +382,46 @@ void CSVImportDialog::initGUI() layout->addMultiCellLayout( hbox, 0, 0, 0, 4 ); // Delimiter: comma, semicolon, tab, space, other - mDelimiterBox = new QButtonGroup( i18n( "Delimiter" ), mPage ); + mDelimiterBox = new TQButtonGroup( i18n( "Delimiter" ), mPage ); mDelimiterBox->setColumnLayout( 0, Qt::Vertical ); mDelimiterBox->layout()->setSpacing( spacingHint() ); mDelimiterBox->layout()->setMargin( marginHint() ); - QGridLayout *delimiterLayout = new QGridLayout( mDelimiterBox->layout() ); + TQGridLayout *delimiterLayout = new TQGridLayout( mDelimiterBox->layout() ); delimiterLayout->setAlignment( Qt::AlignTop ); layout->addMultiCellWidget( mDelimiterBox, 1, 4, 0, 0 ); - mRadioComma = new QRadioButton( i18n( "Comma" ), mDelimiterBox ); + mRadioComma = new TQRadioButton( i18n( "Comma" ), mDelimiterBox ); mRadioComma->setChecked( true ); delimiterLayout->addWidget( mRadioComma, 0, 0 ); - mRadioSemicolon = new QRadioButton( i18n( "Semicolon" ), mDelimiterBox ); + mRadioSemicolon = new TQRadioButton( i18n( "Semicolon" ), mDelimiterBox ); delimiterLayout->addWidget( mRadioSemicolon, 0, 1 ); - mRadioTab = new QRadioButton( i18n( "Tabulator" ), mDelimiterBox ); + mRadioTab = new TQRadioButton( i18n( "Tabulator" ), mDelimiterBox ); delimiterLayout->addWidget( mRadioTab, 1, 0 ); - mRadioSpace = new QRadioButton( i18n( "Space" ), mDelimiterBox ); + mRadioSpace = new TQRadioButton( i18n( "Space" ), mDelimiterBox ); delimiterLayout->addWidget( mRadioSpace, 1, 1 ); - mRadioOther = new QRadioButton( i18n( "Other" ), mDelimiterBox ); + mRadioOther = new TQRadioButton( i18n( "Other" ), mDelimiterBox ); delimiterLayout->addWidget( mRadioOther, 0, 2 ); - mDelimiterEdit = new QLineEdit( mDelimiterBox ); + mDelimiterEdit = new TQLineEdit( mDelimiterBox ); delimiterLayout->addWidget( mDelimiterEdit, 1, 2 ); - mComboLine = new QComboBox( false, mPage ); + mComboLine = new TQComboBox( false, mPage ); mComboLine->insertItem( i18n( "1" ) ); layout->addWidget( mComboLine, 2, 3 ); - mComboQuote = new QComboBox( false, mPage ); + mComboQuote = new TQComboBox( false, mPage ); mComboQuote->insertItem( i18n( "\"" ), 0 ); mComboQuote->insertItem( i18n( "'" ), 1 ); mComboQuote->insertItem( i18n( "None" ), 2 ); layout->addWidget( mComboQuote, 2, 2 ); - mDatePatternEdit = new QLineEdit( mPage ); + mDatePatternEdit = new TQLineEdit( mPage ); mDatePatternEdit->setText( "Y-M-D" ); // ISO 8601 format as default - QToolTip::add( mDatePatternEdit, i18n( "<ul><li>y: year with 2 digits</li>" + TQToolTip::add( mDatePatternEdit, i18n( "<ul><li>y: year with 2 digits</li>" "<li>Y: year with 4 digits</li>" "<li>m: month with 1 or 2 digits</li>" "<li>M: month with 2 digits</li>" @@ -429,24 +429,24 @@ void CSVImportDialog::initGUI() "<li>D: day with 2 digits</li></ul>" ) ); layout->addWidget( mDatePatternEdit, 2, 4 ); - label = new QLabel( i18n( "Start at line:" ), mPage ); + label = new TQLabel( i18n( "Start at line:" ), mPage ); layout->addWidget( label, 1, 3 ); - label = new QLabel( i18n( "Textquote:" ), mPage ); + label = new TQLabel( i18n( "Textquote:" ), mPage ); layout->addWidget( label, 1, 2 ); - label = new QLabel( i18n( "Date format:" ), mPage ); + label = new TQLabel( i18n( "Date format:" ), mPage ); layout->addWidget( label, 1, 4 ); - mIgnoreDuplicates = new QCheckBox( mPage ); + mIgnoreDuplicates = new TQCheckBox( mPage ); mIgnoreDuplicates->setText( i18n( "Ignore duplicate delimiters" ) ); layout->addMultiCellWidget( mIgnoreDuplicates, 3, 3, 2, 4 ); - mCodecCombo = new QComboBox( mPage ); + mCodecCombo = new TQComboBox( mPage ); layout->addMultiCellWidget( mCodecCombo, 4, 4, 2, 4 ); - mTable = new QTable( 0, 0, mPage ); - mTable->setSelectionMode( QTable::NoSelection ); + mTable = new TQTable( 0, 0, mPage ); + mTable->setSelectionMode( TQTable::NoSelection ); mTable->horizontalHeader()->hide(); layout->addMultiCellWidget( mTable, 5, 5, 0, 4 ); @@ -468,13 +468,13 @@ void CSVImportDialog::fillTable() enum { S_START, S_QUOTED_FIELD, S_MAYBE_END_OF_QUOTED_FIELD, S_END_OF_QUOTED_FIELD, S_MAYBE_NORMAL_FIELD, S_NORMAL_FIELD } state = S_START; - QChar x; - QString field; + TQChar x; + TQString field; // store previous assignment mTypeStore.clear(); for ( column = 0; column < mTable->numCols(); ++column ) { - QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, + TQComboTableItem *item = static_cast<TQComboTableItem*>( mTable->item( 0, column ) ); if ( !item || mClearTypeStore ) mTypeStore.append( typeToPos( Undefined ) ); @@ -486,22 +486,22 @@ void CSVImportDialog::fillTable() row = column = 1; - QTextStream inputStream( mFileArray, IO_ReadOnly ); + TQTextStream inputStream( mFileArray, IO_ReadOnly ); // find the current codec int code = mCodecCombo->currentItem(); if ( code == Local ) - inputStream.setEncoding( QTextStream::Locale ); + inputStream.setEncoding( TQTextStream::Locale ); else if ( code >= Codec ) inputStream.setCodec( mCodecs.at( code - Codec ) ); else if ( code == Uni ) - inputStream.setEncoding( QTextStream::Unicode ); + inputStream.setEncoding( TQTextStream::Unicode ); else if ( code == MSBug ) - inputStream.setEncoding( QTextStream::UnicodeReverse ); + inputStream.setEncoding( TQTextStream::UnicodeReverse ); else if ( code == Latin1 ) - inputStream.setEncoding( QTextStream::Latin1 ); + inputStream.setEncoding( TQTextStream::Latin1 ); else if ( code == Guess ) { - QTextCodec* codec = QTextCodec::codecForContent( mFileArray.data(), mFileArray.size() ); + TQTextCodec* codec = TQTextCodec::codecForContent( mFileArray.data(), mFileArray.size() ); if ( codec ) { KMessageBox::information( this, i18n( "Using codec '%1'" ).arg( codec->name() ), i18n( "Encoding" ) ); inputStream.setCodec( codec ); @@ -627,7 +627,7 @@ void CSVImportDialog::fillTable() mTable->setNumCols( maxColumn ); for ( column = 0; column < mTable->numCols(); ++column ) { - QComboTableItem *item = new QComboTableItem( mTable, mTypeMap.keys() ); + TQComboTableItem *item = new TQComboTableItem( mTable, mTypeMap.keys() ); mTable->setItem( 0, column, item ); if ( column < (int)mTypeStore.count() ) item->setCurrentItem( mTypeStore[ column ] ); @@ -650,7 +650,7 @@ void CSVImportDialog::fillComboBox() { mComboLine->clear(); for ( int row = 1; row < mTable->numRows() + 1; ++row ) - mComboLine->insertItem( QString::number( row ), row - 1 ); + mComboLine->insertItem( TQString::number( row ), row - 1 ); } void CSVImportDialog::reloadCodecs() @@ -659,11 +659,11 @@ void CSVImportDialog::reloadCodecs() mCodecs.clear(); - QTextCodec *codec; - for ( int i = 0; ( codec = QTextCodec::codecForIndex( i ) ); i++ ) + TQTextCodec *codec; + for ( int i = 0; ( codec = TQTextCodec::codecForIndex( i ) ); i++ ) mCodecs.append( codec ); - mCodecCombo->insertItem( i18n( "Local (%1)" ).arg( QTextCodec::codecForLocale()->name() ), Local ); + mCodecCombo->insertItem( i18n( "Local (%1)" ).arg( TQTextCodec::codecForLocale()->name() ), Local ); mCodecCombo->insertItem( i18n( "[guess]" ), Guess ); mCodecCombo->insertItem( i18n( "Latin1" ), Latin1 ); mCodecCombo->insertItem( i18n( "Unicode" ), Uni ); @@ -673,7 +673,7 @@ void CSVImportDialog::reloadCodecs() mCodecCombo->insertItem( mCodecs.at( i )->name(), Codec + i ); } -void CSVImportDialog::setText( int row, int col, const QString& text ) +void CSVImportDialog::setText( int row, int col, const TQString& text ) { if ( row < 1 ) // skipped by the user return; @@ -702,10 +702,10 @@ void CSVImportDialog::adjustRows( int rows ) void CSVImportDialog::resizeColumns() { - QFontMetrics fm = fontMetrics(); + TQFontMetrics fm = fontMetrics(); int width = 0; - QMap<QString, uint>::ConstIterator it; + TQMap<TQString, uint>::ConstIterator it; for ( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) { width = QMAX( width, fm.width( it.key() ) ); } @@ -723,7 +723,7 @@ void CSVImportDialog::returnPressed() fillTable(); } -void CSVImportDialog::textChanged ( const QString& ) +void CSVImportDialog::textChanged ( const TQString& ) { mRadioOther->setChecked ( true ); delimiterClicked( 4 ); // other @@ -752,7 +752,7 @@ void CSVImportDialog::delimiterClicked( int id ) fillTable(); } -void CSVImportDialog::textquoteSelected( const QString& mark ) +void CSVImportDialog::textquoteSelected( const TQString& mark ) { if ( mComboQuote->currentItem() == 2 ) mTextQuote = 0; @@ -762,7 +762,7 @@ void CSVImportDialog::textquoteSelected( const QString& mark ) fillTable(); } -void CSVImportDialog::lineSelected( const QString& line ) +void CSVImportDialog::lineSelected( const TQString& line ) { mStartLine = line.toInt() - 1; fillTable(); @@ -773,7 +773,7 @@ void CSVImportDialog::slotOk() bool assigned = false; for ( int column = 0; column < mTable->numCols(); ++column ) { - QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, + TQComboTableItem *item = static_cast<TQComboTableItem*>( mTable->item( 0, column ) ); if ( item && posToType( item->currentItem() ) != Undefined ) assigned = true; @@ -787,15 +787,15 @@ void CSVImportDialog::slotOk() void CSVImportDialog::applyTemplate() { - QMap<uint,int> columnMap; - QMap<QString, QString> fileMap; - QStringList templates; + TQMap<uint,int> columnMap; + TQMap<TQString, TQString> fileMap; + TQStringList templates; // load all template files - QStringList list = KGlobal::dirs()->findAllResources( "data" , QString( kapp->name() ) + + TQStringList list = KGlobal::dirs()->findAllResources( "data" , TQString( kapp->name() ) + "/csv-templates/*.desktop", true, true ); - for ( QStringList::iterator it = list.begin(); it != list.end(); ++it ) + for ( TQStringList::iterator it = list.begin(); it != list.end(); ++it ) { KSimpleConfig config( *it, true ); @@ -809,7 +809,7 @@ void CSVImportDialog::applyTemplate() // let the user chose, what to take bool ok = false; - QString tmp; + TQString tmp; tmp = KInputDialog::getItem( i18n( "Template Selection" ), i18n( "Please select a template, that matches the CSV file:" ), templates, 0, false, &ok, this ); @@ -831,14 +831,14 @@ void CSVImportDialog::applyTemplate() // create the column map config.setGroup( "csv column map" ); for ( uint i = 0; i < numColumns; ++i ) { - int col = config.readNumEntry( QString::number( i ) ); + int col = config.readNumEntry( TQString::number( i ) ); 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, + TQComboTableItem *item = static_cast<TQComboTableItem*>( mTable->item( 0, column ) ); if ( item ) item->setCurrentItem( typeToPos( type ) ); @@ -847,8 +847,8 @@ void CSVImportDialog::applyTemplate() void CSVImportDialog::saveTemplate() { - QString fileName = KFileDialog::getSaveFileName( - locateLocal( "data", QString( kapp->name() ) + "/csv-templates/" ), + TQString fileName = KFileDialog::getSaveFileName( + locateLocal( "data", TQString( kapp->name() ) + "/csv-templates/" ), "*.desktop", this ); if ( fileName.isEmpty() ) @@ -857,7 +857,7 @@ void CSVImportDialog::saveTemplate() if ( !fileName.contains( ".desktop" ) ) fileName += ".desktop"; - QString name = KInputDialog::getText( i18n( "Template Name" ), i18n( "Please enter a name for the template:" ) ); + TQString name = KInputDialog::getText( i18n( "Template Name" ), i18n( "Please enter a name for the template:" ) ); if ( name.isEmpty() ) return; @@ -876,19 +876,19 @@ void CSVImportDialog::saveTemplate() config.setGroup( "csv column map" ); for ( int column = 0; column < mTable->numCols(); ++column ) { - QComboTableItem *item = static_cast<QComboTableItem*>( mTable->item( 0, + TQComboTableItem *item = static_cast<TQComboTableItem*>( mTable->item( 0, column ) ); if ( item ) - config.writeEntry( QString::number( column ), posToType( + config.writeEntry( TQString::number( column ), posToType( item->currentItem() ) ); else - config.writeEntry( QString::number( column ), 0 ); + config.writeEntry( TQString::number( column ), 0 ); } config.sync(); } -QString CSVImportDialog::getText( int row, int col ) +TQString CSVImportDialog::getText( int row, int col ) { return mTable->text( row, col ); } @@ -896,7 +896,7 @@ QString CSVImportDialog::getText( int row, int col ) uint CSVImportDialog::posToType( int pos ) const { uint counter = 0; - QMap<QString, uint>::ConstIterator it; + TQMap<TQString, uint>::ConstIterator it; for ( it = mTypeMap.begin(); it != mTypeMap.end(); ++it, ++counter ) if ( counter == (uint)pos ) return it.data(); @@ -907,7 +907,7 @@ uint CSVImportDialog::posToType( int pos ) const int CSVImportDialog::typeToPos( uint type ) const { uint counter = 0; - QMap<QString, uint>::ConstIterator it; + TQMap<TQString, uint>::ConstIterator it; for ( it = mTypeMap.begin(); it != mTypeMap.end(); ++it, ++counter ) if ( it.data() == type ) return counter; @@ -920,12 +920,12 @@ void CSVImportDialog::ignoreDuplicatesChanged( int ) fillTable(); } -void CSVImportDialog::setFile( const QString &fileName ) +void CSVImportDialog::setFile( const TQString &fileName ) { if ( fileName.isEmpty() ) return; - QFile file( fileName ); + TQFile file( fileName ); if ( !file.open( IO_ReadOnly ) ) { KMessageBox::sorry( this, i18n( "Cannot open input file." ) ); file.close(); @@ -945,7 +945,7 @@ void CSVImportDialog::setFile( const QString &fileName ) fillComboBox(); } -void CSVImportDialog::urlChanged( const QString &file ) +void CSVImportDialog::urlChanged( const TQString &file ) { bool state = !file.isEmpty(); |