diff options
Diffstat (limited to 'kexi/plugins/importexport/csv/kexicsvimportdialog.cpp')
-rw-r--r-- | kexi/plugins/importexport/csv/kexicsvimportdialog.cpp | 508 |
1 files changed, 255 insertions, 253 deletions
diff --git a/kexi/plugins/importexport/csv/kexicsvimportdialog.cpp b/kexi/plugins/importexport/csv/kexicsvimportdialog.cpp index 16a9d416b..b7bcb80e8 100644 --- a/kexi/plugins/importexport/csv/kexicsvimportdialog.cpp +++ b/kexi/plugins/importexport/csv/kexicsvimportdialog.cpp @@ -25,22 +25,22 @@ * Boston, MA 02110-1301, USA. */ -#include <qbuttongroup.h> -#include <qcheckbox.h> -#include <qclipboard.h> -#include <qlabel.h> -#include <qlineedit.h> -#include <qmime.h> -#include <qpushbutton.h> -#include <qradiobutton.h> -#include <qtable.h> -#include <qlayout.h> -#include <qfiledialog.h> -#include <qpainter.h> -#include <qtextcodec.h> -#include <qtimer.h> -#include <qfontmetrics.h> -#include <qtooltip.h> +#include <tqbuttongroup.h> +#include <tqcheckbox.h> +#include <tqclipboard.h> +#include <tqlabel.h> +#include <tqlineedit.h> +#include <tqmime.h> +#include <tqpushbutton.h> +#include <tqradiobutton.h> +#include <tqtable.h> +#include <tqlayout.h> +#include <tqfiledialog.h> +#include <tqpainter.h> +#include <tqtextcodec.h> +#include <tqtimer.h> +#include <tqfontmetrics.h> +#include <tqtooltip.h> #include <kapplication.h> #include <kdebug.h> @@ -71,7 +71,7 @@ #include "kexicsvimportdialog.h" #include "kexicsvwidgets.h" -#ifdef Q_WS_WIN +#ifdef TQ_WS_WIN #include <krecentdirs.h> #include <windows.h> #endif @@ -99,43 +99,45 @@ #define MAX_BYTES_TO_PREVIEW 10240 //max 10KB is reasonable #define MAX_CHARS_TO_SCAN_WHILE_DETECTING_DELIMITER 4096 -class KexiCSVImportDialogTable : public QTable +class KexiCSVImportDialogTable : public TQTable { public: - KexiCSVImportDialogTable( QWidget * parent = 0, const char * name = 0 ) - : QTable(parent, name) { + KexiCSVImportDialogTable( TQWidget * tqparent = 0, const char * name = 0 ) + : TQTable(tqparent, name) { f = font(); f.setBold(true); } - virtual void paintCell( QPainter * p, int row, int col, const QRect & cr, bool selected, const QColorGroup & cg ) { + virtual void paintCell( TQPainter * p, int row, int col, const TQRect & cr, bool selected, const TQColorGroup & cg ) { if (row==0) p->setFont(f); else p->setFont(font()); - QTable::paintCell(p, row, col, cr, selected, cg); + TQTable::paintCell(p, row, col, cr, selected, cg); } virtual void setColumnWidth( int col, int w ) { //make columns a bit wider - QTable::setColumnWidth( col, w + 16 ); + TQTable::setColumnWidth( col, w + 16 ); } - QFont f; + TQFont f; }; //! Helper used to temporary disable keyboard and mouse events -void installRecursiveEventFilter(QObject *filter, QObject *object) +void installRecursiveEventFilter(TQObject *filter, TQObject *object) { object->installEventFilter(filter); - if (!object->children()) + TQObjectList clo = object->childrenListObject(); + + if (clo.isEmpty()) return; - QObjectList list = *object->children(); - for(QObject *obj = list.first(); obj; obj = list.next()) + TQObjectList list = clo; + for(TQObject *obj = list.first(); obj; obj = list.next()) installRecursiveEventFilter(filter, obj); } KexiCSVImportDialog::KexiCSVImportDialog( Mode mode, KexiMainWindow* mainWin, - QWidget * parent, const char * name + TQWidget * tqparent, const char * name ) : KDialogBase( KDialogBase::Plain, @@ -144,7 +146,7 @@ KexiCSVImportDialog::KexiCSVImportDialog( Mode mode, KexiMainWindow* mainWin, , (mode==File ? User1 : (ButtonCode)0) |Ok|Cancel, Ok, - parent, + tqparent, name ? name : "KexiCSVImportDialog", true, false, @@ -154,7 +156,7 @@ KexiCSVImportDialog::KexiCSVImportDialog( Mode mode, KexiMainWindow* mainWin, m_cancelled( false ), m_adjustRows( true ), m_startline( 0 ), - m_textquote( QString(KEXICSV_DEFAULT_FILE_TEXT_QUOTE)[0] ), + m_textquote( TQString(KEXICSV_DEFAULT_FILE_TEXT_TQUOTE)[0] ), m_mode(mode), m_prevSelectedCol(-1), m_columnsAdjusted(false), @@ -168,7 +170,7 @@ KexiCSVImportDialog::KexiCSVImportDialog( Mode mode, KexiMainWindow* mainWin, m_allRowsLoadedInPreview(false), m_stoppedAt_MAX_BYTES_TO_PREVIEW(false) { - setWFlags(getWFlags() | Qt::WStyle_Maximize | Qt::WStyle_SysMenu); + setWFlags(getWFlags() | TQt::WStyle_Maximize | TQt::WStyle_SysMenu); hide(); setButtonOK(KGuiItem( i18n("&Import..."), _IMPORT_ICON)); @@ -190,12 +192,12 @@ KexiCSVImportDialog::KexiCSVImportDialog( Mode mode, KexiMainWindow* mainWin, setIcon(DesktopIcon(_IMPORT_ICON)); setSizeGripEnabled( TRUE ); -// m_encoding = QString::fromLatin1(KGlobal::locale()->encoding()); +// m_encoding = TQString::tqfromLatin1(KGlobal::locale()->encoding()); // m_stripWhiteSpaceInTextValuesChecked = true; m_file = 0; m_inputStream = 0; - QVBoxLayout *lyr = new QVBoxLayout(plainPage(), 0, KDialogBase::spacingHint(), "lyr"); + TQVBoxLayout *lyr = new TQVBoxLayout(plainPage(), 0, KDialogBase::spacingHint(), "lyr"); m_infoLbl = new KexiCSVInfoLabel( m_mode==File ? i18n("Preview of data from file:") @@ -204,8 +206,8 @@ KexiCSVImportDialog::KexiCSVImportDialog( Mode mode, KexiMainWindow* mainWin, ); lyr->addWidget( m_infoLbl ); - QWidget* page = new QFrame( plainPage(), "page" ); - QGridLayout *glyr= new QGridLayout( page, 4, 5, 0, KDialogBase::spacingHint(), "glyr"); + TQWidget* page = new TQFrame( plainPage(), "page" ); + TQGridLayout *glyr= new TQGridLayout( page, 4, 5, 0, KDialogBase::spacingHint(), "glyr"); lyr->addWidget( page ); // Delimiter: comma, semicolon, tab, space, other @@ -213,8 +215,8 @@ KexiCSVImportDialog::KexiCSVImportDialog( Mode mode, KexiMainWindow* mainWin, m_detectDelimiter = true; glyr->addMultiCellWidget( m_delimiterWidget, 1, 2, 0, 0 ); - QLabel *delimiterLabel = new QLabel(m_delimiterWidget, i18n("Delimiter:"), page); - delimiterLabel->setAlignment(Qt::AlignAuto | Qt::AlignBottom); + TQLabel *delimiterLabel = new TQLabel(m_delimiterWidget, i18n("Delimiter:"), page); + delimiterLabel->tqsetAlignment(TQt::AlignAuto | TQt::AlignBottom); glyr->addMultiCellWidget( delimiterLabel, 0, 0, 0, 0 ); // Format: number, text, currency, @@ -227,49 +229,49 @@ KexiCSVImportDialog::KexiCSVImportDialog( Mode mode, KexiMainWindow* mainWin, m_formatCombo->insertItem(i18n("Date/Time")); glyr->addMultiCellWidget( m_formatCombo, 1, 1, 1, 1 ); - m_formatLabel = new QLabel(m_formatCombo, "", page); - m_formatLabel->setAlignment(Qt::AlignAuto | Qt::AlignBottom); + m_formatLabel = new TQLabel(m_formatCombo, "", page); + m_formatLabel->tqsetAlignment(TQt::AlignAuto | TQt::AlignBottom); glyr->addWidget( m_formatLabel, 0, 1 ); - m_primaryKeyField = new QCheckBox( i18n( "Primary key" ), page, "m_primaryKeyField" ); + m_primaryKeyField = new TQCheckBox( i18n( "Primary key" ), page, "m_primaryKeyField" ); glyr->addWidget( m_primaryKeyField, 2, 1 ); - connect(m_primaryKeyField, SIGNAL(toggled(bool)), this, SLOT(slotPrimaryKeyFieldToggled(bool))); + connect(m_primaryKeyField, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotPrimaryKeyFieldToggled(bool))); m_comboQuote = new KexiCSVTextQuoteComboBox( page ); glyr->addWidget( m_comboQuote, 1, 2 ); - TextLabel2 = new QLabel( m_comboQuote, i18n( "Text quote:" ), page, "TextLabel2" ); - TextLabel2->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ); - TextLabel2->setAlignment(Qt::AlignAuto | Qt::AlignBottom); + TextLabel2 = new TQLabel( m_comboQuote, i18n( "Text quote:" ), page, "TextLabel2" ); + TextLabel2->tqsetSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Preferred ); + TextLabel2->tqsetAlignment(TQt::AlignAuto | TQt::AlignBottom); glyr->addWidget( TextLabel2, 0, 2 ); m_startAtLineSpinBox = new KIntSpinBox( page, "m_startAtLineSpinBox" ); m_startAtLineSpinBox->setMinValue(1); - m_startAtLineSpinBox->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); - m_startAtLineSpinBox->setMinimumWidth(QFontMetrics(m_startAtLineSpinBox->font()).width("8888888")); + m_startAtLineSpinBox->tqsetSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed ); + m_startAtLineSpinBox->setMinimumWidth(TQFontMetrics(m_startAtLineSpinBox->font()).width("8888888")); glyr->addWidget( m_startAtLineSpinBox, 1, 3 ); - m_startAtLineLabel = new QLabel( m_startAtLineSpinBox, "", + m_startAtLineLabel = new TQLabel( m_startAtLineSpinBox, "", page, "TextLabel3" ); - m_startAtLineLabel->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ); - m_startAtLineLabel->setAlignment(Qt::AlignAuto | Qt::AlignBottom); + m_startAtLineLabel->tqsetSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Preferred ); + m_startAtLineLabel->tqsetAlignment(TQt::AlignAuto | TQt::AlignBottom); glyr->addWidget( m_startAtLineLabel, 0, 3 ); - QSpacerItem* spacer_2 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Preferred ); + TQSpacerItem* spacer_2 = new TQSpacerItem( 0, 0, TQSizePolicy::Minimum, TQSizePolicy::Preferred ); glyr->addItem( spacer_2, 0, 4 ); - m_ignoreDuplicates = new QCheckBox( page, "m_ignoreDuplicates" ); + m_ignoreDuplicates = new TQCheckBox( page, "m_ignoreDuplicates" ); m_ignoreDuplicates->setText( i18n( "Ignore duplicated delimiters" ) ); glyr->addMultiCellWidget( m_ignoreDuplicates, 2, 2, 2, 4 ); - m_1stRowForFieldNames = new QCheckBox( page, "m_1stRowForFieldNames" ); + m_1stRowForFieldNames = new TQCheckBox( page, "m_1stRowForFieldNames" ); m_1stRowForFieldNames->setText( i18n( "First row contains column names" ) ); glyr->addMultiCellWidget( m_1stRowForFieldNames, 3, 3, 2, 4 ); m_table = new KexiCSVImportDialogTable( plainPage(), "m_table" ); lyr->addWidget( m_table ); - m_table->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding, 1, 1) ); + m_table->tqsetSizePolicy( TQSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::MinimumExpanding, 1, 1) ); m_table->setNumRows( 0 ); m_table->setNumCols( 0 ); @@ -278,7 +280,7 @@ KexiCSVImportDialog::KexiCSVImportDialog( Mode mode, KexiMainWindow* mainWin, if ( m_mode == Clipboard ) { setCaption( i18n( "Inserting From Clipboard" ) ); - QMimeSource * mime = QApplication::clipboard()->data(); + TQMimeSource * mime = TQApplication::tqclipboard()->data(); if ( !mime ) { KMessageBox::information( this, i18n("There is no data in the clipboard.") ); @@ -292,22 +294,22 @@ if ( m_mode == Clipboard ) m_cancelled = true; return; } - m_fileArray = QByteArray(mime->encodedData( "text/plain" ) ); + m_fileArray = TQByteArray(mime->tqencodedData( "text/plain" ) ); } else if ( mode == File ) {*/ - m_dateRegExp = QRegExp("(\\d{1,4})([/\\-\\.])(\\d{1,2})([/\\-\\.])(\\d{1,4})"); - m_timeRegExp1 = QRegExp("(\\d{1,2}):(\\d{1,2}):(\\d{1,2})"); - m_timeRegExp2 = QRegExp("(\\d{1,2}):(\\d{1,2})"); - m_fpNumberRegExp = QRegExp("[\\-]{0,1}\\d*[,\\.]\\d+"); - QString caption( i18n("Open CSV Data File") ); + m_dateRegExp = TQRegExp("(\\d{1,4})([/\\-\\.])(\\d{1,2})([/\\-\\.])(\\d{1,4})"); + m_timeRegExp1 = TQRegExp("(\\d{1,2}):(\\d{1,2}):(\\d{1,2})"); + m_timeRegExp2 = TQRegExp("(\\d{1,2}):(\\d{1,2})"); + m_fpNumberRegExp = TQRegExp("[\\-]{0,1}\\d*[,\\.]\\d+"); + TQString caption( i18n("Open CSV Data File") ); if (m_mode == File) { - QStringList mimetypes( csvMimeTypes() ); -#ifdef Q_WS_WIN + TQStringList mimetypes( csvMimeTypes() ); +#ifdef TQ_WS_WIN //! @todo remove - QString recentDir = KGlobalSettings::documentPath(); - m_fname = QFileDialog::getOpenFileName( + TQString recentDir = KGlobalSettings::documentPath(); + m_fname = TQFileDialog::getOpenFileName( KFileDialog::getStartURL(":CSVImportExport", recentDir).path(), KexiUtils::fileDialogFilterStrings(mimetypes, false), page, "KexiCSVImportDialog", caption); @@ -327,18 +329,18 @@ if ( m_mode == Clipboard ) { actionButton( Ok )->setEnabled( false ); m_cancelled = true; - if (parentWidget()) - parentWidget()->raise(); + if (tqparentWidget()) + tqparentWidget()->raise(); return; } } else if (m_mode == Clipboard) { - QCString subtype("plain"); - m_clipboardData = QApplication::clipboard()->text(subtype, QClipboard::Clipboard); + TQCString subtype("plain"); + m_clipboardData = TQApplication::tqclipboard()->text(subtype, TQClipboard::Clipboard); /* debug - for (int i=0;QApplication::clipboard()->data(QClipboard::Clipboard)->format(i);i++) + for (int i=0;TQApplication::tqclipboard()->data(TQClipboard::Clipboard)->format(i);i++) kdDebug() << i << ": " - << QApplication::clipboard()->data(QClipboard::Clipboard)->format(i) << endl; + << TQApplication::tqclipboard()->data(TQClipboard::Clipboard)->format(i) << endl; */ } else { @@ -350,7 +352,7 @@ if ( m_mode == Clipboard ) if (m_mode == File) { m_loadingProgressDlg = new KProgressDialog( this, "m_loadingProgressDlg", i18n("Loading CSV Data"), i18n("Loading CSV Data from \"%1\"...") - .arg(QDir::convertSeparators(m_fname)), true); + .tqarg(TQDir::convertSeparators(m_fname)), true); m_loadingProgressDlg->progressBar()->setTotalSteps( m_maximumRowsForPreview+1 ); m_loadingProgressDlg->show(); } @@ -360,28 +362,28 @@ if ( m_mode == Clipboard ) } //updateRowCountInfo(); - m_table->setSelectionMode(QTable::NoSelection); - - connect(m_formatCombo, SIGNAL(activated(int)), - this, SLOT(formatChanged(int))); - connect(m_delimiterWidget, SIGNAL(delimiterChanged(const QString&)), - this, SLOT(delimiterChanged(const QString&))); - connect(m_startAtLineSpinBox, SIGNAL(valueChanged ( int )), - this, SLOT(startlineSelected(int))); - connect(m_comboQuote, SIGNAL(activated(int)), - this, SLOT(textquoteSelected(int))); - connect(m_table, SIGNAL(currentChanged(int, int)), - this, SLOT(currentCellChanged(int, int))); - connect(m_table, SIGNAL(valueChanged(int,int)), - this, SLOT(cellValueChanged(int,int))); - connect(m_ignoreDuplicates, SIGNAL(stateChanged(int)), - this, SLOT(ignoreDuplicatesChanged(int))); - connect(m_1stRowForFieldNames, SIGNAL(stateChanged(int)), - this, SLOT(slot1stRowForFieldNamesChanged(int))); - - connect(this, SIGNAL(user1Clicked()), this, SLOT(optionsButtonClicked())); - - installRecursiveEventFilter(this, this); + m_table->setSelectionMode(TQTable::NoSelection); + + connect(m_formatCombo, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(formatChanged(int))); + connect(m_delimiterWidget, TQT_SIGNAL(delimiterChanged(const TQString&)), + this, TQT_SLOT(delimiterChanged(const TQString&))); + connect(m_startAtLineSpinBox, TQT_SIGNAL(valueChanged ( int )), + this, TQT_SLOT(startlineSelected(int))); + connect(m_comboQuote, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(textquoteSelected(int))); + connect(m_table, TQT_SIGNAL(currentChanged(int, int)), + this, TQT_SLOT(currentCellChanged(int, int))); + connect(m_table, TQT_SIGNAL(valueChanged(int,int)), + this, TQT_SLOT(cellValueChanged(int,int))); + connect(m_ignoreDuplicates, TQT_SIGNAL(stateChanged(int)), + this, TQT_SLOT(ignoreDuplicatesChanged(int))); + connect(m_1stRowForFieldNames, TQT_SIGNAL(stateChanged(int)), + this, TQT_SLOT(slot1stRowForFieldNamesChanged(int))); + + connect(this, TQT_SIGNAL(user1Clicked()), this, TQT_SLOT(optionsButtonClicked())); + + installRecursiveEventFilter(TQT_TQOBJECT(this), TQT_TQOBJECT(this)); initLater(); } @@ -404,7 +406,7 @@ void KexiCSVImportDialog::initLater() if (m_dialogCancelled) { // m_loadingProgressDlg->hide(); // m_loadingProgressDlg->close(); - QTimer::singleShot(0, this, SLOT(reject())); + TQTimer::singleShot(0, this, TQT_SLOT(reject())); return; } @@ -431,18 +433,18 @@ bool KexiCSVImportDialog::openData() m_file->close(); delete m_file; } - m_file = new QFile(m_fname); + m_file = new TQFile(m_fname); if (!m_file->open(IO_ReadOnly)) { m_file->close(); delete m_file; m_file = 0; KMessageBox::sorry( this, i18n("Cannot open input file <nobr>\"%1\"</nobr>.") - .arg(QDir::convertSeparators(m_fname)) ); + .tqarg(TQDir::convertSeparators(m_fname)) ); actionButton( Ok )->setEnabled( false ); m_cancelled = true; - if (parentWidget()) - parentWidget()->raise(); + if (tqparentWidget()) + tqparentWidget()->raise(); return false; } return true; @@ -456,9 +458,9 @@ bool KexiCSVImportDialog::cancelled() const void KexiCSVImportDialog::fillTable() { KexiUtils::WaitCursor wc(true); - repaint(); + tqrepaint(); m_blockUserEvents = true; - QPushButton *pb = actionButton(KDialogBase::Cancel); + TQPushButton *pb = actionButton(KDialogBase::Cancel); if (pb) pb->setEnabled(true); //allow to cancel KexiUtils::WaitCursor wait; @@ -467,7 +469,7 @@ void KexiCSVImportDialog::fillTable() m_table->setCurrentCell(0,0); int row, column, maxColumn; - QString field = QString::null; + TQString field = TQString(); for (row = 0; row < m_table->numRows(); ++row) for (column = 0; column < m_table->numCols(); ++column) @@ -489,17 +491,17 @@ void KexiCSVImportDialog::fillTable() { setText(row - m_startline, column, field, true); ++row; - field = QString::null; + field = TQString(); } adjustRows( row - m_startline - (m_1stRowForFieldNames->isChecked()?1:0) ); - maxColumn = QMAX( maxColumn, column ); + maxColumn = TQMAX( maxColumn, column ); m_table->setNumCols(maxColumn); for (column = 0; column < m_table->numCols(); ++column) { -// QString header = m_table->horizontalHeader()->label(column); +// TQString header = m_table->horizontalHeader()->label(column); // if (header != i18n("Text") && header != i18n("Number") && // header != i18n("Date") && header != i18n("Currency")) // const int detectedType = m_detectedTypes[column+1]; @@ -522,44 +524,44 @@ void KexiCSVImportDialog::fillTable() if (m_primaryKeyColumn != -1) m_table->setPixmap(0, m_primaryKeyColumn, m_pkIcon); - const int count = QMAX(0, m_table->numRows()-1+m_startline); + const int count = TQMAX(0, m_table->numRows()-1+m_startline); m_allRowsLoadedInPreview = count < m_maximumRowsForPreview && !m_stoppedAt_MAX_BYTES_TO_PREVIEW; if (m_allRowsLoadedInPreview) { m_startAtLineSpinBox->setMaxValue(count); m_startAtLineSpinBox->setValue(m_startline+1); } - m_startAtLineLabel->setText(i18n( "Start at line%1:").arg( - m_allRowsLoadedInPreview ? QString(" (1-%1)").arg(count) - : QString::null //we do not know what's real count + m_startAtLineLabel->setText(i18n( "Start at line%1:").tqarg( + m_allRowsLoadedInPreview ? TQString(" (1-%1)").tqarg(count) + : TQString() //we do not know what's real count )); updateRowCountInfo(); m_blockUserEvents = false; - repaint(); - m_table->verticalScrollBar()->repaint();//avoid missing repaint - m_table->horizontalScrollBar()->repaint();//avoid missing repaint + tqrepaint(); + m_table->verticalScrollBar()->tqrepaint();//avoid missing tqrepaint + m_table->horizontalScrollBar()->tqrepaint();//avoid missing tqrepaint } -QString KexiCSVImportDialog::detectDelimiterByLookingAtFirstBytesOfFile(QTextStream& inputStream) +TQString KexiCSVImportDialog::detectDelimiterByLookingAtFirstBytesOfFile(TQTextStream& inputStream) { m_file->at(0); // try to detect delimiter // \t has priority, then ; then , - const QIODevice::Offset origOffset = inputStream.device()->at(); - QChar c, prevChar=0; + const TQIODevice::Offset origOffset = inputStream.tqdevice()->at(); + TQChar c, prevChar=0; int detectedDelimiter = 0; bool insideQuote = false; //characters by priority - const int CH_TAB_AFTER_QUOTE = 500; - const int CH_SEMICOLON_AFTER_QUOTE = 499; - const int CH_COMMA_AFTER_QUOTE = 498; + const int CH_TAB_AFTER_TQUOTE = 500; + const int CH_SEMICOLON_AFTER_TQUOTE = 499; + const int CH_COMMA_AFTER_TQUOTE = 498; const int CH_TAB = 200; // \t const int CH_SEMICOLON = 199; // ; const int CH_COMMA = 198; // , - QValueList<int> tabsPerLine, semicolonsPerLine, commasPerLine; + TQValueList<int> tabsPerLine, semicolonsPerLine, commasPerLine; int tabs = 0, semicolons = 0, commas = 0; int line = 0; for (uint i=0; !inputStream.atEnd() && i < MAX_CHARS_TO_SCAN_WHILE_DETECTING_DELIMITER; i++) { @@ -586,24 +588,24 @@ QString KexiCSVImportDialog::detectDelimiterByLookingAtFirstBytesOfFile(QTextStr } else if (c=='\t') { tabs++; - detectedDelimiter = QMAX( prevChar=='"' ? CH_TAB_AFTER_QUOTE : CH_TAB, detectedDelimiter ); + detectedDelimiter = TQMAX( prevChar=='"' ? CH_TAB_AFTER_TQUOTE : CH_TAB, detectedDelimiter ); } else if (c==';') { semicolons++; - detectedDelimiter = QMAX( prevChar=='"' ? CH_SEMICOLON_AFTER_QUOTE : CH_SEMICOLON, detectedDelimiter ); + detectedDelimiter = TQMAX( prevChar=='"' ? CH_SEMICOLON_AFTER_TQUOTE : CH_SEMICOLON, detectedDelimiter ); } else if (c==',') { commas++; - detectedDelimiter = QMAX( prevChar=='"' ? CH_COMMA_AFTER_QUOTE : CH_COMMA, detectedDelimiter ); + detectedDelimiter = TQMAX( prevChar=='"' ? CH_COMMA_AFTER_TQUOTE : CH_COMMA, detectedDelimiter ); } prevChar = c; } - inputStream.device()->at(origOffset); //restore orig. offset + inputStream.tqdevice()->at(origOffset); //restore orig. offset //now, try to find a delimiter character that exists the same number of times in all the checked lines //this detection method has priority over others - QValueList<int>::ConstIterator it; + TQValueList<int>::ConstIterator it; if (tabsPerLine.count()>1) { tabs = tabsPerLine.isEmpty() ? 0 : tabsPerLine.first(); for (it=tabsPerLine.constBegin(); it!=tabsPerLine.constEnd(); ++it) { @@ -632,54 +634,54 @@ QString KexiCSVImportDialog::detectDelimiterByLookingAtFirstBytesOfFile(QTextStr return ","; } //now return the winning character by looking at CH_* symbol - if (detectedDelimiter == CH_TAB_AFTER_QUOTE || detectedDelimiter == CH_TAB) + if (detectedDelimiter == CH_TAB_AFTER_TQUOTE || detectedDelimiter == CH_TAB) return "\t"; - if (detectedDelimiter == CH_SEMICOLON_AFTER_QUOTE || detectedDelimiter == CH_SEMICOLON) + if (detectedDelimiter == CH_SEMICOLON_AFTER_TQUOTE || detectedDelimiter == CH_SEMICOLON) return ";"; - if (detectedDelimiter == CH_COMMA_AFTER_QUOTE || detectedDelimiter == CH_COMMA) + if (detectedDelimiter == CH_COMMA_AFTER_TQUOTE || detectedDelimiter == CH_COMMA) return ","; return KEXICSV_DEFAULT_FILE_DELIMITER; //<-- default } -tristate KexiCSVImportDialog::loadRows(QString &field, int &row, int &column, int &maxColumn, +tristate KexiCSVImportDialog::loadRows(TQString &field, int &row, int &column, int &maxColumn, bool inGUI) { - enum { S_START, S_QUOTED_FIELD, S_MAYBE_END_OF_QUOTED_FIELD, S_END_OF_QUOTED_FIELD, + enum { S_START, S_TQUOTED_FIELD, S_MAYBE_END_OF_TQUOTED_FIELD, S_END_OF_TQUOTED_FIELD, S_MAYBE_NORMAL_FIELD, S_NORMAL_FIELD } state = S_START; - field = QString::null; + field = TQString(); const bool ignoreDups = m_ignoreDuplicates->isChecked(); bool lastCharDelimiter = false; bool nextRow = false; row = column = 1; maxColumn = 0; - QChar x; + TQChar x; const bool hadInputStream = m_inputStream!=0; delete m_inputStream; if ( m_mode == Clipboard ) { - m_inputStream = new QTextStream(m_clipboardData, IO_ReadOnly); + m_inputStream = new TQTextStream(m_clipboardData, IO_ReadOnly); if (!hadInputStream) m_delimiterWidget->setDelimiter(KEXICSV_DEFAULT_CLIPBOARD_DELIMITER); } else { m_file->at(0); //always seek at 0 because loadRows() is called many times - m_inputStream = new QTextStream(m_file); + m_inputStream = new TQTextStream(m_file); if (m_options.defaultEncodingExplicitySet) { - QTextCodec *codec = KGlobal::charsets()->codecForName(m_options.encoding); + TQTextCodec *codec = KGlobal::charsets()->codecForName(m_options.encoding); if (codec) - m_inputStream->setCodec(codec); //QTextCodec::codecForName("CP1250")); + m_inputStream->setCodec(codec); //TQTextCodec::codecForName("CP1250")); } if (m_detectDelimiter) { - const QString delimiter( detectDelimiterByLookingAtFirstBytesOfFile(*m_inputStream) ); + const TQString delimiter( detectDelimiterByLookingAtFirstBytesOfFile(*m_inputStream) ); if (m_delimiterWidget->delimiter() != delimiter) m_delimiterWidget->setDelimiter( delimiter ); } } - const QChar delimiter(m_delimiterWidget->delimiter()[0]); + const TQChar delimiter(m_delimiterWidget->delimiter()[0]); m_stoppedAt_MAX_BYTES_TO_PREVIEW = false; int progressStep = 0; if (m_importingProgressDlg) - progressStep = QMAX( 1, m_importingProgressDlg->progressBar()->totalSteps()/200 ); + progressStep = TQMAX( 1, m_importingProgressDlg->progressBar()->totalSteps()/200 ); int offset = 0; for (;!m_inputStream->atEnd(); offset++) { @@ -690,7 +692,7 @@ tristate KexiCSVImportDialog::loadRows(QString &field, int &row, int &column, in if (m_importingProgressDlg && ((offset % progressStep) < 5)) { //update progr. bar dlg on final exporting m_importingProgressDlg->progressBar()->setValue(offset); - qApp->processEvents(); + tqApp->processEvents(); if (m_importingProgressDlg->wasCancelled()) { delete m_importingProgressDlg; m_importingProgressDlg = 0; @@ -703,10 +705,10 @@ tristate KexiCSVImportDialog::loadRows(QString &field, int &row, int &column, in if (x == '\r') { continue; // eat '\r', to handle RFC-compliant files } - if (offset==0 && x.unicode()==0xfeff) { + if (offset==0 && x.tqunicode()==0xfeff) { // Ignore BOM, the "Byte Order Mark" - // (http://en.wikipedia.org/wiki/Byte_Order_Mark, // http://www.unicode.org/charts/PDF/UFFF0.pdf) - // Probably fixed in Qt4. + // (http://en.wikipedia.org/wiki/Byte_Order_Mark, // http://www.tqunicode.org/charts/PDF/UFFF0.pdf) + // Probably fixed in TQt4. continue; } @@ -715,12 +717,12 @@ tristate KexiCSVImportDialog::loadRows(QString &field, int &row, int &column, in case S_START : if (x == m_textquote) { - state = S_QUOTED_FIELD; + state = S_TQUOTED_FIELD; } else if (x == delimiter) { setText(row - m_startline, column, field, inGUI); - field = QString::null; + field = TQString(); if ((ignoreDups == false) || (lastCharDelimiter == false)) ++column; lastCharDelimiter = true; @@ -730,11 +732,11 @@ tristate KexiCSVImportDialog::loadRows(QString &field, int &row, int &column, in if (!inGUI) { //fill remaining empty fields (database wants them explicitly) for (int additionalColumn = column; additionalColumn <= maxColumn; additionalColumn++) { - setText(row - m_startline, additionalColumn, QString::null, inGUI); + setText(row - m_startline, additionalColumn, TQString(), inGUI); } } nextRow = true; - maxColumn = QMAX( maxColumn, column ); + maxColumn = TQMAX( maxColumn, column ); column = 1; } else @@ -743,10 +745,10 @@ tristate KexiCSVImportDialog::loadRows(QString &field, int &row, int &column, in state = S_MAYBE_NORMAL_FIELD; } break; - case S_QUOTED_FIELD : + case S_TQUOTED_FIELD : if (x == m_textquote) { - state = S_MAYBE_END_OF_QUOTED_FIELD; + state = S_MAYBE_END_OF_TQUOTED_FIELD; } /*allow \n inside quoted fields else if (x == '\n') @@ -756,7 +758,7 @@ tristate KexiCSVImportDialog::loadRows(QString &field, int &row, int &column, in if (x == '\n') { nextRow = true; - maxColumn = QMAX( maxColumn, column ); + maxColumn = TQMAX( maxColumn, column ); column = 1; } else @@ -772,20 +774,20 @@ tristate KexiCSVImportDialog::loadRows(QString &field, int &row, int &column, in field += x; } break; - case S_MAYBE_END_OF_QUOTED_FIELD : + case S_MAYBE_END_OF_TQUOTED_FIELD : if (x == m_textquote) { field += x; //no, this was just escaped quote character - state = S_QUOTED_FIELD; + state = S_TQUOTED_FIELD; } else if (x == delimiter || x == '\n') { setText(row - m_startline, column, field, inGUI); - field = QString::null; + field = TQString(); if (x == '\n') { nextRow = true; - maxColumn = QMAX( maxColumn, column ); + maxColumn = TQMAX( maxColumn, column ); column = 1; } else @@ -798,18 +800,18 @@ tristate KexiCSVImportDialog::loadRows(QString &field, int &row, int &column, in } else { - state = S_END_OF_QUOTED_FIELD; + state = S_END_OF_TQUOTED_FIELD; } break; - case S_END_OF_QUOTED_FIELD : + case S_END_OF_TQUOTED_FIELD : if (x == delimiter || x == '\n') { setText(row - m_startline, column, field, inGUI); - field = QString::null; + field = TQString(); if (x == '\n') { nextRow = true; - maxColumn = QMAX( maxColumn, column ); + maxColumn = TQMAX( maxColumn, column ); column = 1; } else @@ -822,25 +824,25 @@ tristate KexiCSVImportDialog::loadRows(QString &field, int &row, int &column, in } else { - state = S_END_OF_QUOTED_FIELD; + state = S_END_OF_TQUOTED_FIELD; } break; case S_MAYBE_NORMAL_FIELD : if (x == m_textquote) { - field = QString::null; - state = S_QUOTED_FIELD; + field = TQString(); + state = S_TQUOTED_FIELD; break; } case S_NORMAL_FIELD : if (x == delimiter || x == '\n') { setText(row - m_startline, column, field, inGUI); - field = QString::null; + field = TQString(); if (x == '\n') { nextRow = true; - maxColumn = QMAX( maxColumn, column ); + maxColumn = TQMAX( maxColumn, column ); column = 1; } else @@ -880,12 +882,12 @@ tristate KexiCSVImportDialog::loadRows(QString &field, int &row, int &column, in m_1stRowForFieldNames->setChecked(true); //this will reload table //slot1stRowForFieldNamesChanged(1); m_blockUserEvents = false; - repaint(); + tqrepaint(); return false; } if (!m_importingProgressDlg && row % 20 == 0) { - qApp->processEvents(); + tqApp->processEvents(); //only for GUI mode: if (!m_firstFillTableCall && m_loadingProgressDlg && m_loadingProgressDlg->wasCancelled()) { delete m_loadingProgressDlg; @@ -897,7 +899,7 @@ tristate KexiCSVImportDialog::loadRows(QString &field, int &row, int &column, in } if (!m_firstFillTableCall && m_loadingProgressDlg) { - m_loadingProgressDlg->progressBar()->setValue(QMIN(m_maximumRowsForPreview, row)); + m_loadingProgressDlg->progressBar()->setValue(TQMIN(m_maximumRowsForPreview, row)); } if ( inGUI && row > (m_maximumRowsForPreview + (m_1stRowForFieldNamesDetected?1:0)) ) { @@ -920,11 +922,11 @@ tristate KexiCSVImportDialog::loadRows(QString &field, int &row, int &column, in void KexiCSVImportDialog::updateColumnText(int col) { - QString colName; + TQString colName; if (col<(int)m_columnNames.count() && (m_1stRowForFieldNames->isChecked() || m_changedColumnNames[col])) colName = m_columnNames[ col ]; if (colName.isEmpty()) { - colName = i18n("Column %1").arg(col+1); //will be changed to a valid identifier on import + colName = i18n("Column %1").tqarg(col+1); //will be changed to a valid identifier on import m_changedColumnNames[ col ] = false; } int detectedType = m_detectedTypes[col]; @@ -935,15 +937,15 @@ void KexiCSVImportDialog::updateColumnText(int col) detectedType=_TEXT_TYPE; } m_table->horizontalHeader()->setLabel(col, - i18n("Column %1").arg(col+1) + " \n(" + m_typeNames[ detectedType ] + ") "); + i18n("Column %1").tqarg(col+1) + " \n(" + m_typeNames[ detectedType ] + ") "); m_table->setText(0, col, colName); m_table->horizontalHeader()->adjustHeaderSize(); //check uniqueness - QValueList<int> *list = m_uniquenessTest[col]; + TQValueList<int> *list = m_uniquenessTest[col]; if (m_primaryKeyColumn==-1 && list && !list->isEmpty()) { qHeapSort(*list); - QValueList<int>::ConstIterator it=list->constBegin(); + TQValueList<int>::ConstIterator it=list->constBegin(); int prevValue = *it; ++it; for(; it!=list->constEnd() && prevValue!=(*it); ++it) @@ -963,7 +965,7 @@ void KexiCSVImportDialog::updateColumnText(int col) list->clear(); } -void KexiCSVImportDialog::detectTypeAndUniqueness(int row, int col, const QString& text) +void KexiCSVImportDialog::detectTypeAndUniqueness(int row, int col, const TQString& text) { int intValue; const int type = m_detectedTypes[col]; @@ -1015,14 +1017,14 @@ void KexiCSVImportDialog::detectTypeAndUniqueness(int row, int col, const QStrin if (row==1 || type==_NO_TYPE_YET) { bool detected = text.isEmpty(); if (!detected) { - const QStringList dateTimeList( QStringList::split(" ", text) ); + const TQStringList dateTimeList( TQStringList::split(" ", text) ); bool ok = dateTimeList.count()>=2; //! @todo also support ISODateTime's "T" separator? //! @todo also support timezones? if (ok) { //try all combinations - QString datePart( dateTimeList[0].stripWhiteSpace() ); - QString timePart( dateTimeList[1].stripWhiteSpace() ); + TQString datePart( dateTimeList[0].stripWhiteSpace() ); + TQString timePart( dateTimeList[1].stripWhiteSpace() ); ok = m_dateRegExp.exactMatch(datePart) && (m_timeRegExp1.exactMatch(timePart) || m_timeRegExp2.exactMatch(timePart)); } @@ -1042,10 +1044,10 @@ void KexiCSVImportDialog::detectTypeAndUniqueness(int row, int col, const QStrin //default: text type (already set) } //check uniqueness for this value - QValueList<int> *list = m_uniquenessTest[col]; + TQValueList<int> *list = m_uniquenessTest[col]; if (row==1 && (!list || !list->isEmpty()) && !text.isEmpty() && _NUMBER_TYPE == m_detectedTypes[col]) { if (!list) { - list = new QValueList<int>(); + list = new TQValueList<int>(); m_uniquenessTest.insert(col, list); } list->append( intValue ); @@ -1057,7 +1059,7 @@ void KexiCSVImportDialog::detectTypeAndUniqueness(int row, int col, const QStrin } } -bool KexiCSVImportDialog::parseDate(const QString& text, QDate& date) +bool KexiCSVImportDialog::parseDate(const TQString& text, TQDate& date) { if (!m_dateRegExp.exactMatch(text)) return false; @@ -1065,77 +1067,77 @@ bool KexiCSVImportDialog::parseDate(const QString& text, QDate& date) //1 2 3 4 5 <- pos const int d1 = m_dateRegExp.cap(1).toInt(), d3 = m_dateRegExp.cap(3).toInt(), d5 = m_dateRegExp.cap(5).toInt(); if (m_dateRegExp.cap(2)=="/") //probably separator for american format mm/dd/yyyy - date = QDate(d5, d1, d3); + date = TQDate(d5, d1, d3); else { if (d5 > 31) //d5 == year - date = QDate(d5, d3, d1); + date = TQDate(d5, d3, d1); else //d1 == year - date = QDate(d1, d3, d5); + date = TQDate(d1, d3, d5); } return date.isValid(); } -bool KexiCSVImportDialog::parseTime(const QString& text, QTime& time) +bool KexiCSVImportDialog::parseTime(const TQString& text, TQTime& time) { - time = QTime::fromString(text, Qt::ISODate); //same as m_timeRegExp1 + time = TQTime::fromString(text, Qt::ISODate); //same as m_timeRegExp1 if (time.isValid()) return true; if (m_timeRegExp2.exactMatch(text)) { //hh:mm:ss - time = QTime(m_timeRegExp2.cap(1).toInt(), m_timeRegExp2.cap(3).toInt(), m_timeRegExp2.cap(5).toInt()); + time = TQTime(m_timeRegExp2.cap(1).toInt(), m_timeRegExp2.cap(3).toInt(), m_timeRegExp2.cap(5).toInt()); return true; } return false; } -void KexiCSVImportDialog::setText(int row, int col, const QString& text, bool inGUI) +void KexiCSVImportDialog::setText(int row, int col, const TQString& text, bool inGUI) { if (!inGUI) { //save text directly to database buffer if (col==1) { //1st col m_importingStatement->clearArguments(); if (m_implicitPrimaryKeyAdded) - *m_importingStatement << QVariant(); //id will be autogenerated here + *m_importingStatement << TQVariant(); //id will be autogenerated here } const int detectedType = m_detectedTypes[col-1]; if (detectedType==_NUMBER_TYPE) { - *m_importingStatement << ( text.isEmpty() ? QVariant() : text.toInt() ); + *m_importingStatement << ( text.isEmpty() ? TQVariant() : text.toInt() ); //! @todo what about time and float/double types and different integer subtypes? } else if (detectedType==_FP_NUMBER_TYPE) { - //replace ',' with '.' - QCString t(text.latin1()); + //tqreplace ',' with '.' + TQCString t(text.latin1()); const int textLen = t.length(); for (int i=0; i<textLen; i++) { - if (t.at(i)==',') { - t.at(i) = '.'; + if (t.tqat(i)==',') { + t.tqat(i) = '.'; break; } } - *m_importingStatement << ( t.isEmpty() ? QVariant() : t.toDouble() ); + *m_importingStatement << ( t.isEmpty() ? TQVariant() : t.toDouble() ); } else if (detectedType==_DATE_TYPE) { - QDate date; + TQDate date; if (parseDate(text, date)) *m_importingStatement << date; } else if (detectedType==_TIME_TYPE) { - QTime time; + TQTime time; if (parseTime(text, time)) *m_importingStatement << time; } else if (detectedType==_DATETIME_TYPE) { - QStringList dateTimeList( QStringList::split(" ", text) ); + TQStringList dateTimeList( TQStringList::split(" ", text) ); if (dateTimeList.count()<2) - dateTimeList = QStringList::split("T", text); //also support ISODateTime's "T" separator + dateTimeList = TQStringList::split("T", text); //also support ISODateTime's "T" separator //! @todo also support timezones? if (dateTimeList.count()>=2) { - QString datePart( dateTimeList[0].stripWhiteSpace() ); - QDate date; + TQString datePart( dateTimeList[0].stripWhiteSpace() ); + TQDate date; if (parseDate(datePart, date)) { - QString timePart( dateTimeList[1].stripWhiteSpace() ); - QTime time; + TQString timePart( dateTimeList[1].stripWhiteSpace() ); + TQTime time; if (parseTime(timePart, time)) - *m_importingStatement << QDateTime(date, time); + *m_importingStatement << TQDateTime(date, time); } } } @@ -1154,10 +1156,10 @@ void KexiCSVImportDialog::setText(int row, int col, const QString& text, bool in if (m_1stRowForFieldNames->isChecked()) { if ((row+m_startline)==1) {//this is for column name - if ((col-1) < (int)m_changedColumnNames.size() && false==m_changedColumnNames[col-1]) { + if ((col-1) < (int)m_changedColumnNames.size() && (int)false==(int)m_changedColumnNames[col-1]) { //this column has no custom name entered by a user //-get the name from the data cell - QString colName(text.simplifyWhiteSpace()); + TQString colName(text.simplifyWhiteSpace()); if (!colName.isEmpty()) { if (colName.left(1)>="0" && colName.left(1)<="9") colName.prepend(i18n("Column")+" "); @@ -1170,7 +1172,7 @@ void KexiCSVImportDialog::setText(int row, int col, const QString& text, bool in else { if ((row+m_startline)==1) {//this row is for column name if (m_1stRowForFieldNamesDetected && !m_1stRowForFieldNames->isChecked()) { - QString f( text.simplifyWhiteSpace() ); + TQString f( text.simplifyWhiteSpace() ); if (f.isEmpty() || !f[0].isLetter()) m_1stRowForFieldNamesDetected = false; //this couldn't be a column name } @@ -1191,7 +1193,7 @@ void KexiCSVImportDialog::setText(int row, int col, const QString& text, bool in } m_table->setText(row - 1, col - 1, (m_options.stripWhiteSpaceInTextValuesChecked ? text.stripWhiteSpace() : text)); - m_table->verticalHeader()->setLabel(row-1, QString::number(row-1)); + m_table->verticalHeader()->setLabel(row-1, TQString::number(row-1)); detectTypeAndUniqueness(row-1, col-1, text); } @@ -1225,7 +1227,7 @@ void KexiCSVImportDialog::formatChanged(int id) { if (id==_PK_FLAG) { if (m_primaryKeyColumn>=0 && m_primaryKeyColumn<m_table->numCols()) { - m_table->setPixmap(0, m_primaryKeyColumn, QPixmap()); + m_table->setPixmap(0, m_primaryKeyColumn, TQPixmap()); } if (m_primaryKeyField->isChecked()) { m_primaryKeyColumn = m_table->currentColumn(); @@ -1243,18 +1245,18 @@ void KexiCSVImportDialog::formatChanged(int id) updateColumnText(m_table->currentColumn()); } -void KexiCSVImportDialog::delimiterChanged(const QString& delimiter) +void KexiCSVImportDialog::delimiterChanged(const TQString& delimiter) { Q_UNUSED(delimiter); m_columnsAdjusted = false; m_detectDelimiter = false; //selected by hand: do not detect in the future - //delayed, otherwise combobox won't be repainted + //delayed, otherwise combobox won't be tqrepainted fillTableLater(); } void KexiCSVImportDialog::textquoteSelected(int) { - const QString tq(m_comboQuote->textQuote()); + const TQString tq(m_comboQuote->textQuote()); if (tq.isEmpty()) m_textquote = 0; else @@ -1262,14 +1264,14 @@ void KexiCSVImportDialog::textquoteSelected(int) kexipluginsdbg << "KexiCSVImportDialog::textquoteSelected(): " << m_textquote << endl; - //delayed, otherwise combobox won't be repainted + //delayed, otherwise combobox won't be tqrepainted fillTableLater(); } void KexiCSVImportDialog::fillTableLater() { m_table->setNumRows( 0 ); - QTimer::singleShot(10, this, SLOT(fillTable())); + TQTimer::singleShot(10, this, TQT_SLOT(fillTable())); } void KexiCSVImportDialog::startlineSelected(int startline) @@ -1293,7 +1295,7 @@ void KexiCSVImportDialog::currentCellChanged(int, int col) type=_NUMBER_TYPE; //we're simplifying that for now m_formatCombo->setCurrentItem( type ); - m_formatLabel->setText( m_formatComboText.arg(col+1) ); + m_formatLabel->setText( m_formatComboText.tqarg(col+1) ); m_primaryKeyField->setEnabled( _NUMBER_TYPE == m_detectedTypes[col]); m_primaryKeyField->blockSignals(true); //block to disable executing slotPrimaryKeyFieldToggled() m_primaryKeyField->setChecked( m_primaryKeyColumn == col ); @@ -1341,12 +1343,12 @@ void KexiCSVImportDialog::accept() } //get suggested name based on the file name - QString suggestedName; + TQString suggestedName; if (m_mode==File) { suggestedName = KURL::fromPathOrURL(m_fname).fileName(); //remove extension if (!suggestedName.isEmpty()) { - const int idx = suggestedName.findRev("."); + const int idx = suggestedName.tqfindRev("."); if (idx!=-1) suggestedName = suggestedName.mid(0, idx ).simplifyWhiteSpace(); } @@ -1395,7 +1397,7 @@ void KexiCSVImportDialog::accept() i18n("No Primary Key (autonumber) has been defined.\n" "Should it be automatically defined on import (recommended)?\n\n" "Note: An imported table without a Primary Key may not be editable (depending on database type)."), - QString::null, KGuiItem(i18n("Add Database Primary Key to a Table", "Add Primary Key"), "key"), + TQString(), KGuiItem(i18n("Add Database Primary Key to a Table", "Add Primary Key"), "key"), KGuiItem(i18n("Do Not Add Database Primary Key to a Table", "Do Not Add"))))) { if (msgboxResult == KMessageBox::Cancel) @@ -1405,19 +1407,19 @@ void KexiCSVImportDialog::accept() //! @todo make this field hidden (what about e.g. pgsql?) m_implicitPrimaryKeyAdded = true; - QString fieldName("id"); - QString fieldCaption("Id"); + TQString fieldName("id"); + TQString fieldCaption("Id"); - QStringList colnames; + TQStringList colnames; for (uint col = 0; col < numCols; col++) colnames.append( m_table->text(0, col).lower().simplifyWhiteSpace() ); - if (colnames.find(fieldName)!=colnames.end()) { + if (colnames.tqfind(fieldName)!=colnames.end()) { int num = 1; - while (colnames.find(fieldName+QString::number(num))!=colnames.end()) + while (colnames.tqfind(fieldName+TQString::number(num))!=colnames.end()) num++; - fieldName += QString::number(num); - fieldCaption += QString::number(num); + fieldName += TQString::number(num); + fieldCaption += TQString::number(num); } KexiDB::Field *field = new KexiDB::Field( fieldName, @@ -1425,7 +1427,7 @@ void KexiCSVImportDialog::accept() KexiDB::Field::NoConstraints, KexiDB::Field::NoOptions, 0,0, //uint length=0, uint precision=0, - QVariant(), //QVariant defaultValue=QVariant(), + TQVariant(), //TQVariant defaultValue=TQVariant(), fieldCaption ); //no description and width for now field->setPrimaryKey(true); @@ -1434,19 +1436,19 @@ void KexiCSVImportDialog::accept() } for (uint col = 0; col < numCols; col++) { - QString fieldCaption( m_table->text(0, col).simplifyWhiteSpace() ); - QString fieldName( KexiUtils::string2Identifier( fieldCaption ) ); + TQString fieldCaption( m_table->text(0, col).simplifyWhiteSpace() ); + TQString fieldName( KexiUtils::string2Identifier( fieldCaption ) ); if (m_destinationTableSchema->field(fieldName)) { - QString fixedFieldName; + TQString fixedFieldName; uint i = 2; //"apple 2, apple 3, etc. if there're many "apple" names do { - fixedFieldName = fieldName + "_" + QString::number(i); + fixedFieldName = fieldName + "_" + TQString::number(i); if (!m_destinationTableSchema->field(fixedFieldName)) break; i++; } while (true); fieldName = fixedFieldName; - fieldCaption += (" " + QString::number(i)); + fieldCaption += (" " + TQString::number(i)); } const int detectedType = m_detectedTypes[col]; KexiDB::Field::Type fieldType; @@ -1471,7 +1473,7 @@ void KexiCSVImportDialog::accept() KexiDB::Field::NoConstraints, KexiDB::Field::NoOptions, 0,0, //uint length=0, uint precision=0, - QVariant(), //QVariant defaultValue=QVariant(), + TQVariant(), //TQVariant defaultValue=TQVariant(), fieldCaption ); //no description and width for now @@ -1516,17 +1518,17 @@ void KexiCSVImportDialog::accept() if (m_file) { if (!m_importingProgressDlg) { m_importingProgressDlg = new KProgressDialog( this, "m_importingProgressDlg", - i18n("Importing CSV Data"), QString::null, true ); + i18n("Importing CSV Data"), TQString(), true ); } m_importingProgressDlg->setLabel( i18n("Importing CSV Data from <nobr>\"%1\"</nobr> into \"%2\" table...") - .arg(QDir::convertSeparators(m_fname)).arg(m_destinationTableSchema->name()) ); - m_importingProgressDlg->progressBar()->setTotalSteps( QFileInfo(*m_file).size() ); + .tqarg(TQDir::convertSeparators(m_fname)).tqarg(m_destinationTableSchema->name()) ); + m_importingProgressDlg->progressBar()->setTotalSteps( TQFileInfo(*m_file).size() ); m_importingProgressDlg->show(); } int row, column, maxColumn; - QString field = QString::null; + TQString field = TQString(); // main job res = loadRows(field, row, column, maxColumn, false /*!gui*/ ); @@ -1546,14 +1548,14 @@ void KexiCSVImportDialog::accept() setText(row - m_startline, column, field, false /*!gui*/); //fill remaining empty fields (database wants them explicitly) for (int additionalColumn = column; additionalColumn <= maxColumn; additionalColumn++) { - setText(row - m_startline, additionalColumn, QString::null, false /*!gui*/); + setText(row - m_startline, additionalColumn, TQString(), false /*!gui*/); } if (!saveRow(false /*!gui*/)) { msg.showErrorMessage(m_conn); _DROP_DEST_TABLE_AND_RETURN; } ++row; - field = QString::null; + field = TQString(); } if (!tg.commit()) { @@ -1565,16 +1567,16 @@ void KexiCSVImportDialog::accept() partItemForSavedTable->setIdentifier( m_destinationTableSchema->id() ); project->addStoredItem( part->info(), partItemForSavedTable ); - QDialog::accept(); + TQDialog::accept(); KMessageBox::information(this, i18n("Data has been successfully imported to table \"%1\".") - .arg(m_destinationTableSchema->name())); - parentWidget()->raise(); + .tqarg(m_destinationTableSchema->name())); + tqparentWidget()->raise(); m_conn = 0; } int KexiCSVImportDialog::getHeader(int col) { - QString header = m_table->horizontalHeader()->label(col); + TQString header = m_table->horizontalHeader()->label(col); if (header == i18n("Text type for column", "Text")) return TEXT; @@ -1586,7 +1588,7 @@ int KexiCSVImportDialog::getHeader(int col) return DATE; } -QString KexiCSVImportDialog::getText(int row, int col) +TQString KexiCSVImportDialog::getText(int row, int col) { return m_table->text(row, col); } @@ -1607,7 +1609,7 @@ void KexiCSVImportDialog::slot1stRowForFieldNamesChanged(int) void KexiCSVImportDialog::optionsButtonClicked() { KexiCSVImportOptionsDialog dlg(m_options, this); - if (QDialog::Accepted != dlg.exec()) + if (TQDialog::Accepted != dlg.exec()) return; KexiCSVImportOptions newOptions( dlg.options() ); @@ -1619,23 +1621,23 @@ void KexiCSVImportDialog::optionsButtonClicked() } } -bool KexiCSVImportDialog::eventFilter ( QObject * watched, QEvent * e ) +bool KexiCSVImportDialog::eventFilter ( TQObject * watched, TQEvent * e ) { - QEvent::Type t = e->type(); + TQEvent::Type t = e->type(); // temporary disable keyboard and mouse events for time-consuming tasks - if (m_blockUserEvents && (t==QEvent::KeyPress || t==QEvent::KeyRelease - || t==QEvent::MouseButtonPress || t==QEvent::MouseButtonDblClick - || t==QEvent::Paint )) + if (m_blockUserEvents && (t==TQEvent::KeyPress || t==TQEvent::KeyRelease + || t==TQEvent::MouseButtonPress || t==TQEvent::MouseButtonDblClick + || t==TQEvent::Paint )) return true; - if (watched == m_startAtLineSpinBox && t==QEvent::KeyPress) { - QKeyEvent *ke = static_cast<QKeyEvent*>(e); - if (ke->key()==Qt::Key_Enter || ke->key()==Qt::Key_Return) { + if (TQT_BASE_OBJECT(watched) == TQT_BASE_OBJECT(m_startAtLineSpinBox) && t==TQEvent::KeyPress) { + TQKeyEvent *ke = TQT_TQKEYEVENT(e); + if (ke->key()==TQt::Key_Enter || ke->key()==TQt::Key_Return) { m_table->setFocus(); return true; } } - return QDialog::eventFilter( watched, e ); + return TQDialog::eventFilter( watched, e ); } void KexiCSVImportDialog::slotPrimaryKeyFieldToggled(bool on) @@ -1649,13 +1651,13 @@ void KexiCSVImportDialog::updateRowCountInfo() m_infoLbl->setFileName( m_fname ); if (m_allRowsLoadedInPreview) { m_infoLbl->setCommentText( - i18n("row count", "(rows: %1)").arg( m_table->numRows()-1+m_startline ) ); - QToolTip::remove( m_infoLbl ); + i18n("row count", "(rows: %1)").tqarg( m_table->numRows()-1+m_startline ) ); + TQToolTip::remove( m_infoLbl ); } else { m_infoLbl->setCommentText( - i18n("row count", "(rows: more than %1)").arg( m_table->numRows()-1+m_startline ) ); - QToolTip::add( m_infoLbl->commentLabel(), i18n("Not all rows are visible on this preview") ); + i18n("row count", "(rows: more than %1)").tqarg( m_table->numRows()-1+m_startline ) ); + TQToolTip::add( m_infoLbl->commentLabel(), i18n("Not all rows are visible on this preview") ); } } |