diff options
Diffstat (limited to 'src/translators/csvimporter.cpp')
| -rw-r--r-- | src/translators/csvimporter.cpp | 178 |
1 files changed, 89 insertions, 89 deletions
diff --git a/src/translators/csvimporter.cpp b/src/translators/csvimporter.cpp index f0c0900..683a3d1 100644 --- a/src/translators/csvimporter.cpp +++ b/src/translators/csvimporter.cpp @@ -36,17 +36,17 @@ extern "C" { #include <kconfig.h> #include <kmessagebox.h> -#include <qgroupbox.h> -#include <qlayout.h> -#include <qhbox.h> -#include <qlabel.h> -#include <qcheckbox.h> -#include <qbuttongroup.h> -#include <qradiobutton.h> -#include <qwhatsthis.h> -#include <qtable.h> -#include <qvaluevector.h> -#include <qregexp.h> +#include <tqgroupbox.h> +#include <tqlayout.h> +#include <tqhbox.h> +#include <tqlabel.h> +#include <tqcheckbox.h> +#include <tqbuttongroup.h> +#include <tqradiobutton.h> +#include <tqwhatsthis.h> +#include <tqtable.h> +#include <tqvaluevector.h> +#include <tqregexp.h> using Tellico::Import::CSVImporter; @@ -55,22 +55,22 @@ static void writeRow(char buffer, void* data); class CSVImporter::Parser { public: - Parser(const QString& str) : stream(new QTextIStream(&str)) { csv_init(&parser, 0); } + Parser(const TQString& str) : stream(new TQTextIStream(&str)) { csv_init(&parser, 0); } ~Parser() { csv_free(parser); delete stream; stream = 0; } - void setDelimiter(const QString& s) { Q_ASSERT(s.length() == 1); csv_set_delim(parser, s[0].latin1()); } - void reset(const QString& str) { delete stream; stream = new QTextIStream(&str); }; + void setDelimiter(const TQString& s) { Q_ASSERT(s.length() == 1); csv_set_delim(parser, s[0].latin1()); } + void reset(const TQString& str) { delete stream; stream = new TQTextIStream(&str); }; bool hasNext() { return !stream->atEnd(); } void skipLine() { stream->readLine(); } - void addToken(const QString& t) { tokens += t; } + void addToken(const TQString& t) { tokens += t; } void setRowDone(bool b) { done = b; } - QStringList nextTokens() { + TQStringList nextTokens() { tokens.clear(); done = false; while(hasNext() && !done) { - QCString line = stream->readLine().utf8() + '\n'; // need the eol char + TQCString line = stream->readLine().utf8() + '\n'; // need the eol char csv_parse(parser, line, line.length(), &writeToken, &writeRow, this); } csv_fini(parser, &writeToken, &writeRow, this); @@ -79,14 +79,14 @@ public: private: struct csv_parser* parser; - QTextIStream* stream; - QStringList tokens; + TQTextIStream* stream; + TQStringList tokens; bool done; }; static void writeToken(char* buffer, size_t len, void* data) { CSVImporter::Parser* p = static_cast<CSVImporter::Parser*>(data); - p->addToken(QString::fromUtf8(buffer, len)); + p->addToken(TQString::fromUtf8(buffer, len)); } static void writeRow(char c, void* data) { @@ -99,7 +99,7 @@ CSVImporter::CSVImporter(const KURL& url_) : Tellico::Import::TextImporter(url_) m_coll(0), m_existingCollection(0), m_firstRowHeader(false), - m_delimiter(QString::fromLatin1(",")), + m_delimiter(TQString::tqfromLatin1(",")), m_cancelled(false), m_widget(0), m_table(0), @@ -123,12 +123,12 @@ Tellico::Data::CollPtr CSVImporter::collection() { m_coll = CollectionFactory::collection(m_comboColl->currentType(), true); } - const QStringList existingNames = m_coll->fieldNames(); + const TQStringList existingNames = m_coll->fieldNames(); - QValueVector<int> cols; - QStringList names; + TQValueVector<int> cols; + TQStringList names; for(int col = 0; col < m_table->numCols(); ++col) { - QString t = m_table->horizontalHeader()->label(col); + TQString t = m_table->horizontalHeader()->label(col); if(m_existingCollection && m_existingCollection->fieldByTitle(t)) { // the collection might have the right field, but a different title, say for translations Data::FieldPtr f = m_existingCollection->fieldByTitle(t); @@ -157,23 +157,23 @@ Tellico::Data::CollPtr CSVImporter::collection() { m_parser->skipLine(); } - const uint numLines = text().contains('\n'); - const uint stepSize = QMAX(s_stepSize, numLines/100); + const uint numLines = text().tqcontains('\n'); + const uint stepSize = TQMAX(s_stepSize, numLines/100); const bool showProgress = options() & ImportProgress; ProgressItem& item = ProgressManager::self()->newProgressItem(this, progressLabel(), true); item.setTotalSteps(numLines); - connect(&item, SIGNAL(signalCancelled(ProgressItem*)), SLOT(slotCancel())); + connect(&item, TQT_SIGNAL(signalCancelled(ProgressItem*)), TQT_SLOT(slotCancel())); ProgressItem::Done done(this); uint j = 0; while(!m_cancelled && m_parser->hasNext()) { bool empty = true; Data::EntryPtr entry = new Data::Entry(m_coll); - QStringList values = m_parser->nextTokens(); + TQStringList values = m_parser->nextTokens(); for(uint i = 0; i < names.size(); ++i) { -// QString value = values[cols[i]].simplifyWhiteSpace(); - QString value = values[cols[i]].stripWhiteSpace(); +// TQString value = values[cols[i]].simplifyWhiteSpace(); + TQString value = values[cols[i]].stripWhiteSpace(); bool success = entry->setField(names[i], value); // we might need to add a new allowed value // assume that if the user is importing the value, it should be allowed @@ -202,7 +202,7 @@ Tellico::Data::CollPtr CSVImporter::collection() { } { - KConfigGroup config(KGlobal::config(), QString::fromLatin1("ImportOptions - CSV")); + KConfigGroup config(KGlobal::config(), TQString::tqfromLatin1("ImportOptions - CSV")); config.writeEntry("Delimiter", m_delimiter); config.writeEntry("First Row Titles", m_firstRowHeader); } @@ -210,117 +210,117 @@ Tellico::Data::CollPtr CSVImporter::collection() { return m_coll; } -QWidget* CSVImporter::widget(QWidget* parent_, const char* name_) { - if(m_widget && m_widget->parent() == parent_) { +TQWidget* CSVImporter::widget(TQWidget* tqparent_, const char* name_) { + if(m_widget && TQT_BASE_OBJECT(m_widget->tqparent()) == TQT_BASE_OBJECT(tqparent_)) { return m_widget; } - m_widget = new QWidget(parent_, name_); - QVBoxLayout* l = new QVBoxLayout(m_widget); + m_widget = new TQWidget(tqparent_, name_); + TQVBoxLayout* l = new TQVBoxLayout(m_widget); - QGroupBox* group = new QGroupBox(1, Qt::Horizontal, i18n("CSV Options"), m_widget); + TQGroupBox* group = new TQGroupBox(1, Qt::Horizontal, i18n("CSV Options"), m_widget); l->addWidget(group); - QHBox* box = new QHBox(group); + TQHBox* box = new TQHBox(group); box->setSpacing(5); - QLabel* lab = new QLabel(i18n("Collection &type:"), box); + TQLabel* lab = new TQLabel(i18n("Collection &type:"), box); m_comboColl = new GUI::CollectionTypeCombo(box); lab->setBuddy(m_comboColl); - QWhatsThis::add(m_comboColl, i18n("Select the type of collection being imported.")); - connect(m_comboColl, SIGNAL(activated(int)), SLOT(slotTypeChanged())); + TQWhatsThis::add(m_comboColl, i18n("Select the type of collection being imported.")); + connect(m_comboColl, TQT_SIGNAL(activated(int)), TQT_SLOT(slotTypeChanged())); // need a spacer - QWidget* w = new QWidget(box); + TQWidget* w = new TQWidget(box); box->setStretchFactor(w, 1); - m_checkFirstRowHeader = new QCheckBox(i18n("&First row contains field titles"), group); - QWhatsThis::add(m_checkFirstRowHeader, i18n("If checked, the first row is used as field titles.")); - connect(m_checkFirstRowHeader, SIGNAL(toggled(bool)), SLOT(slotFirstRowHeader(bool))); + m_checkFirstRowHeader = new TQCheckBox(i18n("&First row contains field titles"), group); + TQWhatsThis::add(m_checkFirstRowHeader, i18n("If checked, the first row is used as field titles.")); + connect(m_checkFirstRowHeader, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotFirstRowHeader(bool))); - QHBox* hbox2 = new QHBox(group); - m_delimiterGroup = new QButtonGroup(0, Qt::Vertical, i18n("Delimiter"), hbox2); - QGridLayout* m_delimiterGroupLayout = new QGridLayout(m_delimiterGroup->layout(), 3, 3); - m_delimiterGroupLayout->setAlignment(Qt::AlignTop); - QWhatsThis::add(m_delimiterGroup, i18n("In addition to a comma, other characters may be used as " + TQHBox* hbox2 = new TQHBox(group); + m_delimiterGroup = new TQButtonGroup(0, Qt::Vertical, i18n("Delimiter"), hbox2); + TQGridLayout* m_delimiterGroupLayout = new TQGridLayout(m_delimiterGroup->tqlayout(), 3, 3); + m_delimiterGroupLayout->tqsetAlignment(TQt::AlignTop); + TQWhatsThis::add(m_delimiterGroup, i18n("In addition to a comma, other characters may be used as " "a delimiter, separating each value in the file.")); - connect(m_delimiterGroup, SIGNAL(clicked(int)), SLOT(slotDelimiter())); + connect(m_delimiterGroup, TQT_SIGNAL(clicked(int)), TQT_SLOT(slotDelimiter())); - m_radioComma = new QRadioButton(m_delimiterGroup); + m_radioComma = new TQRadioButton(m_delimiterGroup); m_radioComma->setText(i18n("&Comma")); m_radioComma->setChecked(true); - QWhatsThis::add(m_radioComma, i18n("Use a comma as the delimiter.")); + TQWhatsThis::add(m_radioComma, i18n("Use a comma as the delimiter.")); m_delimiterGroupLayout->addWidget(m_radioComma, 1, 0); - m_radioSemicolon = new QRadioButton( m_delimiterGroup); + m_radioSemicolon = new TQRadioButton( m_delimiterGroup); m_radioSemicolon->setText(i18n("&Semicolon")); - QWhatsThis::add(m_radioSemicolon, i18n("Use a semi-colon as the delimiter.")); + TQWhatsThis::add(m_radioSemicolon, i18n("Use a semi-colon as the delimiter.")); m_delimiterGroupLayout->addWidget(m_radioSemicolon, 1, 1); - m_radioTab = new QRadioButton(m_delimiterGroup); + m_radioTab = new TQRadioButton(m_delimiterGroup); m_radioTab->setText(i18n("Ta&b")); - QWhatsThis::add(m_radioTab, i18n("Use a tab as the delimiter.")); + TQWhatsThis::add(m_radioTab, i18n("Use a tab as the delimiter.")); m_delimiterGroupLayout->addWidget(m_radioTab, 2, 0); - m_radioOther = new QRadioButton(m_delimiterGroup); + m_radioOther = new TQRadioButton(m_delimiterGroup); m_radioOther->setText(i18n("Ot&her:")); - QWhatsThis::add(m_radioOther, i18n("Use a custom string as the delimiter.")); + TQWhatsThis::add(m_radioOther, i18n("Use a custom string as the delimiter.")); m_delimiterGroupLayout->addWidget(m_radioOther, 2, 1); m_editOther = new KLineEdit(m_delimiterGroup); m_editOther->setEnabled(false); m_editOther->setFixedWidth(m_widget->fontMetrics().width('X') * 4); m_editOther->setMaxLength(1); - QWhatsThis::add(m_editOther, i18n("A custom string, such as a colon, may be used as a delimiter.")); + TQWhatsThis::add(m_editOther, i18n("A custom string, such as a colon, may be used as a delimiter.")); m_delimiterGroupLayout->addWidget(m_editOther, 2, 2); - connect(m_radioOther, SIGNAL(toggled(bool)), - m_editOther, SLOT(setEnabled(bool))); - connect(m_editOther, SIGNAL(textChanged(const QString&)), SLOT(slotDelimiter())); + connect(m_radioOther, TQT_SIGNAL(toggled(bool)), + m_editOther, TQT_SLOT(setEnabled(bool))); + connect(m_editOther, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotDelimiter())); - w = new QWidget(hbox2); + w = new TQWidget(hbox2); hbox2->setStretchFactor(w, 1); - m_table = new QTable(5, 0, group); - m_table->setSelectionMode(QTable::Single); - m_table->setFocusStyle(QTable::FollowStyle); + m_table = new TQTable(5, 0, group); + m_table->setSelectionMode(TQTable::Single); + m_table->setFocusStyle(TQTable::FollowStyle); m_table->setLeftMargin(0); m_table->verticalHeader()->hide(); m_table->horizontalHeader()->setClickEnabled(true); m_table->setReadOnly(true); m_table->setMinimumHeight(m_widget->fontMetrics().lineSpacing() * 8); - QWhatsThis::add(m_table, i18n("The table shows up to the first five lines of the CSV file.")); - connect(m_table, SIGNAL(currentChanged(int, int)), SLOT(slotCurrentChanged(int, int))); - connect(m_table->horizontalHeader(), SIGNAL(clicked(int)), SLOT(slotHeaderClicked(int))); + TQWhatsThis::add(m_table, i18n("The table shows up to the first five lines of the CSV file.")); + connect(m_table, TQT_SIGNAL(currentChanged(int, int)), TQT_SLOT(slotCurrentChanged(int, int))); + connect(m_table->horizontalHeader(), TQT_SIGNAL(clicked(int)), TQT_SLOT(slotHeaderClicked(int))); - QWidget* hbox = new QWidget(group); - QHBoxLayout* hlay = new QHBoxLayout(hbox, 5); + TQWidget* hbox = new TQWidget(group); + TQHBoxLayout* hlay = new TQHBoxLayout(hbox, 5); hlay->addStretch(10); - QWhatsThis::add(hbox, i18n("<qt>Set each column to correspond to a field in the collection by choosing " + TQWhatsThis::add(hbox, i18n("<qt>Set each column to correspond to a field in the collection by choosing " "a column, selecting the field, then clicking the <i>Assign Field</i> button.</qt>")); - lab = new QLabel(i18n("Co&lumn:"), hbox); + lab = new TQLabel(i18n("Co&lumn:"), hbox); hlay->addWidget(lab); m_colSpinBox = new KIntSpinBox(hbox); hlay->addWidget(m_colSpinBox); m_colSpinBox->setMinValue(1); - connect(m_colSpinBox, SIGNAL(valueChanged(int)), SLOT(slotSelectColumn(int))); + connect(m_colSpinBox, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(slotSelectColumn(int))); lab->setBuddy(m_colSpinBox); hlay->addSpacing(10); - lab = new QLabel(i18n("&Data field in this column:"), hbox); + lab = new TQLabel(i18n("&Data field in this column:"), hbox); hlay->addWidget(lab); m_comboField = new KComboBox(hbox); hlay->addWidget(m_comboField); - connect(m_comboField, SIGNAL(activated(int)), SLOT(slotFieldChanged(int))); + connect(m_comboField, TQT_SIGNAL(activated(int)), TQT_SLOT(slotFieldChanged(int))); lab->setBuddy(m_comboField); hlay->addSpacing(10); m_setColumnBtn = new KPushButton(i18n("&Assign Field"), hbox); hlay->addWidget(m_setColumnBtn); - m_setColumnBtn->setIconSet(SmallIconSet(QString::fromLatin1("apply"))); - connect(m_setColumnBtn, SIGNAL(clicked()), SLOT(slotSetColumnTitle())); + m_setColumnBtn->setIconSet(SmallIconSet(TQString::tqfromLatin1("apply"))); + connect(m_setColumnBtn, TQT_SIGNAL(clicked()), TQT_SLOT(slotSetColumnTitle())); hlay->addStretch(10); l->addStretch(1); - KConfigGroup config(KGlobal::config(), QString::fromLatin1("ImportOptions - CSV")); + KConfigGroup config(KGlobal::config(), TQString::tqfromLatin1("ImportOptions - CSV")); m_delimiter = config.readEntry("Delimiter", m_delimiter); m_firstRowHeader = config.readBoolEntry("First Row Titles", m_firstRowHeader); @@ -361,13 +361,13 @@ void CSVImporter::fillTable() { int maxCols = 0; int row = 0; for( ; m_parser->hasNext() && row < m_table->numRows(); ++row) { - QStringList values = m_parser->nextTokens(); + TQStringList values = m_parser->nextTokens(); if(static_cast<int>(values.count()) > m_table->numCols()) { m_table->setNumCols(values.count()); m_colSpinBox->setMaxValue(values.count()); } int col = 0; - for(QStringList::ConstIterator it = values.begin(); it != values.end(); ++it) { + for(TQStringList::ConstIterator it = values.begin(); it != values.end(); ++it) { m_table->setText(row, col, *it); m_table->adjustColumn(col); ++col; @@ -443,14 +443,14 @@ void CSVImporter::slotSelectColumn(int pos_) { void CSVImporter::slotSetColumnTitle() { int col = m_colSpinBox->value()-1; - const QString title = m_comboField->currentText(); + const TQString title = m_comboField->currentText(); m_table->horizontalHeader()->setLabel(col, title); m_hasAssignedFields = true; // make sure none of the other columns have this title bool found = false; for(int i = 0; i < col; ++i) { if(m_table->horizontalHeader()->label(i) == title) { - m_table->horizontalHeader()->setLabel(i, QString::number(i+1)); + m_table->horizontalHeader()->setLabel(i, TQString::number(i+1)); found = true; break; } @@ -461,7 +461,7 @@ void CSVImporter::slotSetColumnTitle() { } for(int i = col+1; i < m_table->numCols(); ++i) { if(m_table->horizontalHeader()->label(i) == title) { - m_table->horizontalHeader()->setLabel(i, QString::number(i+1)); + m_table->horizontalHeader()->setLabel(i, TQString::number(i+1)); break; } } @@ -477,7 +477,7 @@ void CSVImporter::updateHeader(bool force_) { Data::CollPtr c = m_existingCollection ? m_existingCollection : m_coll; for(int col = 0; col < m_table->numCols(); ++col) { - QString s = m_table->text(0, col); + TQString s = m_table->text(0, col); Data::FieldPtr f; if(c) { c->fieldByTitle(s); @@ -489,7 +489,7 @@ void CSVImporter::updateHeader(bool force_) { m_table->horizontalHeader()->setLabel(col, f->title()); m_hasAssignedFields = true; } else { - m_table->horizontalHeader()->setLabel(col, QString::number(col+1)); + m_table->horizontalHeader()->setLabel(col, TQString::number(col+1)); } } } @@ -504,7 +504,7 @@ void CSVImporter::slotFieldChanged(int idx_) { uint count = c->fieldTitles().count(); CollectionFieldsDialog dlg(c, m_widget); // dlg.setModal(true); - if(dlg.exec() == QDialog::Accepted) { + if(dlg.exec() == TQDialog::Accepted) { m_comboField->clear(); m_comboField->insertStringList(c->fieldTitles()); m_comboField->insertItem('<' + i18n("New Field") + '>'); @@ -536,7 +536,7 @@ void CSVImporter::slotActionChanged(int action_) { case Import::Merge: { m_comboColl->clear(); - QString name = CollectionFactory::nameMap()[currColl->type()]; + TQString name = CollectionFactory::nameMap()[currColl->type()]; m_comboColl->insertItem(name, currColl->type()); m_existingCollection = currColl; } |
