diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-05-17 08:20:48 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-05-17 08:20:48 +0000 |
commit | aa0726b20f398264f0a2abc60215be044b106f9c (patch) | |
tree | 070fdbc19a1106cfdd7f651a8ce76bb1b89a513d /src/softwareimporters.cpp | |
parent | d3cf5b3e75aadc3b02d0b56f030d4c3f8c2c749d (diff) | |
download | basket-aa0726b20f398264f0a2abc60215be044b106f9c.tar.gz basket-aa0726b20f398264f0a2abc60215be044b106f9c.zip |
TQt4 port basket
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/basket@1232416 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/softwareimporters.cpp')
-rw-r--r-- | src/softwareimporters.cpp | 374 |
1 files changed, 187 insertions, 187 deletions
diff --git a/src/softwareimporters.cpp b/src/softwareimporters.cpp index 9f276c7..2c9acb0 100644 --- a/src/softwareimporters.cpp +++ b/src/softwareimporters.cpp @@ -18,17 +18,17 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#include <qstring.h> -#include <qdir.h> +#include <tqstring.h> +#include <tqdir.h> #include <kstandarddirs.h> #include <klocale.h> #include <kfiledialog.h> -#include <qptrstack.h> -#include <qlayout.h> -#include <qvbuttongroup.h> -#include <qradiobutton.h> +#include <tqptrstack.h> +#include <tqlayout.h> +#include <tqvbuttongroup.h> +#include <tqradiobutton.h> #include <kmessagebox.h> -#include <qtextedit.h> +#include <tqtextedit.h> #include "softwareimporters.h" #include "basket.h" @@ -41,17 +41,17 @@ /** class TreeImportDialog: */ -TreeImportDialog::TreeImportDialog(QWidget *parent) +TreeImportDialog::TreeImportDialog(TQWidget *tqparent) : KDialogBase(KDialogBase::Swallow, i18n("Import Hierarchy"), KDialogBase::Ok | KDialogBase::Cancel, - KDialogBase::Ok, parent, /*name=*/"ImportHierarchy", /*modal=*/true, /*separator=*/false) + KDialogBase::Ok, tqparent, /*name=*/"ImportHierarchy", /*modal=*/true, /*separator=*/false) { - QWidget *page = new QWidget(this); - QVBoxLayout *topLayout = new QVBoxLayout(page, /*margin=*/0, spacingHint()); + TQWidget *page = new TQWidget(this); + TQVBoxLayout *topLayout = new TQVBoxLayout(page, /*margin=*/0, spacingHint()); - m_choices = new QVButtonGroup(i18n("How to Import the Notes?"), page); - new QRadioButton(i18n("&Keep original hierarchy (all notes in separate baskets)"), m_choices); - new QRadioButton(i18n("&First level notes in separate baskets"), m_choices); - new QRadioButton(i18n("&All notes in one basket"), m_choices); + m_choices = new TQVButtonGroup(i18n("How to Import the Notes?"), page); + new TQRadioButton(i18n("&Keep original hierarchy (all notes in separate baskets)"), m_choices); + new TQRadioButton(i18n("&First level notes in separate baskets"), m_choices); + new TQRadioButton(i18n("&All notes in one basket"), m_choices); m_choices->setButton(0); topLayout->addWidget(m_choices); topLayout->addStretch(10); @@ -70,33 +70,33 @@ int TreeImportDialog::choice() /** class TextFileImportDialog: */ -TextFileImportDialog::TextFileImportDialog(QWidget *parent) +TextFileImportDialog::TextFileImportDialog(TQWidget *tqparent) : KDialogBase(KDialogBase::Swallow, i18n("Import Text File"), KDialogBase::Ok | KDialogBase::Cancel, - KDialogBase::Ok, parent, /*name=*/"ImportTextFile", /*modal=*/true, /*separator=*/false) + KDialogBase::Ok, tqparent, /*name=*/"ImportTextFile", /*modal=*/true, /*separator=*/false) { - QWidget *page = new QWidget(this); - QVBoxLayout *topLayout = new QVBoxLayout(page, /*margin=*/0, spacingHint()); - - m_choices = new QVButtonGroup(i18n("Format of the Text File"), page); - new QRadioButton(i18n("Notes separated by an &empty line"), m_choices); - new QRadioButton(i18n("One ¬e per line"), m_choices); - new QRadioButton(i18n("Notes begin with a &dash (-)"), m_choices); - new QRadioButton(i18n("Notes begin with a &star (*)"), m_choices); - m_anotherSeparator = new QRadioButton(i18n("&Use another separator:"), m_choices); - - QWidget *indentedTextEdit = new QWidget(m_choices); - QHBoxLayout *hLayout = new QHBoxLayout(indentedTextEdit, /*margin=*/0, spacingHint()); + TQWidget *page = new TQWidget(this); + TQVBoxLayout *topLayout = new TQVBoxLayout(page, /*margin=*/0, spacingHint()); + + m_choices = new TQVButtonGroup(i18n("Format of the Text File"), page); + new TQRadioButton(i18n("Notes separated by an &empty line"), m_choices); + new TQRadioButton(i18n("One ¬e per line"), m_choices); + new TQRadioButton(i18n("Notes begin with a &dash (-)"), m_choices); + new TQRadioButton(i18n("Notes begin with a &star (*)"), m_choices); + m_anotherSeparator = new TQRadioButton(i18n("&Use another separator:"), m_choices); + + TQWidget *indentedTextEdit = new TQWidget(m_choices); + TQHBoxLayout *hLayout = new TQHBoxLayout(indentedTextEdit, /*margin=*/0, spacingHint()); hLayout->addSpacing(20); - m_customSeparator = new QTextEdit(indentedTextEdit); - m_customSeparator->setTextFormat(Qt::PlainText); + m_customSeparator = new TQTextEdit(indentedTextEdit); + m_customSeparator->setTextFormat(TQt::PlainText); hLayout->addWidget(m_customSeparator); - m_choices->insertChild(indentedTextEdit); + m_choices->insertChild(TQT_TQOBJECT(indentedTextEdit)); - new QRadioButton(i18n("&All in one note"), m_choices); + new TQRadioButton(i18n("&All in one note"), m_choices); m_choices->setButton(0); topLayout->addWidget(m_choices); - connect( m_customSeparator, SIGNAL(textChanged()), this, SLOT(customSeparatorChanged()) ); + connect( m_customSeparator, TQT_SIGNAL(textChanged()), this, TQT_SLOT(customSeparatorChanged()) ); setMainWidget(page); } @@ -105,7 +105,7 @@ TextFileImportDialog::~TextFileImportDialog() { } -QString TextFileImportDialog::separator() +TQString TextFileImportDialog::separator() { switch (m_choices->selectedId()) { default: @@ -126,21 +126,21 @@ void TextFileImportDialog::customSeparatorChanged() /** namespace SoftwareImporters: */ -QString SoftwareImporters::fromICS(const QString &ics) +TQString SoftwareImporters::fromICS(const TQString &ics) { - QString result = ics; + TQString result = ics; // Remove escaped '\' characters and append the text to the body int pos = 0; - while ( (pos = result.find('\\', pos)) != -1 ) { + while ( (pos = result.tqfind('\\', pos)) != -1 ) { if ((uint)pos == result.length() - 1) // End of string break; if (result[pos+1] == 'n') { - result.replace(pos, 2, '\n'); + result.tqreplace(pos, 2, '\n'); } else if (result[pos+1] == 'r') { - result.replace(pos, 2, '\r'); + result.tqreplace(pos, 2, '\r'); } else if (result[pos+1] == 't') { - result.replace(pos, 2, '\t'); + result.tqreplace(pos, 2, '\t'); } else if (result[pos] == '\\') { result.remove(pos, 1); // Take care of "\\", "\,", "\;" and other escaped characters I haven't noticed ++pos; @@ -150,60 +150,60 @@ QString SoftwareImporters::fromICS(const QString &ics) return result; } -QString SoftwareImporters::fromTomboy(QString tomboy) +TQString SoftwareImporters::fromTomboy(TQString tomboy) { // The first line is the note title, and we already have it, so we remove it (yes, that's pretty stupid to duplicate it in the content...): - tomboy = tomboy.mid(tomboy.find("\n")).stripWhiteSpace(); + tomboy = tomboy.mid(tomboy.tqfind("\n")).stripWhiteSpace(); // Font styles and decorations: - tomboy.replace("<bold>", "<b>"); - tomboy.replace("</bold>", "</b>"); - tomboy.replace("<italic>", "<i>"); - tomboy.replace("</italic>", "</i>"); - tomboy.replace("<strikethrough>", "<span style='text-decoration: line-through'>"); - tomboy.replace("</strikethrough>", "</span>"); + tomboy.tqreplace("<bold>", "<b>"); + tomboy.tqreplace("</bold>", "</b>"); + tomboy.tqreplace("<italic>", "<i>"); + tomboy.tqreplace("</italic>", "</i>"); + tomboy.tqreplace("<strikethrough>", "<span style='text-decoration: line-through'>"); + tomboy.tqreplace("</strikethrough>", "</span>"); - // Highlight not supported by QTextEdit: - tomboy.replace("<highlight>", "<span style='color:#ff0080'>"); - tomboy.replace("</highlight>", "</span>"); + // Highlight not supported by TQTextEdit: + tomboy.tqreplace("<highlight>", "<span style='color:#ff0080'>"); + tomboy.tqreplace("</highlight>", "</span>"); // Font sizes: - tomboy.replace("<size:small>", "<span style='font-size: 7pt'>"); - tomboy.replace("</size:small>", "</span>"); - tomboy.replace("<size:large>", "<span style='font-size: 16pt'>"); - tomboy.replace("</size:large>", "</span>"); - tomboy.replace("<size:huge>", "<span style='font-size: 20pt'>"); - tomboy.replace("</size:huge>", "</span>"); + tomboy.tqreplace("<size:small>", "<span style='font-size: 7pt'>"); + tomboy.tqreplace("</size:small>", "</span>"); + tomboy.tqreplace("<size:large>", "<span style='font-size: 16pt'>"); + tomboy.tqreplace("</size:large>", "</span>"); + tomboy.tqreplace("<size:huge>", "<span style='font-size: 20pt'>"); + tomboy.tqreplace("</size:huge>", "</span>"); // Internal links to other notes aren't supported yet by BasKet Note Pads: - tomboy.replace("<link:internal>", ""); - tomboy.replace("</link:internal>", ""); + tomboy.tqreplace("<link:internal>", ""); + tomboy.tqreplace("</link:internal>", ""); // In the Tomboy file, new lines are "\n" and not "<br>": - tomboy.replace("\n", "<br>\n"); + tomboy.tqreplace("\n", "<br>\n"); // Preserve consecutive spaces: return "<html><head><meta name=\"qrichtext\" content=\"1\" /></head><body>" + tomboy + "</body></html>"; } -Note* SoftwareImporters::insertTitledNote(Basket *parent, const QString &title, const QString &content, Qt::TextFormat format/* = Qt::PlainText*/, Note *parentNote/* = 0*/) +Note* SoftwareImporters::insertTitledNote(Basket *tqparent, const TQString &title, const TQString &content, TQt::TextFormat format/* = TQt::PlainText*/, Note *tqparentNote/* = 0*/) { - Note *nGroup = new Note(parent); + Note *nGroup = new Note(tqparent); - Note *nTitle = NoteFactory::createNoteText(title, parent); + Note *nTitle = NoteFactory::createNoteText(title, tqparent); nTitle->addState(Tag::stateForId("title")); Note *nContent; - if (format == Qt::PlainText) - nContent = NoteFactory::createNoteText(content, parent); + if (format == TQt::PlainText) + nContent = NoteFactory::createNoteText(content, tqparent); else - nContent = NoteFactory::createNoteHtml(content, parent); + nContent = NoteFactory::createNoteHtml(content, tqparent); - if (parentNote == 0) - parentNote = parent->firstNote(); // In the first column! - parent->insertNote(nGroup, parentNote, Note::BottomColumn, QPoint(), /*animate=*/false); - parent->insertNote(nTitle, nGroup, Note::BottomColumn, QPoint(), /*animate=*/false); - parent->insertNote(nContent, nTitle, Note::BottomInsert, QPoint(), /*animate=*/false); + if (tqparentNote == 0) + tqparentNote = tqparent->firstNote(); // In the first column! + tqparent->insertNote(nGroup, tqparentNote, Note::BottomColumn, TQPoint(), /*animate=*/false); + tqparent->insertNote(nTitle, nGroup, Note::BottomColumn, TQPoint(), /*animate=*/false); + tqparent->insertNote(nContent, nTitle, Note::BottomInsert, TQPoint(), /*animate=*/false); return nGroup; } @@ -216,9 +216,9 @@ void SoftwareImporters::finishImport(Basket *basket) // Focus the FIRST note (the last inserted note is currently focused!): basket->setFocusedNote(basket->firstNoteShownInStack()); - // Relayout every notes at theire new place and simulate a load animation (because already loaded just after the creation). - // Without a relayouting, notes on the bottom would comes from the top (because they were inserted on top) and clutter the animation load: - basket->relayoutNotes(/*animate=*/false); + // Retqlayout every notes at theire new place and simulate a load animation (because already loaded just after the creation). + // Without a retqlayouting, notes on the bottom would comes from the top (because they were inserted on top) and clutter the animation load: + basket->retqlayoutNotes(/*animate=*/false); basket->animateLoad(); basket->save(); } @@ -227,32 +227,32 @@ void SoftwareImporters::finishImport(Basket *basket) void SoftwareImporters::importKJots() { - QString dirPath = locateLocal("appdata","") + "/../kjots/"; // I think the assumption is good - QDir dir(dirPath, QString::null, QDir::Name | QDir::IgnoreCase, QDir::Files | QDir::NoSymLinks); + TQString dirPath = locateLocal("appdata","") + "/../kjots/"; // I think the assumption is good + TQDir dir(dirPath, TQString(), TQDir::Name | TQDir::IgnoreCase, TQDir::Files | TQDir::NoSymLinks); - QStringList list = dir.entryList(); + TQStringList list = dir.entryList(); if (list.isEmpty()) return; - BasketFactory::newBasket(/*icon=*/"kjots", /*name=*/i18n("From KJots"), /*backgroundImage=*/"", /*backgroundColor=*/QColor(), /*textColor=*/QColor(), /*templateName=*/"1column", /*createIn=*/0); + BasketFactory::newBasket(/*icon=*/"kjots", /*name=*/i18n("From KJots"), /*backgroundImage=*/"", /*backgroundColor=*/TQColor(), /*textColor=*/TQColor(), /*templateName=*/"1column", /*createIn=*/0); Basket *kjotsBasket = Global::bnpView->currentBasket(); - for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { // For each file - QFile file(dirPath + *it); + for ( TQStringList::Iterator it = list.begin(); it != list.end(); ++it ) { // For each file + TQFile file(dirPath + *it); if (file.open(IO_ReadOnly)) { - QTextStream stream(&file); - stream.setEncoding(QTextStream::Locale); - QString buf = stream.readLine(); + TQTextStream stream(&file); + stream.setEncoding(TQTextStream::Locale); + TQString buf = stream.readLine(); // IT IS A NOTEBOOK FILE, AT THE VERION 0.6.x and older: if ( !buf.isNull() && buf.left(9) == "\\NewEntry") { // First create a basket for it: - BasketFactory::newBasket(/*icon=*/"kjots", /*name=*/KURL(file.name()).fileName(), /*backgroundImage=*/"", /*backgroundColor=*/QColor(), /*textColor=*/QColor(), /*templateName=*/"1column", /*createIn=*/kjotsBasket); + BasketFactory::newBasket(/*icon=*/"kjots", /*name=*/KURL(file.name()).fileName(), /*backgroundImage=*/"", /*backgroundColor=*/TQColor(), /*textColor=*/TQColor(), /*templateName=*/"1column", /*createIn=*/kjotsBasket); Basket *basket = Global::bnpView->currentBasket(); basket->load(); - QString title, body; + TQString title, body; bool haveAnEntry = false; while (1) { if (buf.left(9) == "\\NewEntry") { @@ -264,7 +264,7 @@ void SoftwareImporters::importKJots() } else if (buf.left(3) != "\\ID") { // Don't care of the ID // Remove escaped '\' characters and append the text to the body int pos = 0; - while ( (pos = buf.find('\\', pos)) != -1 ) + while ( (pos = buf.tqfind('\\', pos)) != -1 ) if (buf[++pos] == '\\') buf.remove(pos, 1); body.append(buf + "\n"); @@ -281,20 +281,20 @@ void SoftwareImporters::importKJots() // IT IS A NOTEBOOK XML FILE, AT THE VERION 0.7.0 and later: } else if ( (*it).endsWith(".book") /*&& !buf.isNull() && (buf.left(2) == "<!" / *<!DOCTYPE...* / || buf.left(2) == "<?" / *<?xml...* /)*/) { - QDomDocument *doc = XMLWork::openFile("KJots", dirPath + *it); + TQDomDocument *doc = XMLWork::openFile("KJots", dirPath + *it); if (doc == 0) continue; - QString bookTitle = XMLWork::getElementText(doc->documentElement(), "KJotsBook/Title"); + TQString bookTitle = XMLWork::getElementText(doc->documentElement(), "KJotsBook/Title"); // First create a basket for it: - BasketFactory::newBasket(/*icon=*/"kjots", /*name=*/bookTitle, /*backgroundImage=*/"", /*backgroundColor=*/QColor(), /*textColor=*/QColor(), /*templateName=*/"1column", /*createIn=*/kjotsBasket); + BasketFactory::newBasket(/*icon=*/"kjots", /*name=*/bookTitle, /*backgroundImage=*/"", /*backgroundColor=*/TQColor(), /*textColor=*/TQColor(), /*templateName=*/"1column", /*createIn=*/kjotsBasket); Basket *basket = Global::bnpView->currentBasket(); basket->load(); - QDomElement docElem = XMLWork::getElement(doc->documentElement(), "KJotsBook"); - for ( QDomNode n = docElem.firstChild(); !n.isNull(); n = n.nextSibling() ) { - QDomElement e = n.toElement(); + TQDomElement docElem = XMLWork::getElement(doc->documentElement(), "KJotsBook"); + for ( TQDomNode n = docElem.firstChild(); !n.isNull(); n = n.nextSibling() ) { + TQDomElement e = n.toElement(); if ( (!e.isNull()) && e.tagName() == "KJotsPage" ) insertTitledNote(basket, XMLWork::getElementText(e, "Title"), XMLWork::getElementText(e, "Text")); } @@ -309,28 +309,28 @@ void SoftwareImporters::importKJots() void SoftwareImporters::importKNotes() { - QString dirPath = locateLocal("appdata","") + "/../knotes/"; // I thing the assumption is good - QDir dir(dirPath, QString::null, QDir::Name | QDir::IgnoreCase, QDir::Files | QDir::NoSymLinks); + TQString dirPath = locateLocal("appdata","") + "/../knotes/"; // I thing the assumption is good + TQDir dir(dirPath, TQString(), TQDir::Name | TQDir::IgnoreCase, TQDir::Files | TQDir::NoSymLinks); - QStringList list = dir.entryList(); - for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { // For each file + TQStringList list = dir.entryList(); + for ( TQStringList::Iterator it = list.begin(); it != list.end(); ++it ) { // For each file if ( ! (*it).endsWith(".ics") ) // Don't process *.ics~ and otehr files continue; - QFile file(dirPath + *it); + TQFile file(dirPath + *it); if (file.open(IO_ReadOnly)) { - QTextStream stream(&file); - stream.setEncoding(QTextStream::UnicodeUTF8); + TQTextStream stream(&file); + stream.setEncoding(TQTextStream::UnicodeUTF8); // First create a basket for it: - BasketFactory::newBasket(/*icon=*/"knotes", /*name=*/i18n("From KNotes"), /*backgroundImage=*/"", /*backgroundColor=*/QColor(), /*textColor=*/QColor(), /*templateName=*/"1column", /*createIn=*/0); + BasketFactory::newBasket(/*icon=*/"knotes", /*name=*/i18n("From KNotes"), /*backgroundImage=*/"", /*backgroundColor=*/TQColor(), /*textColor=*/TQColor(), /*templateName=*/"1column", /*createIn=*/0); Basket *basket = Global::bnpView->currentBasket(); basket->load(); bool inVJournal = false; bool inDescription = false; bool isRichText = false; - QString title, body; - QString buf; + TQString title, body; + TQString buf; while (1) { buf = stream.readLine(); if (buf.isNull()) // OEF @@ -348,7 +348,7 @@ void SoftwareImporters::importKNotes() } else if (buf.startsWith("X-KDE-KNotes-RichText:")) { isRichText = XMLWork::trueOrFalse(buf.mid(22, buf.length() - 22).stripWhiteSpace(), "false"); } else if (buf == "END:VJOURNAL") { - insertTitledNote(basket, fromICS(title), fromICS(body), (isRichText ? Qt::RichText : Qt::PlainText)); + insertTitledNote(basket, fromICS(title), fromICS(body), (isRichText ? TQt::RichText : TQt::PlainText)); inVJournal = false; inDescription = false; isRichText = false; @@ -361,7 +361,7 @@ void SoftwareImporters::importKNotes() // Bouh : duplicate code // In case of unvalide ICAL file! if ( ! body.isEmpty() ) // Add the ending note - insertTitledNote(basket, fromICS(title), fromICS(body), (isRichText ? Qt::RichText : Qt::PlainText)); + insertTitledNote(basket, fromICS(title), fromICS(body), (isRichText ? TQt::RichText : TQt::PlainText)); file.close(); finishImport(basket); } @@ -373,33 +373,33 @@ void SoftwareImporters::importStickyNotes() // Sticky Notes file is usually located in ~/.gnome2/stickynotes_applet // We will search all directories in "~/" that contain "gnome" in the name, // and will search for "stickynotes_applet" file (that should be XML file with <stickynotes> root. - QDir dir(QDir::home().absPath(), QString::null, QDir::Name | QDir::IgnoreCase, - QDir::Dirs | QDir::NoSymLinks | QDir::Hidden); - QStringList founds; - - QStringList list = dir.entryList(); - for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { // For each folder - if ( (*it).contains("gnome", false) ) { - QString fullPath = QDir::home().absPath() + "/" + (*it) + "/stickynotes_applet"; + TQDir dir(TQDir::home().absPath(), TQString(), TQDir::Name | TQDir::IgnoreCase, + TQDir::Dirs | TQDir::NoSymLinks | TQDir::Hidden); + TQStringList founds; + + TQStringList list = dir.entryList(); + for ( TQStringList::Iterator it = list.begin(); it != list.end(); ++it ) { // For each folder + if ( (*it).tqcontains("gnome", false) ) { + TQString fullPath = TQDir::home().absPath() + "/" + (*it) + "/stickynotes_applet"; if (dir.exists(fullPath)) founds += fullPath; } } - for ( QStringList::Iterator it = founds.begin(); it != founds.end(); ++it ) { // For each file - QFile file(*it); - QDomDocument *doc = XMLWork::openFile("stickynotes", *it); + for ( TQStringList::Iterator it = founds.begin(); it != founds.end(); ++it ) { // For each file + TQFile file(*it); + TQDomDocument *doc = XMLWork::openFile("stickynotes", *it); if (doc == 0) continue; // First create a basket for it: - BasketFactory::newBasket(/*icon=*/"gnome", /*name=*/i18n("From Sticky Notes"), /*backgroundImage=*/"", /*backgroundColor=*/QColor(), /*textColor=*/QColor(), /*templateName=*/"1column", /*createIn=*/0); + BasketFactory::newBasket(/*icon=*/"gnome", /*name=*/i18n("From Sticky Notes"), /*backgroundImage=*/"", /*backgroundColor=*/TQColor(), /*textColor=*/TQColor(), /*templateName=*/"1column", /*createIn=*/0); Basket *basket = Global::bnpView->currentBasket(); basket->load(); - QDomElement docElem = doc->documentElement(); - for ( QDomNode n = docElem.firstChild(); !n.isNull(); n = n.nextSibling() ) { - QDomElement e = n.toElement(); + TQDomElement docElem = doc->documentElement(); + for ( TQDomNode n = docElem.firstChild(); !n.isNull(); n = n.nextSibling() ) { + TQDomElement e = n.toElement(); if ( (!e.isNull()) && e.tagName() == "note" ) insertTitledNote(basket, e.attribute("title"), e.text()); } @@ -411,13 +411,13 @@ void SoftwareImporters::importStickyNotes() // TODO: FIXME: Code duplicated from notecontent.cpp but with UTF-8 encoding. // TODO: FIXME: Later, merge! -QString loadUtf8FileToString(const QString &fileName) +TQString loadUtf8FileToString(const TQString &fileName) { - QFile file(fileName); + TQFile file(fileName); if (file.open(IO_ReadOnly)) { - QTextStream stream(&file); - stream.setEncoding(QTextStream::UnicodeUTF8); - QString text; + TQTextStream stream(&file); + stream.setEncoding(TQTextStream::UnicodeUTF8); + TQString text; text = stream.read(); file.close(); return text; @@ -428,41 +428,41 @@ QString loadUtf8FileToString(const QString &fileName) void SoftwareImporters::importTomboy() { - QString dirPath = QDir::home().absPath() + "/.tomboy/"; // I thing the assumption is good - QDir dir(dirPath, QString::null, QDir::Name | QDir::IgnoreCase, QDir::Files | QDir::NoSymLinks); + TQString dirPath = TQDir::home().absPath() + "/.tomboy/"; // I thing the assumption is good + TQDir dir(dirPath, TQString(), TQDir::Name | TQDir::IgnoreCase, TQDir::Files | TQDir::NoSymLinks); Basket *basket = 0; // Create the basket ONLY if we found at least one note to add! - QStringList list = dir.entryList(); - for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { // For each file + TQStringList list = dir.entryList(); + for ( TQStringList::Iterator it = list.begin(); it != list.end(); ++it ) { // For each file if ( ! (*it).endsWith(".note") ) continue; - QDomDocument *doc = XMLWork::openFile("note", dirPath + *it); + TQDomDocument *doc = XMLWork::openFile("note", dirPath + *it); if (doc == 0) continue; if (basket == 0) { // First create a basket for it: - BasketFactory::newBasket(/*icon=*/"tomboy", /*name=*/i18n("From Tomboy"), /*backgroundImage=*/"", /*backgroundColor=*/QColor(), /*textColor=*/QColor(), /*templateName=*/"1column", /*createIn=*/0); + BasketFactory::newBasket(/*icon=*/"tomboy", /*name=*/i18n("From Tomboy"), /*backgroundImage=*/"", /*backgroundColor=*/TQColor(), /*textColor=*/TQColor(), /*templateName=*/"1column", /*createIn=*/0); basket = Global::bnpView->currentBasket(); basket->load(); } - QDomElement docElem = doc->documentElement(); - QString title = XMLWork::getElementText(docElem, "title"); + TQDomElement docElem = doc->documentElement(); + TQString title = XMLWork::getElementText(docElem, "title"); // DOES NOT REALLY WORKS: - //QDomElement contentElement = XMLWork::getElement(docElem, "text/note-content"); - //QString content = XMLWork::innerXml(contentElement); + //TQDomElement contentElement = XMLWork::getElement(docElem, "text/note-content"); + //TQString content = XMLWork::innerXml(contentElement); // Isolate "<note-content version="0.1">CONTENT</note-content>"! - QString xml = loadUtf8FileToString(dirPath + *it); - xml = xml.mid(xml.find("<note-content ")); - xml = xml.mid(xml.find(">") + 1); - xml = xml.mid(0, xml.find("</note-content>")); + TQString xml = loadUtf8FileToString(dirPath + *it); + xml = xml.mid(xml.tqfind("<note-content ")); + xml = xml.mid(xml.tqfind(">") + 1); + xml = xml.mid(0, xml.tqfind("</note-content>")); if (!title.isEmpty() && !/*content*/xml.isEmpty()) - insertTitledNote(basket, title, fromTomboy(xml/*content*/), Qt::RichText); + insertTitledNote(basket, title, fromTomboy(xml/*content*/), TQt::RichText); } if (basket) @@ -471,35 +471,35 @@ void SoftwareImporters::importTomboy() void SoftwareImporters::importTextFile() { - QString fileName = KFileDialog::getOpenFileName(":ImportTextFile", "*|All files"); + TQString fileName = KFileDialog::getOpenFileName(":ImportTextFile", "*|All files"); if (fileName.isEmpty()) return; TextFileImportDialog dialog; - if (dialog.exec() == QDialog::Rejected) + if (dialog.exec() == TQDialog::Rejected) return; - QString separator = dialog.separator(); + TQString separator = dialog.separator(); - QFile file(fileName); + TQFile file(fileName); if (file.open(IO_ReadOnly)) { - QTextStream stream(&file); - stream.setEncoding(QTextStream::Locale); - QString content = stream.read(); - QStringList list = (separator.isEmpty() - ? QStringList(content) - : QStringList::split(separator, content, /*allowEmptyEntries=*/false) + TQTextStream stream(&file); + stream.setEncoding(TQTextStream::Locale); + TQString content = stream.read(); + TQStringList list = (separator.isEmpty() + ? TQStringList(content) + : TQStringList::split(separator, content, /*allowEmptyEntries=*/false) ); // First create a basket for it: - QString title = i18n("From TextFile.txt", "From %1").arg(KURL(fileName).fileName()); - BasketFactory::newBasket(/*icon=*/"txt", title, /*backgroundImage=*/"", /*backgroundColor=*/QColor(), /*textColor=*/QColor(), /*templateName=*/"1column", /*createIn=*/0); + TQString title = i18n("From TextFile.txt", "From %1").tqarg(KURL(fileName).fileName()); + BasketFactory::newBasket(/*icon=*/"txt", title, /*backgroundImage=*/"", /*backgroundColor=*/TQColor(), /*textColor=*/TQColor(), /*templateName=*/"1column", /*createIn=*/0); Basket *basket = Global::bnpView->currentBasket(); basket->load(); // Import every notes: - for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { + for (TQStringList::Iterator it = list.begin(); it != list.end(); ++it ) { Note *note = NoteFactory::createNoteFromText((*it).stripWhiteSpace(), basket); - basket->insertNote(note, basket->firstNote(), Note::BottomColumn, QPoint(), /*animate=*/false); + basket->insertNote(note, basket->firstNote(), Note::BottomColumn, TQPoint(), /*animate=*/false); } // Finish the export: @@ -515,15 +515,15 @@ void SoftwareImporters::importKnowIt() "*.kno|KnowIt files\n*|All files"); if (!url.isEmpty()) { - QFile file(url.path()); - QFileInfo info(url.path()); + TQFile file(url.path()); + TQFileInfo info(url.path()); Basket* basket = 0; - QPtrStack<Basket> baskets; - QString text; + TQPtrStack<Basket> baskets; + TQString text; int hierarchy = 0; TreeImportDialog dialog; - if (dialog.exec() == QDialog::Rejected) + if (dialog.exec() == TQDialog::Rejected) return; hierarchy = dialog.choice(); @@ -531,8 +531,8 @@ void SoftwareImporters::importKnowIt() BasketFactory::newBasket(/*icon=*/"knowit", /*name=*/info.baseName(), /*backgroundImage=*/"", - /*backgroundColor=*/QColor(), - /*textColor=*/QColor(), + /*backgroundColor=*/TQColor(), + /*textColor=*/TQColor(), /*templateName=*/"1column", /*createIn=*/0); basket = Global::bnpView->currentBasket(); @@ -541,14 +541,14 @@ void SoftwareImporters::importKnowIt() if(file.open(IO_ReadOnly)) { - QTextStream stream(&file); + TQTextStream stream(&file); uint level = 0; - QString name; - QString line; - QStringList links; - QStringList descriptions; + TQString name; + TQString line; + TQStringList links; + TQStringList descriptions; - stream.setEncoding(QTextStream::UnicodeUTF8); + stream.setEncoding(TQTextStream::UnicodeUTF8); while(1) { line = stream.readLine(); @@ -569,8 +569,8 @@ void SoftwareImporters::importKnowIt() BasketFactory::newBasket(/*icon=*/"knowit", /*name=*/name, /*backgroundImage=*/"", - /*backgroundColor=*/QColor(), - /*textColor=*/QColor(), + /*backgroundColor=*/TQColor(), + /*textColor=*/TQColor(), /*templateName=*/"1column", /*createIn=*/baskets.top()); basket = Global::bnpView->currentBasket(); @@ -581,7 +581,7 @@ void SoftwareImporters::importKnowIt() hierarchy == 2 || (hierarchy == 1 && level > 0)) { - insertTitledNote(basket, name, text, Qt::RichText); + insertTitledNote(basket, name, text, TQt::RichText); } for(uint j = 0; j < links.count(); ++j) { @@ -598,8 +598,8 @@ void SoftwareImporters::importKnowIt() if(stream.atEnd()) break; - int i = line.find("Entry") + 6; - int n = line.find(' ', i); + int i = line.tqfind("Entry") + 6; + int n = line.tqfind(' ', i); level = line.mid(i, n - i).toInt(); name = line.mid(n+1); text = ""; @@ -628,39 +628,39 @@ void SoftwareImporters::importKnowIt() void SoftwareImporters::importTuxCards() { - QString fileName = KFileDialog::getOpenFileName(":ImportTuxCards", "*|All files"); + TQString fileName = KFileDialog::getOpenFileName(":ImportTuxCards", "*|All files"); if (fileName.isEmpty()) return; TreeImportDialog dialog; - if (dialog.exec() == QDialog::Rejected) + if (dialog.exec() == TQDialog::Rejected) return; int hierarchy = dialog.choice(); - QDomDocument *document = XMLWork::openFile("tuxcards_data_file"/*"InformationCollection"*/, fileName); + TQDomDocument *document = XMLWork::openFile("tuxcards_data_file"/*"InformationCollection"*/, fileName); if (document == 0) { KMessageBox::error(0, i18n("Can not import that file. It is either corrupted or not a TuxCards file."), i18n("Bad File Format")); return; } - QDomElement collection = document->documentElement(); + TQDomElement collection = document->documentElement(); int remainingHierarchy = (hierarchy == 0 ? 65000 : 3 - hierarchy); - importTuxCardsNode(collection, /*parentBasket=*/0, /*parentNote=*/0, remainingHierarchy); + importTuxCardsNode(collection, /*tqparentBasket=*/0, /*tqparentNote=*/0, remainingHierarchy); } // TODO: <InformationElement isOpen="true" isEncripted="false" -void SoftwareImporters::importTuxCardsNode(const QDomElement &element, Basket *parentBasket, Note *parentNote, int remainingHierarchy) +void SoftwareImporters::importTuxCardsNode(const TQDomElement &element, Basket *tqparentBasket, Note *tqparentNote, int remainingHierarchy) { - for (QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling()) { - QDomElement e = n.toElement(); + for (TQDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling()) { + TQDomElement e = n.toElement(); if (e.isNull() || e.tagName() != "InformationElement") // Cannot handle that! continue; - QString icon = e.attribute("iconFileName"); - QString name = XMLWork::getElementText(e, "Description"); - QString content = XMLWork::getElementText(e, "Information"); + TQString icon = e.attribute("iconFileName"); + TQString name = XMLWork::getElementText(e, "Description"); + TQString content = XMLWork::getElementText(e, "Information"); bool isRichText = (e.attribute("informationFormat") == "RTF"); bool isEncrypted = (e.attribute("isEncripted") == "true"); if (icon.isEmpty() || icon == "none") @@ -674,7 +674,7 @@ void SoftwareImporters::importTuxCardsNode(const QDomElement &element, Basket *p } if (remainingHierarchy > 0) { - BasketFactory::newBasket(icon, name, /*backgroundImage=*/"", /*backgroundColor=*/QColor(), /*textColor=*/QColor(), /*templateName=*/"1column", parentBasket); + BasketFactory::newBasket(icon, name, /*backgroundImage=*/"", /*backgroundColor=*/TQColor(), /*textColor=*/TQColor(), /*templateName=*/"1column", tqparentBasket); Basket *basket = Global::bnpView->currentBasket(); basket->load(); @@ -682,13 +682,13 @@ void SoftwareImporters::importTuxCardsNode(const QDomElement &element, Basket *p nContent = NoteFactory::createNoteHtml(content, basket); else nContent = NoteFactory::createNoteText(content, basket); - basket->insertNote(nContent, basket->firstNote(), Note::BottomColumn, QPoint(), /*animate=*/false); + basket->insertNote(nContent, basket->firstNote(), Note::BottomColumn, TQPoint(), /*animate=*/false); importTuxCardsNode(e, basket, 0, remainingHierarchy - 1); finishImport(basket); } else { - Note *nGroup = insertTitledNote(parentBasket, name, content, (isRichText ? Qt::RichText : Qt::PlainText), parentNote); - importTuxCardsNode(e, parentBasket, nGroup, remainingHierarchy - 1); + Note *nGroup = insertTitledNote(tqparentBasket, name, content, (isRichText ? TQt::RichText : TQt::PlainText), tqparentNote); + importTuxCardsNode(e, tqparentBasket, nGroup, remainingHierarchy - 1); } } } |