diff options
Diffstat (limited to 'src/translators/alexandriaimporter.cpp')
-rw-r--r-- | src/translators/alexandriaimporter.cpp | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/src/translators/alexandriaimporter.cpp b/src/translators/alexandriaimporter.cpp index 5e49e86..2c67408 100644 --- a/src/translators/alexandriaimporter.cpp +++ b/src/translators/alexandriaimporter.cpp @@ -25,9 +25,9 @@ #include <kapplication.h> #include <kstringhandler.h> -#include <qlayout.h> -#include <qlabel.h> -#include <qgroupbox.h> +#include <tqlayout.h> +#include <tqlabel.h> +#include <tqgroupbox.h> using Tellico::Import::AlexandriaImporter; @@ -42,42 +42,42 @@ Tellico::Data::CollPtr AlexandriaImporter::collection() { m_coll = new Data::BookCollection(true); - QDir dataDir = m_libraryDir; + TQDir dataDir = m_libraryDir; dataDir.cd(m_library->currentText()); - dataDir.setFilter(QDir::Files | QDir::Readable | QDir::NoSymLinks); - - const QString title = QString::fromLatin1("title"); - const QString author = QString::fromLatin1("author"); - const QString year = QString::fromLatin1("pub_year"); - const QString binding = QString::fromLatin1("binding"); - const QString isbn = QString::fromLatin1("isbn"); - const QString pub = QString::fromLatin1("publisher"); - const QString rating = QString::fromLatin1("rating"); - const QString cover = QString::fromLatin1("cover"); - const QString comments = QString::fromLatin1("comments"); + dataDir.setFilter(TQDir::Files | TQDir::Readable | TQDir::NoSymLinks); + + const TQString title = TQString::tqfromLatin1("title"); + const TQString author = TQString::tqfromLatin1("author"); + const TQString year = TQString::tqfromLatin1("pub_year"); + const TQString binding = TQString::tqfromLatin1("binding"); + const TQString isbn = TQString::tqfromLatin1("isbn"); + const TQString pub = TQString::tqfromLatin1("publisher"); + const TQString rating = TQString::tqfromLatin1("rating"); + const TQString cover = TQString::tqfromLatin1("cover"); + const TQString comments = TQString::tqfromLatin1("comments"); // start with yaml files - dataDir.setNameFilter(QString::fromLatin1("*.yaml")); - const QStringList files = dataDir.entryList(); + dataDir.setNameFilter(TQString::tqfromLatin1("*.yaml")); + const TQStringList files = dataDir.entryList(); const uint numFiles = files.count(); - const uint stepSize = QMAX(s_stepSize, numFiles/100); + const uint stepSize = TQMAX(s_stepSize, numFiles/100); const bool showProgress = options() & ImportProgress; ProgressItem& item = ProgressManager::self()->newProgressItem(this, progressLabel(), true); item.setTotalSteps(numFiles); - connect(&item, SIGNAL(signalCancelled(ProgressItem*)), SLOT(slotCancel())); + connect(&item, TQT_SIGNAL(signalCancelled(ProgressItem*)), TQT_SLOT(slotCancel())); ProgressItem::Done done(this); - QStringList covers; - covers << QString::fromLatin1(".cover") - << QString::fromLatin1("_medium.jpg") - << QString::fromLatin1("_small.jpg"); + TQStringList covers; + covers << TQString::tqfromLatin1(".cover") + << TQString::tqfromLatin1("_medium.jpg") + << TQString::tqfromLatin1("_small.jpg"); - QTextStream ts; - ts.setEncoding(QTextStream::UnicodeUTF8); // YAML is always utf8? + TQTextStream ts; + ts.setEncoding(TQTextStream::UnicodeUTF8); // YAML is always utf8? uint j = 0; - for(QStringList::ConstIterator it = files.begin(); !m_cancelled && it != files.end(); ++it, ++j) { - QFile file(dataDir.absFilePath(*it)); + for(TQStringList::ConstIterator it = files.begin(); !m_cancelled && it != files.end(); ++it, ++j) { + TQFile file(dataDir.absFilePath(*it)); if(!file.open(IO_ReadOnly)) { continue; } @@ -86,8 +86,8 @@ Tellico::Data::CollPtr AlexandriaImporter::collection() { bool readNextLine = true; ts.unsetDevice(); - ts.setDevice(&file); - QString line; + ts.setDevice(TQT_TQIODEVICE(&file)); + TQString line; while(!ts.atEnd()) { if(readNextLine) { line = ts.readLine(); @@ -95,17 +95,17 @@ Tellico::Data::CollPtr AlexandriaImporter::collection() { readNextLine = true; } // skip the line that starts with --- - if(line.isEmpty() || line.startsWith(QString::fromLatin1("---"))) { + if(line.isEmpty() || line.startsWith(TQString::tqfromLatin1("---"))) { continue; } - if(line.endsWith(QChar('\\'))) { + if(line.endsWith(TQChar('\\'))) { line.truncate(line.length()-1); // remove last character line += ts.readLine(); } cleanLine(line); - QString alexField = line.section(':', 0, 0); - QString alexValue = line.section(':', 1).stripWhiteSpace(); + TQString alexField = line.section(':', 0, 0); + TQString alexValue = line.section(':', 1).stripWhiteSpace(); clean(alexValue); // Alexandria uses "n/a for empty values, and it is translated @@ -115,15 +115,15 @@ Tellico::Data::CollPtr AlexandriaImporter::collection() { } if(alexField == Latin1Literal("authors")) { - QStringList authors; + TQStringList authors; line = ts.readLine(); - QRegExp begin(QString::fromLatin1("^\\s*-\\s+")); - while(!line.isNull() && line.find(begin) > -1) { + TQRegExp begin(TQString::tqfromLatin1("^\\s*-\\s+")); + while(!line.isNull() && line.tqfind(begin) > -1) { line.remove(begin); authors += clean(line); line = ts.readLine(); } - entry->setField(author, authors.join(QString::fromLatin1("; "))); + entry->setField(author, authors.join(TQString::tqfromLatin1("; "))); // the next line has already been read readNextLine = false; @@ -146,12 +146,12 @@ Tellico::Data::CollPtr AlexandriaImporter::collection() { // now find cover image KURL u; alexValue.remove('-'); - for(QStringList::Iterator ext = covers.begin(); ext != covers.end(); ++ext) { + for(TQStringList::Iterator ext = covers.begin(); ext != covers.end(); ++ext) { u.setPath(dataDir.absFilePath(alexValue + *ext)); - if(!QFile::exists(u.path())) { + if(!TQFile::exists(u.path())) { continue; } - QString id = ImageFactory::addImage(u, true); + TQString id = ImageFactory::addImage(u, true); if(!id.isEmpty()) { entry->setField(cover, id); break; @@ -179,27 +179,27 @@ Tellico::Data::CollPtr AlexandriaImporter::collection() { return m_coll; } -QWidget* AlexandriaImporter::widget(QWidget* parent_, const char* name_/*=0*/) { +TQWidget* AlexandriaImporter::widget(TQWidget* tqparent_, const char* name_/*=0*/) { if(m_widget) { return m_widget; } - m_libraryDir = QDir::home(); - m_libraryDir.setFilter(QDir::Dirs | QDir::Readable | QDir::NoSymLinks); + m_libraryDir = TQDir::home(); + m_libraryDir.setFilter(TQDir::Dirs | TQDir::Readable | TQDir::NoSymLinks); - 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* box = new QGroupBox(2, Qt::Horizontal, i18n("Alexandria Options"), m_widget); - QLabel* label = new QLabel(i18n("&Library:"), box); + TQGroupBox* box = new TQGroupBox(2, Qt::Horizontal, i18n("Alexandria Options"), m_widget); + TQLabel* label = new TQLabel(i18n("&Library:"), box); m_library = new KComboBox(box); label->setBuddy(m_library); // .alexandria might not exist - if(m_libraryDir.cd(QString::fromLatin1(".alexandria"))) { - QStringList dirs = m_libraryDir.entryList(); - dirs.remove(QString::fromLatin1(".")); // why can't I tell QDir not to include these? QDir::Hidden doesn't work - dirs.remove(QString::fromLatin1("..")); + if(m_libraryDir.cd(TQString::tqfromLatin1(".alexandria"))) { + TQStringList dirs = m_libraryDir.entryList(); + dirs.remove(TQString::tqfromLatin1(".")); // why can't I tell TQDir not to include these? TQDir::Hidden doesn't work + dirs.remove(TQString::tqfromLatin1("..")); m_library->insertStringList(dirs); } @@ -208,44 +208,44 @@ QWidget* AlexandriaImporter::widget(QWidget* parent_, const char* name_/*=0*/) { return m_widget; } -QString& AlexandriaImporter::cleanLine(QString& str_) { - static QRegExp escRx(QString::fromLatin1("\\\\x(\\w\\w)"), false); - str_.remove(QString::fromLatin1("\\r")); - str_.replace(QString::fromLatin1("\\n"), QString::fromLatin1("\n")); - str_.replace(QString::fromLatin1("\\t"), QString::fromLatin1("\t")); +TQString& AlexandriaImporter::cleanLine(TQString& str_) { + static TQRegExp escRx(TQString::tqfromLatin1("\\\\x(\\w\\w)"), false); + str_.remove(TQString::tqfromLatin1("\\r")); + str_.tqreplace(TQString::tqfromLatin1("\\n"), TQString::tqfromLatin1("\n")); + str_.tqreplace(TQString::tqfromLatin1("\\t"), TQString::tqfromLatin1("\t")); // YAML uses escape sequences like \xC3 int pos = escRx.search(str_); int origPos = pos; - QCString bytes; + TQCString bytes; while(pos > -1) { bool ok; char c = escRx.cap(1).toInt(&ok, 16); if(ok) { bytes += c; } else { - bytes = QCString(); + bytes = TQCString(); break; } pos = escRx.search(str_, pos+1); } if(!bytes.isEmpty()) { - str_.replace(origPos, bytes.length()*4, QString::fromUtf8(bytes.data())); + str_.tqreplace(origPos, bytes.length()*4, TQString::fromUtf8(bytes.data())); } return str_; } -QString& AlexandriaImporter::clean(QString& str_) { - const QRegExp quote(QString::fromLatin1("\\\\\"")); // equals \" - if(str_.startsWith(QChar('\'')) || str_.startsWith(QChar('"'))) { +TQString AlexandriaImporter::clean(TQString& str_) { + const TQRegExp quote(TQString::tqfromLatin1("\\\\\"")); // equals \" + if(str_.startsWith(TQChar('\'')) || str_.startsWith(TQChar('"'))) { str_.remove(0, 1); } - if(str_.endsWith(QChar('\'')) || str_.endsWith(QChar('"'))) { + if(str_.endsWith(TQChar('\'')) || str_.endsWith(TQChar('"'))) { str_.truncate(str_.length()-1); } // we ignore YAML tags, this is not actually a good parser, but will do for now - str_.remove(QRegExp(QString::fromLatin1("^![^\\s]*\\s+"))); - return str_.replace(quote, QChar('"')); + str_.remove(TQRegExp(TQString::tqfromLatin1("^![^\\s]*\\s+"))); + return str_.tqreplace(quote, TQChar('"')); } void AlexandriaImporter::slotCancel() { |