diff options
Diffstat (limited to 'src/translators/tellicoxmlexporter.cpp')
-rw-r--r-- | src/translators/tellicoxmlexporter.cpp | 166 |
1 files changed, 83 insertions, 83 deletions
diff --git a/src/translators/tellicoxmlexporter.cpp b/src/translators/tellicoxmlexporter.cpp index 221a11b..8f71140 100644 --- a/src/translators/tellicoxmlexporter.cpp +++ b/src/translators/tellicoxmlexporter.cpp @@ -33,12 +33,12 @@ #include <kglobal.h> #include <kcalendarsystem.h> -#include <tqlayout.h> +#include <layout.h> #include <tqgroupbox.h> #include <tqcheckbox.h> #include <tqwhatsthis.h> #include <tqdom.h> -#include <tqtextcodec.h> +#include <textcodec.h> using Tellico::Export::TellicoXMLExporter; @@ -78,29 +78,29 @@ TQDomDocument TellicoXMLExporter::exportXML() const { : XML::syntaxVersion; TQDomImplementation impl; - TQDomDocumentType doctype = impl.createDocumentType(TQString::tqfromLatin1("tellico"), + TQDomDocumentType doctype = impl.createDocumentType(TQString::fromLatin1("tellico"), XML::pubTellico(exportVersion), XML::dtdTellico(exportVersion)); //default namespace const TQString& ns = XML::nsTellico; - TQDomDocument dom = impl.createDocument(ns, TQString::tqfromLatin1("tellico"), doctype); + TQDomDocument dom = impl.createDocument(ns, TQString::fromLatin1("tellico"), doctype); // root tellico element TQDomElement root = dom.documentElement(); - TQString encodeStr = TQString::tqfromLatin1("version=\"1.0\" encoding=\""); + TQString encodeStr = TQString::fromLatin1("version=\"1.0\" encoding=\""); if(options() & Export::ExportUTF8) { - encodeStr += TQString::tqfromLatin1("UTF-8"); + encodeStr += TQString::fromLatin1("UTF-8"); } else { - encodeStr += TQString::tqfromLatin1(TQTextCodec::codecForLocale()->mimeName()); + encodeStr += TQString::fromLatin1(TQTextCodec::codecForLocale()->mimeName()); } encodeStr += TQChar('"'); // createDocument creates a root node, insert the processing instruction before it - dom.insertBefore(dom.createProcessingInstruction(TQString::tqfromLatin1("xml"), encodeStr), root); + dom.insertBefore(dom.createProcessingInstruction(TQString::fromLatin1("xml"), encodeStr), root); - root.setAttribute(TQString::tqfromLatin1("syntaxVersion"), exportVersion); + root.setAttribute(TQString::fromLatin1("syntaxVersion"), exportVersion); exportCollectionXML(dom, root, options() & Export::ExportFormatted); @@ -121,11 +121,11 @@ void TellicoXMLExporter::exportCollectionXML(TQDomDocument& dom_, TQDomElement& return; } - TQDomElement collElem = dom_.createElement(TQString::tqfromLatin1("collection")); - collElem.setAttribute(TQString::tqfromLatin1("type"), coll->type()); - collElem.setAttribute(TQString::tqfromLatin1("title"), coll->title()); + TQDomElement collElem = dom_.createElement(TQString::fromLatin1("collection")); + collElem.setAttribute(TQString::fromLatin1("type"), coll->type()); + collElem.setAttribute(TQString::fromLatin1("title"), coll->title()); - TQDomElement fieldsElem = dom_.createElement(TQString::tqfromLatin1("fields")); + TQDomElement fieldsElem = dom_.createElement(TQString::fromLatin1("fields")); collElem.appendChild(fieldsElem); Data::FieldVec fields = coll->fields(); @@ -136,16 +136,16 @@ void TellicoXMLExporter::exportCollectionXML(TQDomDocument& dom_, TQDomElement& if(coll->type() == Data::Collection::Bibtex) { const Data::BibtexCollection* c = static_cast<const Data::BibtexCollection*>(coll.data()); if(!c->preamble().isEmpty()) { - TQDomElement preElem = dom_.createElement(TQString::tqfromLatin1("bibtex-preamble")); + TQDomElement preElem = dom_.createElement(TQString::fromLatin1("bibtex-preamble")); preElem.appendChild(dom_.createTextNode(c->preamble())); collElem.appendChild(preElem); } - TQDomElement macrosElem = dom_.createElement(TQString::tqfromLatin1("macros")); + TQDomElement macrosElem = dom_.createElement(TQString::fromLatin1("macros")); for(StringMap::ConstIterator macroIt = c->macroList().constBegin(); macroIt != c->macroList().constEnd(); ++macroIt) { if(!macroIt.data().isEmpty()) { - TQDomElement macroElem = dom_.createElement(TQString::tqfromLatin1("macro")); - macroElem.setAttribute(TQString::tqfromLatin1("name"), macroIt.key()); + TQDomElement macroElem = dom_.createElement(TQString::fromLatin1("macro")); + macroElem.setAttribute(TQString::fromLatin1("name"), macroIt.key()); macroElem.appendChild(dom_.createTextNode(macroIt.data())); macrosElem.appendChild(macroElem); } @@ -161,7 +161,7 @@ void TellicoXMLExporter::exportCollectionXML(TQDomDocument& dom_, TQDomElement& } if(!m_images.isEmpty() && (options() & Export::ExportImages)) { - TQDomElement imgsElem = dom_.createElement(TQString::tqfromLatin1("images")); + TQDomElement imgsElem = dom_.createElement(TQString::fromLatin1("images")); collElem.appendChild(imgsElem); const TQStringList imageIds = m_images.toList(); for(TQStringList::ConstIterator it = imageIds.begin(); it != imageIds.end(); ++it) { @@ -177,7 +177,7 @@ void TellicoXMLExporter::exportCollectionXML(TQDomDocument& dom_, TQDomElement& // the borrowers and filters are in the tellico object, not the collection if(options() & Export::ExportComplete) { - TQDomElement bElem = dom_.createElement(TQString::tqfromLatin1("borrowers")); + TQDomElement bElem = dom_.createElement(TQString::fromLatin1("borrowers")); Data::BorrowerVec borrowers = coll->borrowers(); for(Data::BorrowerVec::Iterator bIt = borrowers.begin(); bIt != borrowers.end(); ++bIt) { exportBorrowerXML(dom_, bElem, bIt); @@ -186,7 +186,7 @@ void TellicoXMLExporter::exportCollectionXML(TQDomDocument& dom_, TQDomElement& parent_.appendChild(bElem); } - TQDomElement fElem = dom_.createElement(TQString::tqfromLatin1("filters")); + TQDomElement fElem = dom_.createElement(TQString::fromLatin1("filters")); FilterVec filters = coll->filters(); for(FilterVec::Iterator fIt = filters.begin(); fIt != filters.end(); ++fIt) { exportFilterXML(dom_, fElem, fIt); @@ -198,31 +198,31 @@ void TellicoXMLExporter::exportCollectionXML(TQDomDocument& dom_, TQDomElement& } void TellicoXMLExporter::exportFieldXML(TQDomDocument& dom_, TQDomElement& parent_, Data::FieldPtr field_) const { - TQDomElement elem = dom_.createElement(TQString::tqfromLatin1("field")); + TQDomElement elem = dom_.createElement(TQString::fromLatin1("field")); - elem.setAttribute(TQString::tqfromLatin1("name"), field_->name()); - elem.setAttribute(TQString::tqfromLatin1("title"), field_->title()); - elem.setAttribute(TQString::tqfromLatin1("category"), field_->category()); - elem.setAttribute(TQString::tqfromLatin1("type"), field_->type()); - elem.setAttribute(TQString::tqfromLatin1("flags"), field_->flags()); - elem.setAttribute(TQString::tqfromLatin1("format"), field_->formatFlag()); + elem.setAttribute(TQString::fromLatin1("name"), field_->name()); + elem.setAttribute(TQString::fromLatin1("title"), field_->title()); + elem.setAttribute(TQString::fromLatin1("category"), field_->category()); + elem.setAttribute(TQString::fromLatin1("type"), field_->type()); + elem.setAttribute(TQString::fromLatin1("flags"), field_->flags()); + elem.setAttribute(TQString::fromLatin1("format"), field_->formatFlag()); if(field_->type() == Data::Field::Choice) { - elem.setAttribute(TQString::tqfromLatin1("allowed"), field_->allowed().join(TQString::tqfromLatin1(";"))); + elem.setAttribute(TQString::fromLatin1("allowed"), field_->allowed().join(TQString::fromLatin1(";"))); } // only save description if it's not equal to title, which is the default // title is never empty, so this indirectly checks for empty descriptions if(field_->description() != field_->title()) { - elem.setAttribute(TQString::tqfromLatin1("description"), field_->description()); + elem.setAttribute(TQString::fromLatin1("description"), field_->description()); } for(StringMap::ConstIterator it = field_->propertyList().begin(); it != field_->propertyList().end(); ++it) { if(it.data().isEmpty()) { continue; } - TQDomElement e = dom_.createElement(TQString::tqfromLatin1("prop")); - e.setAttribute(TQString::tqfromLatin1("name"), it.key()); + TQDomElement e = dom_.createElement(TQString::fromLatin1("prop")); + e.setAttribute(TQString::fromLatin1("name"), it.key()); e.appendChild(dom_.createTextNode(it.data())); elem.appendChild(e); } @@ -231,8 +231,8 @@ void TellicoXMLExporter::exportFieldXML(TQDomDocument& dom_, TQDomElement& paren } void TellicoXMLExporter::exportEntryXML(TQDomDocument& dom_, TQDomElement& parent_, Data::EntryPtr entry_, bool format_) const { - TQDomElement entryElem = dom_.createElement(TQString::tqfromLatin1("entry")); - entryElem.setAttribute(TQString::tqfromLatin1("id"), entry_->id()); + TQDomElement entryElem = dom_.createElement(TQString::fromLatin1("entry")); + entryElem.setAttribute(TQString::fromLatin1("id"), entry_->id()); // iterate through every field for the entry Data::FieldVec fields = entry_->collection()->fields(); @@ -268,7 +268,7 @@ void TellicoXMLExporter::exportEntryXML(TQDomDocument& dom_, TQDomElement& paren entryElem.appendChild(parElem); // the space after the semi-colon is enforced when the field is set for the entry - TQStringList fields = TQStringList::split(TQString::tqfromLatin1("; "), fieldValue, true); + TQStringList fields = TQStringList::split(TQString::fromLatin1("; "), fieldValue, true); for(TQStringList::ConstIterator it = fields.begin(); it != fields.end(); ++it) { // element for field value, child of either entryElem or ParentElem TQDomElement fieldElem = dom_.createElement(fieldName); @@ -276,7 +276,7 @@ void TellicoXMLExporter::exportEntryXML(TQDomDocument& dom_, TQDomElement& paren int ncols = 0; if(fIt->type() == Data::Field::Table) { bool ok; - ncols = Tellico::toUInt(fIt->property(TQString::tqfromLatin1("columns")), &ok); + ncols = Tellico::toUInt(fIt->property(TQString::fromLatin1("columns")), &ok); if(!ok) { ncols = 1; } @@ -284,8 +284,8 @@ void TellicoXMLExporter::exportEntryXML(TQDomDocument& dom_, TQDomElement& paren if(ncols > 1) { for(int col = 0; col < ncols; ++col) { TQDomElement elem; - elem = dom_.createElement(TQString::tqfromLatin1("column")); - elem.appendChild(dom_.createTextNode((*it).section(TQString::tqfromLatin1("::"), col, col))); + elem = dom_.createElement(TQString::fromLatin1("column")); + elem.appendChild(dom_.createTextNode((*it).section(TQString::fromLatin1("::"), col, col))); fieldElem.appendChild(elem); } } else { @@ -298,25 +298,25 @@ void TellicoXMLExporter::exportEntryXML(TQDomDocument& dom_, TQDomElement& paren entryElem.appendChild(fieldElem); // Date fields get special treatment if(fIt->type() == Data::Field::Date) { - fieldElem.setAttribute(TQString::tqfromLatin1("calendar"), KGlobal::locale()->calendar()->calendarName()); + fieldElem.setAttribute(TQString::fromLatin1("calendar"), KGlobal::locale()->calendar()->calendarName()); TQStringList s = TQStringList::split('-', fieldValue, true); if(s.count() > 0 && !s[0].isEmpty()) { - TQDomElement e = dom_.createElement(TQString::tqfromLatin1("year")); + TQDomElement e = dom_.createElement(TQString::fromLatin1("year")); fieldElem.appendChild(e); e.appendChild(dom_.createTextNode(s[0])); } if(s.count() > 1 && !s[1].isEmpty()) { - TQDomElement e = dom_.createElement(TQString::tqfromLatin1("month")); + TQDomElement e = dom_.createElement(TQString::fromLatin1("month")); fieldElem.appendChild(e); e.appendChild(dom_.createTextNode(s[1])); } if(s.count() > 2 && !s[2].isEmpty()) { - TQDomElement e = dom_.createElement(TQString::tqfromLatin1("day")); + TQDomElement e = dom_.createElement(TQString::fromLatin1("day")); fieldElem.appendChild(e); e.appendChild(dom_.createTextNode(s[2])); } } else if(fIt->type() == Data::Field::URL && - fIt->property(TQString::tqfromLatin1("relative")) == Latin1Literal("true") && + fIt->property(TQString::fromLatin1("relative")) == Latin1Literal("true") && !url().isEmpty()) { // if a relative URL and url() is not empty, change the value! KURL old_url(Kernel::self()->URL(), fieldValue); @@ -343,35 +343,35 @@ void TellicoXMLExporter::exportImageXML(TQDomDocument& dom_, TQDomElement& paren } // myLog() << "TellicoXMLExporter::exportImageXML() - id = " << id_ << endl; - TQDomElement imgElem = dom_.createElement(TQString::tqfromLatin1("image")); + TQDomElement imgElem = dom_.createElement(TQString::fromLatin1("image")); if(m_includeImages) { const Data::Image& img = ImageFactory::imageById(id_); if(img.isNull()) { myDebug() << "TellicoXMLExporter::exportImageXML() - null image - " << id_ << endl; return; } - imgElem.setAttribute(TQString::tqfromLatin1("format"), img.format().data()); - imgElem.setAttribute(TQString::tqfromLatin1("id"), img.id()); - imgElem.setAttribute(TQString::tqfromLatin1("width"), img.width()); - imgElem.setAttribute(TQString::tqfromLatin1("height"), img.height()); + imgElem.setAttribute(TQString::fromLatin1("format"), img.format().data()); + imgElem.setAttribute(TQString::fromLatin1("id"), img.id()); + imgElem.setAttribute(TQString::fromLatin1("width"), img.width()); + imgElem.setAttribute(TQString::fromLatin1("height"), img.height()); if(img.linkOnly()) { - imgElem.setAttribute(TQString::tqfromLatin1("link"), TQString::tqfromLatin1("true")); + imgElem.setAttribute(TQString::fromLatin1("link"), TQString::fromLatin1("true")); } TQCString imgText = KCodecs::base64Encode(img.byteArray()); - imgElem.appendChild(dom_.createTextNode(TQString::tqfromLatin1(imgText))); + imgElem.appendChild(dom_.createTextNode(TQString::fromLatin1(imgText))); } else { const Data::ImageInfo& info = ImageFactory::imageInfo(id_); if(info.isNull()) { return; } - imgElem.setAttribute(TQString::tqfromLatin1("format"), info.format.data()); - imgElem.setAttribute(TQString::tqfromLatin1("id"), info.id); + imgElem.setAttribute(TQString::fromLatin1("format"), info.format.data()); + imgElem.setAttribute(TQString::fromLatin1("id"), info.id); // only load the images to read the size if necessary const bool loadImageIfNecessary = options() & Export::ExportImageSize; - imgElem.setAttribute(TQString::tqfromLatin1("width"), info.width(loadImageIfNecessary)); - imgElem.setAttribute(TQString::tqfromLatin1("height"), info.height(loadImageIfNecessary)); + imgElem.setAttribute(TQString::fromLatin1("width"), info.width(loadImageIfNecessary)); + imgElem.setAttribute(TQString::fromLatin1("height"), info.height(loadImageIfNecessary)); if(info.linkOnly) { - imgElem.setAttribute(TQString::tqfromLatin1("link"), TQString::tqfromLatin1("true")); + imgElem.setAttribute(TQString::fromLatin1("link"), TQString::fromLatin1("true")); } } parent_.appendChild(imgElem); @@ -380,21 +380,21 @@ void TellicoXMLExporter::exportImageXML(TQDomDocument& dom_, TQDomElement& paren void TellicoXMLExporter::exportGroupXML(TQDomDocument& dom_, TQDomElement& parent_) const { Data::EntryVec vec = entries(); // need a copy for ::contains(); bool exportAll = collection()->entries().count() == vec.count(); - // iterate over each group, which are the first tqchildren + // iterate over each group, which are the first children for(GroupIterator gIt = Controller::self()->groupIterator(); gIt.group(); ++gIt) { if(gIt.group()->isEmpty()) { continue; } - TQDomElement groupElem = dom_.createElement(TQString::tqfromLatin1("group")); - groupElem.setAttribute(TQString::tqfromLatin1("title"), gIt.group()->groupName()); + TQDomElement groupElem = dom_.createElement(TQString::fromLatin1("group")); + groupElem.setAttribute(TQString::fromLatin1("title"), gIt.group()->groupName()); // now iterate over all entry items in the group Data::EntryVec sorted = Data::Document::self()->sortEntries(*gIt.group()); for(Data::EntryVec::Iterator eIt = sorted.begin(); eIt != sorted.end(); ++eIt) { if(!exportAll && !vec.contains(eIt)) { continue; } - TQDomElement entryRefElem = dom_.createElement(TQString::tqfromLatin1("entryRef")); - entryRefElem.setAttribute(TQString::tqfromLatin1("id"), eIt->id()); + TQDomElement entryRefElem = dom_.createElement(TQString::fromLatin1("entryRef")); + entryRefElem.setAttribute(TQString::fromLatin1("id"), eIt->id()); groupElem.appendChild(entryRefElem); } if(groupElem.hasChildNodes()) { @@ -404,34 +404,34 @@ void TellicoXMLExporter::exportGroupXML(TQDomDocument& dom_, TQDomElement& paren } void TellicoXMLExporter::exportFilterXML(TQDomDocument& dom_, TQDomElement& parent_, FilterPtr filter_) const { - TQDomElement filterElem = dom_.createElement(TQString::tqfromLatin1("filter")); - filterElem.setAttribute(TQString::tqfromLatin1("name"), filter_->name()); + TQDomElement filterElem = dom_.createElement(TQString::fromLatin1("filter")); + filterElem.setAttribute(TQString::fromLatin1("name"), filter_->name()); - TQString match = (filter_->op() == Filter::MatchAll) ? TQString::tqfromLatin1("all") : TQString::tqfromLatin1("any"); - filterElem.setAttribute(TQString::tqfromLatin1("match"), match); + TQString match = (filter_->op() == Filter::MatchAll) ? TQString::fromLatin1("all") : TQString::fromLatin1("any"); + filterElem.setAttribute(TQString::fromLatin1("match"), match); for(TQPtrListIterator<FilterRule> it(*filter_); it.current(); ++it) { - TQDomElement ruleElem = dom_.createElement(TQString::tqfromLatin1("rule")); - ruleElem.setAttribute(TQString::tqfromLatin1("field"), it.current()->fieldName()); - ruleElem.setAttribute(TQString::tqfromLatin1("pattern"), it.current()->pattern()); + TQDomElement ruleElem = dom_.createElement(TQString::fromLatin1("rule")); + ruleElem.setAttribute(TQString::fromLatin1("field"), it.current()->fieldName()); + ruleElem.setAttribute(TQString::fromLatin1("pattern"), it.current()->pattern()); switch(it.current()->function()) { case FilterRule::FuncContains: - ruleElem.setAttribute(TQString::tqfromLatin1("function"), TQString::tqfromLatin1("contains")); + ruleElem.setAttribute(TQString::fromLatin1("function"), TQString::fromLatin1("contains")); break; case FilterRule::FuncNotContains: - ruleElem.setAttribute(TQString::tqfromLatin1("function"), TQString::tqfromLatin1("notcontains")); + ruleElem.setAttribute(TQString::fromLatin1("function"), TQString::fromLatin1("notcontains")); break; case FilterRule::FuncEquals: - ruleElem.setAttribute(TQString::tqfromLatin1("function"), TQString::tqfromLatin1("equals")); + ruleElem.setAttribute(TQString::fromLatin1("function"), TQString::fromLatin1("equals")); break; case FilterRule::FuncNotEquals: - ruleElem.setAttribute(TQString::tqfromLatin1("function"), TQString::tqfromLatin1("notequals")); + ruleElem.setAttribute(TQString::fromLatin1("function"), TQString::fromLatin1("notequals")); break; case FilterRule::FuncRegExp: - ruleElem.setAttribute(TQString::tqfromLatin1("function"), TQString::tqfromLatin1("regexp")); + ruleElem.setAttribute(TQString::fromLatin1("function"), TQString::fromLatin1("regexp")); break; case FilterRule::FuncNotRegExp: - ruleElem.setAttribute(TQString::tqfromLatin1("function"), TQString::tqfromLatin1("notregexp")); + ruleElem.setAttribute(TQString::fromLatin1("function"), TQString::fromLatin1("notregexp")); break; default: kdWarning() << "TellicoXMLExporter::exportFilterXML() - no matching rule function!" << endl; @@ -448,23 +448,23 @@ void TellicoXMLExporter::exportBorrowerXML(TQDomDocument& dom_, TQDomElement& pa return; } - TQDomElement bElem = dom_.createElement(TQString::tqfromLatin1("borrower")); + TQDomElement bElem = dom_.createElement(TQString::fromLatin1("borrower")); parent_.appendChild(bElem); - bElem.setAttribute(TQString::tqfromLatin1("name"), borrower_->name()); - bElem.setAttribute(TQString::tqfromLatin1("uid"), borrower_->uid()); + bElem.setAttribute(TQString::fromLatin1("name"), borrower_->name()); + bElem.setAttribute(TQString::fromLatin1("uid"), borrower_->uid()); const Data::LoanVec& loans = borrower_->loans(); for(Data::LoanVec::ConstIterator it = loans.constBegin(); it != loans.constEnd(); ++it) { - TQDomElement lElem = dom_.createElement(TQString::tqfromLatin1("loan")); + TQDomElement lElem = dom_.createElement(TQString::fromLatin1("loan")); bElem.appendChild(lElem); - lElem.setAttribute(TQString::tqfromLatin1("uid"), it->uid()); - lElem.setAttribute(TQString::tqfromLatin1("entryRef"), it->entry()->id()); - lElem.setAttribute(TQString::tqfromLatin1("loanDate"), it->loanDate().toString(Qt::ISODate)); - lElem.setAttribute(TQString::tqfromLatin1("dueDate"), it->dueDate().toString(Qt::ISODate)); + lElem.setAttribute(TQString::fromLatin1("uid"), it->uid()); + lElem.setAttribute(TQString::fromLatin1("entryRef"), it->entry()->id()); + lElem.setAttribute(TQString::fromLatin1("loanDate"), it->loanDate().toString(Qt::ISODate)); + lElem.setAttribute(TQString::fromLatin1("dueDate"), it->dueDate().toString(Qt::ISODate)); if(it->inCalendar()) { - lElem.setAttribute(TQString::tqfromLatin1("calendar"), TQString::tqfromLatin1("true")); + lElem.setAttribute(TQString::fromLatin1("calendar"), TQString::fromLatin1("true")); } lElem.appendChild(dom_.createTextNode(it->note())); @@ -491,14 +491,14 @@ TQWidget* TellicoXMLExporter::widget(TQWidget* parent_, const char* name_/*=0*/) } void TellicoXMLExporter::readOptions(KConfig* config_) { - KConfigGroup group(config_, TQString::tqfromLatin1("ExportOptions - %1").tqarg(formatString())); + KConfigGroup group(config_, TQString::fromLatin1("ExportOptions - %1").arg(formatString())); m_includeImages = group.readBoolEntry("Include Images", m_includeImages); } void TellicoXMLExporter::saveOptions(KConfig* config_) { m_includeImages = m_checkIncludeImages->isChecked(); - KConfigGroup group(config_, TQString::tqfromLatin1("ExportOptions - %1").tqarg(formatString())); + KConfigGroup group(config_, TQString::fromLatin1("ExportOptions - %1").arg(formatString())); group.writeEntry("Include Images", m_includeImages); } |