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/archive.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/archive.cpp')
-rw-r--r-- | src/archive.cpp | 302 |
1 files changed, 151 insertions, 151 deletions
diff --git a/src/archive.cpp b/src/archive.cpp index 7365501..6541a8e 100644 --- a/src/archive.cpp +++ b/src/archive.cpp @@ -18,16 +18,16 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#include <qstring.h> -#include <qstringlist.h> -#include <qvaluelist.h> -#include <qmap.h> -#include <qdir.h> +#include <tqstring.h> +#include <tqstringlist.h> +#include <tqvaluelist.h> +#include <tqmap.h> +#include <tqdir.h> #include <ktar.h> -#include <qdom.h> +#include <tqdom.h> #include <kmessagebox.h> -#include <qpixmap.h> -#include <qpainter.h> +#include <tqpixmap.h> +#include <tqpainter.h> #include <kstandarddirs.h> #include <kapplication.h> #include <kiconloader.h> @@ -48,9 +48,9 @@ #include <iostream> -void Archive::save(Basket *basket, bool withSubBaskets, const QString &destination) +void Archive::save(Basket *basket, bool withSubBaskets, const TQString &destination) { - QDir dir; + TQDir dir; KProgressDialog dialog(0, 0, i18n("Save as Basket Archive"), i18n("Saving as basket archive. Please wait..."), /*Not modal, for password dialogs!*/false); dialog.showCancelButton(false); @@ -61,11 +61,11 @@ void Archive::save(Basket *basket, bool withSubBaskets, const QString &destinati progress->setValue(0); // Create the temporar folder: - QString tempFolder = Global::savesFolder() + "temp-archive/"; + TQString tempFolder = Global::savesFolder() + "temp-archive/"; dir.mkdir(tempFolder); // Create the temporar archive file: - QString tempDestination = tempFolder + "temp-archive.tar.gz"; + TQString tempDestination = tempFolder + "temp-archive.tar.gz"; KTar tar(tempDestination, "application/x-gzip"); tar.open(IO_WriteOnly); tar.writeDir("baskets", "", ""); @@ -74,12 +74,12 @@ void Archive::save(Basket *basket, bool withSubBaskets, const QString &destinati std::cout << "Preparation finished out of " << progress->totalSteps() << std::endl; // Copy the baskets data into the archive: - QStringList backgrounds; + TQStringList backgrounds; saveBasketToArchive(basket, withSubBaskets, &tar, backgrounds, tempFolder, progress); // Create a Small baskets.xml Document: - QDomDocument document("basketTree"); - QDomElement root = document.createElement("basketTree"); + TQDomDocument document("basketTree"); + TQDomElement root = document.createElement("basketTree"); document.appendChild(root); Global::bnpView->saveSubHierarchy(Global::bnpView->listViewItemForBasket(basket), document, root, withSubBaskets); Basket::safelySaveToFile(tempFolder + "baskets.xml", "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + document.toString()); @@ -87,22 +87,22 @@ void Archive::save(Basket *basket, bool withSubBaskets, const QString &destinati dir.remove(tempFolder + "baskets.xml"); // Save a Small tags.xml Document: - QValueList<Tag*> tags; + TQValueList<Tag*> tags; listUsedTags(basket, withSubBaskets, tags); Tag::saveTagsTo(tags, tempFolder + "tags.xml"); tar.addLocalFile(tempFolder + "tags.xml", "tags.xml"); dir.remove(tempFolder + "tags.xml"); // Save Tag Emblems (in case they are loaded on a computer that do not have those icons): - QString tempIconFile = tempFolder + "icon.png"; + TQString tempIconFile = tempFolder + "icon.png"; for (Tag::List::iterator it = tags.begin(); it != tags.end(); ++it) { State::List states = (*it)->states(); for (State::List::iterator it2 = states.begin(); it2 != states.end(); ++it2) { State *state = (*it2); - QPixmap icon = kapp->iconLoader()->loadIcon(state->emblem(), KIcon::Small, 16, KIcon::DefaultState, /*path_store=*/0L, /*canReturnNull=*/true); + TQPixmap icon = kapp->iconLoader()->loadIcon(state->emblem(), KIcon::Small, 16, KIcon::DefaultState, /*path_store=*/0L, /*canReturnNull=*/true); if (!icon.isNull()) { icon.save(tempIconFile, "PNG"); - QString iconFileName = state->emblem().replace('/', '_'); + TQString iconFileName = state->emblem().tqreplace('/', '_'); tar.addLocalFile(tempIconFile, "tag-emblems/" + iconFileName); } } @@ -114,8 +114,8 @@ void Archive::save(Basket *basket, bool withSubBaskets, const QString &destinati // Computing the File Preview: Basket *previewBasket = basket; // FIXME: Use the first non-empty basket! - QPixmap previewPixmap(previewBasket->visibleWidth(), previewBasket->visibleHeight()); - QPainter painter(&previewPixmap); + TQPixmap previewPixmap(previewBasket->visibleWidth(), previewBasket->visibleHeight()); + TQPainter painter(&previewPixmap); // Save old state, and make the look clean ("smile, you are filmed!"): NoteSelection *selection = previewBasket->selectedNotes(); previewBasket->unselectAll(); @@ -130,35 +130,35 @@ void Archive::save(Basket *basket, bool withSubBaskets, const QString &destinati previewBasket->doHoverEffects(); // End and save our splandid painting: painter.end(); - QImage previewImage = previewPixmap.convertToImage(); + TQImage previewImage = previewPixmap.convertToImage(); const int PREVIEW_SIZE = 256; - previewImage = previewImage.scale(PREVIEW_SIZE, PREVIEW_SIZE, QImage::ScaleMin); + previewImage = previewImage.scale(PREVIEW_SIZE, PREVIEW_SIZE, TQ_ScaleMin); previewImage.save(tempFolder + "preview.png", "PNG"); // Finaly Save to the Real Destination file: - QFile file(destination); + TQFile file(destination); if (file.open(IO_WriteOnly)) { - ulong previewSize = QFile(tempFolder + "preview.png").size(); - ulong archiveSize = QFile(tempDestination).size(); - QTextStream stream(&file); - stream.setEncoding(QTextStream::Latin1); + ulong previewSize = TQFile(tempFolder + "preview.png").size(); + ulong archiveSize = TQFile(tempDestination).size(); + TQTextStream stream(&file); + stream.setEncoding(TQTextStream::Latin1); stream << "BasKetNP:archive\n" << "version:0.6.1\n" // << "read-compatible:0.6.1\n" // << "write-compatible:0.6.1\n" << "preview*:" << previewSize << "\n"; // Copy the Preview File: - const Q_ULONG BUFFER_SIZE = 1024; + const TQ_ULONG BUFFER_SIZE = 1024; char *buffer = new char[BUFFER_SIZE]; - Q_LONG sizeRead; - QFile previewFile(tempFolder + "preview.png"); + TQ_LONG sizeRead; + TQFile previewFile(tempFolder + "preview.png"); if (previewFile.open(IO_ReadOnly)) { while ((sizeRead = previewFile.readBlock(buffer, BUFFER_SIZE)) > 0) file.writeBlock(buffer, sizeRead); } stream << "archive*:" << archiveSize << "\n"; // Copy the Archive File: - QFile archiveFile(tempDestination); + TQFile archiveFile(tempDestination); if (archiveFile.open(IO_ReadOnly)) { while ((sizeRead = archiveFile.readBlock(buffer, BUFFER_SIZE)) > 0) file.writeBlock(buffer, sizeRead); @@ -178,7 +178,7 @@ void Archive::save(Basket *basket, bool withSubBaskets, const QString &destinati dir.rmdir(tempFolder); } -void Archive::saveBasketToArchive(Basket *basket, bool recursive, KTar *tar, QStringList &backgrounds, const QString &tempFolder, KProgress *progress) +void Archive::saveBasketToArchive(Basket *basket, bool recursive, KTar *tar, TQStringList &backgrounds, const TQString &tempFolder, KProgress *progress) { // Basket need to be loaded for tags exportation. // We load it NOW so that the progress bar really reflect the state of the exportation: @@ -186,33 +186,33 @@ void Archive::saveBasketToArchive(Basket *basket, bool recursive, KTar *tar, QSt basket->load(); } - QDir dir; + TQDir dir; // Save basket data: tar->addLocalDirectory(basket->fullPath(), "baskets/" + basket->folderName()); tar->addLocalFile(basket->fullPath() + ".basket", "baskets/" + basket->folderName() + ".basket"); // The hidden files were not added // Save basket icon: - QString tempIconFile = tempFolder + "icon.png"; + TQString tempIconFile = tempFolder + "icon.png"; if (!basket->icon().isEmpty() && basket->icon() != "basket") { - QPixmap icon = kapp->iconLoader()->loadIcon(basket->icon(), KIcon::Small, 16, KIcon::DefaultState, /*path_store=*/0L, /*canReturnNull=*/true); + TQPixmap icon = kapp->iconLoader()->loadIcon(basket->icon(), KIcon::Small, 16, KIcon::DefaultState, /*path_store=*/0L, /*canReturnNull=*/true); if (!icon.isNull()) { icon.save(tempIconFile, "PNG"); - QString iconFileName = basket->icon().replace('/', '_'); + TQString iconFileName = basket->icon().tqreplace('/', '_'); tar->addLocalFile(tempIconFile, "basket-icons/" + iconFileName); } } // Save basket backgorund image: - QString imageName = basket->backgroundImageName(); - if (!basket->backgroundImageName().isEmpty() && !backgrounds.contains(imageName)) { - QString backgroundPath = Global::backgroundManager->pathForImageName(imageName); + TQString imageName = basket->backgroundImageName(); + if (!basket->backgroundImageName().isEmpty() && !backgrounds.tqcontains(imageName)) { + TQString backgroundPath = Global::backgroundManager->pathForImageName(imageName); if (!backgroundPath.isEmpty()) { // Save the background image: tar->addLocalFile(backgroundPath, "backgrounds/" + imageName); // Save the preview image: - QString previewPath = Global::backgroundManager->previewPathForImageName(imageName); + TQString previewPath = Global::backgroundManager->previewPathForImageName(imageName); if (!previewPath.isEmpty()) tar->addLocalFile(previewPath, "backgrounds/previews/" + imageName); // Save the configuration file: - QString configPath = backgroundPath + ".config"; + TQString configPath = backgroundPath + ".config"; if (dir.exists(configPath)) tar->addLocalFile(configPath, "backgrounds/" + imageName + ".config"); } @@ -231,7 +231,7 @@ void Archive::saveBasketToArchive(Basket *basket, bool recursive, KTar *tar, QSt } } -void Archive::listUsedTags(Basket *basket, bool recursive, QValueList<Tag*> &list) +void Archive::listUsedTags(Basket *basket, bool recursive, TQValueList<Tag*> &list) { basket->listUsedTags(list); BasketListViewItem *item = Global::bnpView->listViewItemForBasket(basket); @@ -242,34 +242,34 @@ void Archive::listUsedTags(Basket *basket, bool recursive, QValueList<Tag*> &lis } } -void Archive::open(const QString &path) +void Archive::open(const TQString &path) { // Create the temporar folder: - QString tempFolder = Global::savesFolder() + "temp-archive/"; - QDir dir; + TQString tempFolder = Global::savesFolder() + "temp-archive/"; + TQDir dir; dir.mkdir(tempFolder); - const Q_ULONG BUFFER_SIZE = 1024; + const TQ_ULONG BUFFER_SIZE = 1024; - QFile file(path); + TQFile file(path); if (file.open(IO_ReadOnly)) { - QTextStream stream(&file); - stream.setEncoding(QTextStream::Latin1); - QString line = stream.readLine(); + TQTextStream stream(&file); + stream.setEncoding(TQTextStream::Latin1); + TQString line = stream.readLine(); if (line != "BasKetNP:archive") { KMessageBox::error(0, i18n("This file is not a basket archive."), i18n("Basket Archive Error")); file.close(); Tools::deleteRecursively(tempFolder); return; } - QString version; - QStringList readCompatibleVersions; - QStringList writeCompatibleVersions; + TQString version; + TQStringList readCompatibleVersions; + TQStringList writeCompatibleVersions; while (!stream.atEnd()) { // Get Key/Value Pair From the Line to Read: line = stream.readLine(); - int index = line.find(':'); - QString key; - QString value; + int index = line.tqfind(':'); + TQString key; + TQString value; if (index >= 0) { key = line.left(index); value = line.right(line.length() - index - 1); @@ -280,9 +280,9 @@ void Archive::open(const QString &path) if (key == "version") { version = value; } else if (key == "read-compatible") { - readCompatibleVersions = QStringList::split(value, ";"); + readCompatibleVersions = TQStringList::split(value, ";"); } else if (key == "write-compatible") { - writeCompatibleVersions = QStringList::split(value, ";"); + writeCompatibleVersions = TQStringList::split(value, ";"); } else if (key == "preview*") { bool ok; ulong size = value.toULong(&ok); @@ -294,11 +294,11 @@ void Archive::open(const QString &path) } // Get the preview file: //FIXME: We do not need the preview for now -// QFile previewFile(tempFolder + "preview.png"); +// TQFile previewFile(tempFolder + "preview.png"); // if (previewFile.open(IO_WriteOnly)) { char *buffer = new char[BUFFER_SIZE]; - Q_LONG sizeRead; - while ((sizeRead = file.readBlock(buffer, QMIN(BUFFER_SIZE, size))) > 0) { + TQ_LONG sizeRead; + while ((sizeRead = file.readBlock(buffer, TQMIN(BUFFER_SIZE, size))) > 0) { // previewFile.writeBlock(buffer, sizeRead); size -= sizeRead; } @@ -306,22 +306,22 @@ void Archive::open(const QString &path) delete buffer; // } } else if (key == "archive*") { - if (version != "0.6.1" && readCompatibleVersions.contains("0.6.1") && !writeCompatibleVersions.contains("0.6.1")) { + if (version != "0.6.1" && readCompatibleVersions.tqcontains("0.6.1") && !writeCompatibleVersions.tqcontains("0.6.1")) { KMessageBox::information( 0, i18n("This file was created with a recent version of %1. " "It can be opened but not every information will be available to you. " "For instance, some notes may be missing because they are of a type only available in new versions. " "When saving the file back, consider to save it to another file, to preserve the original one.") - .arg(kapp->aboutData()->programName()), + .tqarg(kapp->aboutData()->programName()), i18n("Basket Archive Error") ); } - if (version != "0.6.1" && !readCompatibleVersions.contains("0.6.1") && !writeCompatibleVersions.contains("0.6.1")) { + if (version != "0.6.1" && !readCompatibleVersions.tqcontains("0.6.1") && !writeCompatibleVersions.tqcontains("0.6.1")) { KMessageBox::error( 0, i18n("This file was created with a recent version of %1. Please upgrade to a newer version to be able to open that file.") - .arg(kapp->aboutData()->programName()), + .tqarg(kapp->aboutData()->programName()), i18n("Basket Archive Error") ); file.close(); @@ -341,12 +341,12 @@ void Archive::open(const QString &path) Global::mainWindow()->raise(); // Get the archive file: - QString tempArchive = tempFolder + "temp-archive.tar.gz"; - QFile archiveFile(tempArchive); + TQString tempArchive = tempFolder + "temp-archive.tar.gz"; + TQFile archiveFile(tempArchive); if (archiveFile.open(IO_WriteOnly)) { char *buffer = new char[BUFFER_SIZE]; - Q_LONG sizeRead; - while ((sizeRead = file.readBlock(buffer, QMIN(BUFFER_SIZE, size))) > 0) { + TQ_LONG sizeRead; + while ((sizeRead = file.readBlock(buffer, TQMIN(BUFFER_SIZE, size))) > 0) { archiveFile.writeBlock(buffer, sizeRead); size -= sizeRead; } @@ -354,8 +354,8 @@ void Archive::open(const QString &path) delete buffer; // Extract the Archive: - QString extractionFolder = tempFolder + "extraction/"; - QDir dir; + TQString extractionFolder = tempFolder + "extraction/"; + TQDir dir; dir.mkdir(extractionFolder); KTar tar(tempArchive, "application/x-gzip"); tar.open(IO_ReadOnly); @@ -364,8 +364,8 @@ void Archive::open(const QString &path) // Import the Tags: importTagEmblems(extractionFolder); // Import and rename tag emblems BEFORE loading them! - QMap<QString, QString> mergedStates = Tag::loadTags(extractionFolder + "tags.xml"); - QMap<QString, QString>::Iterator it; + TQMap<TQString, TQString> mergedStates = Tag::loadTags(extractionFolder + "tags.xml"); + TQMap<TQString, TQString>::Iterator it; if (mergedStates.count() > 0) { Tag::saveTags(); } @@ -389,8 +389,8 @@ void Archive::open(const QString &path) } // Get the archive file: char *buffer = new char[BUFFER_SIZE]; - Q_LONG sizeRead; - while ((sizeRead = file.readBlock(buffer, QMIN(BUFFER_SIZE, size))) > 0) { + TQ_LONG sizeRead; + while ((sizeRead = file.readBlock(buffer, TQMIN(BUFFER_SIZE, size))) > 0) { size -= sizeRead; } delete buffer; @@ -411,40 +411,40 @@ void Archive::open(const QString &path) * This method check for every emblems and import the missing ones. * It also modify the tags.xml copy for the emblems to point to the absolute path of the impported icons. */ -void Archive::importTagEmblems(const QString &extractionFolder) +void Archive::importTagEmblems(const TQString &extractionFolder) { - QDomDocument *document = XMLWork::openFile("basketTags", extractionFolder + "tags.xml"); + TQDomDocument *document = XMLWork::openFile("basketTags", extractionFolder + "tags.xml"); if (document == 0) return; - QDomElement docElem = document->documentElement(); + TQDomElement docElem = document->documentElement(); - QDir dir; + TQDir dir; dir.mkdir(Global::savesFolder() + "tag-emblems/"); FormatImporter copier; // Only used to copy files synchronously - QDomNode node = docElem.firstChild(); + TQDomNode node = docElem.firstChild(); while (!node.isNull()) { - QDomElement element = node.toElement(); + TQDomElement element = node.toElement(); if ( (!element.isNull()) && element.tagName() == "tag" ) { - QDomNode subNode = element.firstChild(); + TQDomNode subNode = element.firstChild(); while (!subNode.isNull()) { - QDomElement subElement = subNode.toElement(); + TQDomElement subElement = subNode.toElement(); if ( (!subElement.isNull()) && subElement.tagName() == "state" ) { - QString emblemName = XMLWork::getElementText(subElement, "emblem"); + TQString emblemName = XMLWork::getElementText(subElement, "emblem"); if (!emblemName.isEmpty()) { - QPixmap emblem = kapp->iconLoader()->loadIcon(emblemName, KIcon::NoGroup, 16, KIcon::DefaultState, 0L, /*canReturnNull=*/true); + TQPixmap emblem = kapp->iconLoader()->loadIcon(emblemName, KIcon::NoGroup, 16, KIcon::DefaultState, 0L, /*canReturnNull=*/true); // The icon does not exists on that computer, import it: if (emblem.isNull()) { // Of the emblem path was eg. "/home/seb/emblem.png", it was exported as "tag-emblems/_home_seb_emblem.png". // So we need to copy that image to "~/.kde/share/apps/basket/tag-emblems/emblem.png": - int slashIndex = emblemName.findRev("/"); - QString emblemFileName = (slashIndex < 0 ? emblemName : emblemName.right(slashIndex - 2)); - QString source = extractionFolder + "tag-emblems/" + emblemName.replace('/', '_'); - QString destination = Global::savesFolder() + "tag-emblems/" + emblemFileName; + int slashIndex = emblemName.tqfindRev("/"); + TQString emblemFileName = (slashIndex < 0 ? emblemName : emblemName.right(slashIndex - 2)); + TQString source = extractionFolder + "tag-emblems/" + emblemName.tqreplace('/', '_'); + TQString destination = Global::savesFolder() + "tag-emblems/" + emblemFileName; if (!dir.exists(destination)) copier.copyFolder(source, destination); // Replace the emblem path in the tags.xml copy: - QDomElement emblemElement = XMLWork::getElement(subElement, "emblem"); + TQDomElement emblemElement = XMLWork::getElement(subElement, "emblem"); subElement.removeChild(emblemElement); XMLWork::addElement(*document, subElement, "emblem", destination); } @@ -458,28 +458,28 @@ void Archive::importTagEmblems(const QString &extractionFolder) Basket::safelySaveToFile(extractionFolder + "tags.xml", document->toString()); } -void Archive::importArchivedBackgroundImages(const QString &extractionFolder) +void Archive::importArchivedBackgroundImages(const TQString &extractionFolder) { FormatImporter copier; // Only used to copy files synchronously - QString destFolder = KGlobal::dirs()->saveLocation("data", "basket/backgrounds/"); + TQString destFolder = KGlobal::dirs()->saveLocation("data", "basket/backgrounds/"); - QDir dir(extractionFolder + "backgrounds/", /*nameFilder=*/"*.png", /*sortSpec=*/QDir::Name | QDir::IgnoreCase, /*filterSpec=*/QDir::Files | QDir::NoSymLinks); - QStringList files = dir.entryList(); - for (QStringList::Iterator it = files.begin(); it != files.end(); ++it) { - QString image = *it; + TQDir dir(extractionFolder + "backgrounds/", /*nameFilder=*/"*.png", /*sortSpec=*/TQDir::Name | TQDir::IgnoreCase, /*filterSpec=*/TQDir::Files | TQDir::NoSymLinks); + TQStringList files = dir.entryList(); + for (TQStringList::Iterator it = files.begin(); it != files.end(); ++it) { + TQString image = *it; if (!Global::backgroundManager->exists(image)) { // Copy images: - QString imageSource = extractionFolder + "backgrounds/" + image; - QString imageDest = destFolder + image; + TQString imageSource = extractionFolder + "backgrounds/" + image; + TQString imageDest = destFolder + image; copier.copyFolder(imageSource, imageDest); // Copy configuration file: - QString configSource = extractionFolder + "backgrounds/" + image + ".config"; - QString configDest = destFolder + image; + TQString configSource = extractionFolder + "backgrounds/" + image + ".config"; + TQString configDest = destFolder + image; if (dir.exists(configSource)) copier.copyFolder(configSource, configDest); // Copy preview: - QString previewSource = extractionFolder + "backgrounds/previews/" + image; - QString previewDest = destFolder + "previews/" + image; + TQString previewSource = extractionFolder + "backgrounds/previews/" + image; + TQString previewDest = destFolder + "previews/" + image; if (dir.exists(previewSource)) { dir.mkdir(destFolder + "previews/"); // Make sure the folder exists! copier.copyFolder(previewSource, previewDest); @@ -490,38 +490,38 @@ void Archive::importArchivedBackgroundImages(const QString &extractionFolder) } } -void Archive::renameBasketFolders(const QString &extractionFolder, QMap<QString, QString> &mergedStates) +void Archive::renameBasketFolders(const TQString &extractionFolder, TQMap<TQString, TQString> &mergedStates) { - QDomDocument *doc = XMLWork::openFile("basketTree", extractionFolder + "baskets/baskets.xml"); + TQDomDocument *doc = XMLWork::openFile("basketTree", extractionFolder + "baskets/baskets.xml"); if (doc != 0) { - QMap<QString, QString> folderMap; - QDomElement docElem = doc->documentElement(); - QDomNode node = docElem.firstChild(); + TQMap<TQString, TQString> folderMap; + TQDomElement docElem = doc->documentElement(); + TQDomNode node = docElem.firstChild(); renameBasketFolder(extractionFolder, node, folderMap, mergedStates); loadExtractedBaskets(extractionFolder, node, folderMap, 0); } } -void Archive::renameBasketFolder(const QString &extractionFolder, QDomNode &basketNode, QMap<QString, QString> &folderMap, QMap<QString, QString> &mergedStates) +void Archive::renameBasketFolder(const TQString &extractionFolder, TQDomNode &basketNode, TQMap<TQString, TQString> &folderMap, TQMap<TQString, TQString> &mergedStates) { - QDomNode n = basketNode; + TQDomNode n = basketNode; while ( ! n.isNull() ) { - QDomElement element = n.toElement(); + TQDomElement element = n.toElement(); if ( (!element.isNull()) && element.tagName() == "basket" ) { - QString folderName = element.attribute("folderName"); + TQString folderName = element.attribute("folderName"); if (!folderName.isEmpty()) { // Find a folder name: - QString newFolderName = BasketFactory::newFolderName(); + TQString newFolderName = BasketFactory::newFolderName(); folderMap[folderName] = newFolderName; // Reserve the folder name: - QDir dir; + TQDir dir; dir.mkdir(Global::basketsFolder() + newFolderName); // Rename the merged tag ids: // if (mergedStates.count() > 0) { renameMergedStatesAndBasketIcon(extractionFolder + "baskets/" + folderName + ".basket", mergedStates, extractionFolder); // } // Child baskets: - QDomNode node = element.firstChild(); + TQDomNode node = element.firstChild(); renameBasketFolder(extractionFolder, node, folderMap, mergedStates); } } @@ -529,69 +529,69 @@ void Archive::renameBasketFolder(const QString &extractionFolder, QDomNode &bask } } -void Archive::renameMergedStatesAndBasketIcon(const QString &fullPath, QMap<QString, QString> &mergedStates, const QString &extractionFolder) +void Archive::renameMergedStatesAndBasketIcon(const TQString &fullPath, TQMap<TQString, TQString> &mergedStates, const TQString &extractionFolder) { - QDomDocument *doc = XMLWork::openFile("basket", fullPath); + TQDomDocument *doc = XMLWork::openFile("basket", fullPath); if (doc == 0) return; - QDomElement docElem = doc->documentElement(); - QDomElement properties = XMLWork::getElement(docElem, "properties"); + TQDomElement docElem = doc->documentElement(); + TQDomElement properties = XMLWork::getElement(docElem, "properties"); importBasketIcon(properties, extractionFolder); - QDomElement notes = XMLWork::getElement(docElem, "notes"); + TQDomElement notes = XMLWork::getElement(docElem, "notes"); if (mergedStates.count() > 0) renameMergedStates(notes, mergedStates); Basket::safelySaveToFile(fullPath, /*"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + */doc->toString()); } -void Archive::importBasketIcon(QDomElement properties, const QString &extractionFolder) +void Archive::importBasketIcon(TQDomElement properties, const TQString &extractionFolder) { - QString iconName = XMLWork::getElementText(properties, "icon"); + TQString iconName = XMLWork::getElementText(properties, "icon"); if (!iconName.isEmpty() && iconName != "basket") { - QPixmap icon = kapp->iconLoader()->loadIcon(iconName, KIcon::NoGroup, 16, KIcon::DefaultState, 0L, /*canReturnNull=*/true); + TQPixmap icon = kapp->iconLoader()->loadIcon(iconName, KIcon::NoGroup, 16, KIcon::DefaultState, 0L, /*canReturnNull=*/true); // The icon does not exists on that computer, import it: if (icon.isNull()) { - QDir dir; + TQDir dir; dir.mkdir(Global::savesFolder() + "basket-icons/"); FormatImporter copier; // Only used to copy files synchronously // Of the icon path was eg. "/home/seb/icon.png", it was exported as "basket-icons/_home_seb_icon.png". // So we need to copy that image to "~/.kde/share/apps/basket/basket-icons/icon.png": - int slashIndex = iconName.findRev("/"); - QString iconFileName = (slashIndex < 0 ? iconName : iconName.right(slashIndex - 2)); - QString source = extractionFolder + "basket-icons/" + iconName.replace('/', '_'); - QString destination = Global::savesFolder() + "basket-icons/" + iconFileName; + int slashIndex = iconName.tqfindRev("/"); + TQString iconFileName = (slashIndex < 0 ? iconName : iconName.right(slashIndex - 2)); + TQString source = extractionFolder + "basket-icons/" + iconName.tqreplace('/', '_'); + TQString destination = Global::savesFolder() + "basket-icons/" + iconFileName; if (!dir.exists(destination)) copier.copyFolder(source, destination); // Replace the emblem path in the tags.xml copy: - QDomElement iconElement = XMLWork::getElement(properties, "icon"); + TQDomElement iconElement = XMLWork::getElement(properties, "icon"); properties.removeChild(iconElement); - QDomDocument document = properties.ownerDocument(); + TQDomDocument document = properties.ownerDocument(); XMLWork::addElement(document, properties, "icon", destination); } } } -void Archive::renameMergedStates(QDomNode notes, QMap<QString, QString> &mergedStates) +void Archive::renameMergedStates(TQDomNode notes, TQMap<TQString, TQString> &mergedStates) { - QDomNode n = notes.firstChild(); + TQDomNode n = notes.firstChild(); while ( ! n.isNull() ) { - QDomElement element = n.toElement(); + TQDomElement element = n.toElement(); if (!element.isNull()) { if (element.tagName() == "group" ) { renameMergedStates(n, mergedStates); } else if (element.tagName() == "note") { - QString tags = XMLWork::getElementText(element, "tags"); + TQString tags = XMLWork::getElementText(element, "tags"); if (!tags.isEmpty()) { - QStringList tagNames = QStringList::split(";", tags); - for (QStringList::Iterator it = tagNames.begin(); it != tagNames.end(); ++it) { - QString &tag = *it; - if (mergedStates.contains(tag)) { + TQStringList tagNames = TQStringList::split(";", tags); + for (TQStringList::Iterator it = tagNames.begin(); it != tagNames.end(); ++it) { + TQString &tag = *it; + if (mergedStates.tqcontains(tag)) { tag = mergedStates[tag]; } } - QString newTags = tagNames.join(";"); - QDomElement tagsElement = XMLWork::getElement(element, "tags"); + TQString newTags = tagNames.join(";"); + TQDomElement tagsElement = XMLWork::getElement(element, "tags"); element.removeChild(tagsElement); - QDomDocument document = element.ownerDocument(); + TQDomDocument document = element.ownerDocument(); XMLWork::addElement(document, element, "tags", newTags); } } @@ -600,27 +600,27 @@ void Archive::renameMergedStates(QDomNode notes, QMap<QString, QString> &mergedS } } -void Archive::loadExtractedBaskets(const QString &extractionFolder, QDomNode &basketNode, QMap<QString, QString> &folderMap, Basket *parent) +void Archive::loadExtractedBaskets(const TQString &extractionFolder, TQDomNode &basketNode, TQMap<TQString, TQString> &folderMap, Basket *tqparent) { - bool basketSetAsCurrent = (parent != 0); - QDomNode n = basketNode; + bool basketSetAsCurrent = (tqparent != 0); + TQDomNode n = basketNode; while ( ! n.isNull() ) { - QDomElement element = n.toElement(); + TQDomElement element = n.toElement(); if ( (!element.isNull()) && element.tagName() == "basket" ) { - QString folderName = element.attribute("folderName"); + TQString folderName = element.attribute("folderName"); if (!folderName.isEmpty()) { // Move the basket folder to its destination, while renaming it uniquely: - QString newFolderName = folderMap[folderName]; + TQString newFolderName = folderMap[folderName]; FormatImporter copier; // The folder has been "reserved" by creating it. Avoid asking the user to override: - QDir dir; + TQDir dir; dir.rmdir(Global::basketsFolder() + newFolderName); copier.moveFolder(extractionFolder + "baskets/" + folderName, Global::basketsFolder() + newFolderName); // Append and load the basket in the tree: Basket *basket = Global::bnpView->loadBasket(newFolderName); - BasketListViewItem *basketItem = Global::bnpView->appendBasket(basket, (basket && parent ? Global::bnpView->listViewItemForBasket(parent) : 0)); + BasketListViewItem *basketItem = Global::bnpView->appendBasket(basket, (basket && tqparent ? Global::bnpView->listViewItemForBasket(tqparent) : 0)); basketItem->setOpen(!XMLWork::trueOrFalse(element.attribute("folded", "false"), false)); - QDomElement properties = XMLWork::getElement(element, "properties"); + TQDomElement properties = XMLWork::getElement(element, "properties"); importBasketIcon(properties, extractionFolder); // Rename the icon fileName if necessary basket->loadProperties(properties); // Open the first basket of the archive: @@ -628,7 +628,7 @@ void Archive::loadExtractedBaskets(const QString &extractionFolder, QDomNode &ba Global::bnpView->setCurrentBasket(basket); basketSetAsCurrent = true; } - QDomNode node = element.firstChild(); + TQDomNode node = element.firstChild(); loadExtractedBaskets(extractionFolder, node, folderMap, basket); } } |