summaryrefslogtreecommitdiffstats
path: root/src/htmlexporter.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-05-17 08:20:48 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-05-17 08:20:48 +0000
commitaa0726b20f398264f0a2abc60215be044b106f9c (patch)
tree070fdbc19a1106cfdd7f651a8ce76bb1b89a513d /src/htmlexporter.cpp
parentd3cf5b3e75aadc3b02d0b56f030d4c3f8c2c749d (diff)
downloadbasket-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/htmlexporter.cpp')
-rw-r--r--src/htmlexporter.cpp122
1 files changed, 61 insertions, 61 deletions
diff --git a/src/htmlexporter.cpp b/src/htmlexporter.cpp
index 9e41d35..4936454 100644
--- a/src/htmlexporter.cpp
+++ b/src/htmlexporter.cpp
@@ -33,25 +33,25 @@
#include <kiconloader.h>
#include <kfiledialog.h>
#include <kmessagebox.h>
-#include <qdir.h>
-#include <qfile.h>
-#include <qpainter.h>
+#include <tqdir.h>
+#include <tqfile.h>
+#include <tqpainter.h>
#include <kglobalsettings.h>
#include <kprogress.h>
HTMLExporter::HTMLExporter(Basket *basket)
{
- QDir dir;
+ TQDir dir;
// Compute a default file name & path:
KConfig *config = KGlobal::config();
config->setGroup("Export to HTML");
- QString folder = config->readEntry("lastFolder", QDir::homeDirPath()) + "/";
- QString url = folder + QString(basket->basketName()).replace("/", "_") + ".html";
+ TQString folder = config->readEntry("lastFolder", TQDir::homeDirPath()) + "/";
+ TQString url = folder + TQString(basket->basketName()).tqreplace("/", "_") + ".html";
// Ask a file name & path to the user:
- QString filter = "*.html *.htm|" + i18n("HTML Documents") + "\n*|" + i18n("All Files");
- QString destination = url;
+ TQString filter = "*.html *.htm|" + i18n("HTML Documents") + "\n*|" + i18n("All Files");
+ TQString destination = url;
for (bool askAgain = true; askAgain; ) {
// Ask:
destination = KFileDialog::getSaveFileName(destination, filter, 0, i18n("Export to HTML"));
@@ -63,7 +63,7 @@ HTMLExporter::HTMLExporter(Basket *basket)
int result = KMessageBox::questionYesNoCancel(
0,
"<qt>" + i18n("The file <b>%1</b> already exists. Do you really want to override it?")
- .arg(KURL(destination).fileName()),
+ .tqarg(KURL(destination).fileName()),
i18n("Override File?"),
KGuiItem(i18n("&Override"), "filesave")
);
@@ -96,7 +96,7 @@ HTMLExporter::~HTMLExporter()
{
}
-void HTMLExporter::prepareExport(Basket *basket, const QString &fullPath)
+void HTMLExporter::prepareExport(Basket *basket, const TQString &fullPath)
{
progress->setTotalSteps(/*Preparation:*/1 + /*Finishing:*/1 + /*Basket:*/1 + /*SubBaskets:*/Global::bnpView->basketCount(Global::bnpView->listViewItemForBasket(basket)));
progress->setValue(0);
@@ -111,9 +111,9 @@ void HTMLExporter::prepareExport(Basket *basket, const QString &fullPath)
withBasketTree = (item->firstChild() != 0);
// Create and empty the files folder:
- QString filesFolderPath = i18n("HTML export folder (files)", "%1_files").arg(filePath) + "/"; // eg.: "/home/seb/foo.html_files/"
+ TQString filesFolderPath = i18n("HTML export folder (files)", "%1_files").tqarg(filePath) + "/"; // eg.: "/home/seb/foo.html_files/"
Tools::deleteRecursively(filesFolderPath);
- QDir dir;
+ TQDir dir;
dir.mkdir(filesFolderPath);
// Create sub-folders:
@@ -136,7 +136,7 @@ void HTMLExporter::exportBasket(Basket *basket, bool isSubBasket)
}
// Compute the absolute & relative paths for this basket:
- filesFolderPath = i18n("HTML export folder (files)", "%1_files").arg(filePath) + "/";
+ filesFolderPath = i18n("HTML export folder (files)", "%1_files").tqarg(filePath) + "/";
if (isSubBasket) {
basketFilePath = basketsFolderPath + basket->folderName().left(basket->folderName().length() - 1) + ".html";
filesFolderName = "../";
@@ -145,7 +145,7 @@ void HTMLExporter::exportBasket(Basket *basket, bool isSubBasket)
basketsFolderName = "";
} else {
basketFilePath = filePath;
- filesFolderName = i18n("HTML export folder (files)", "%1_files").arg(KURL(filePath).fileName()) + "/";
+ filesFolderName = i18n("HTML export folder (files)", "%1_files").tqarg(KURL(filePath).fileName()) + "/";
dataFolderName = filesFolderName + i18n("HTML export folder (data)", "data") + "/";
dataFolderPath = filesFolderPath + i18n("HTML export folder (data)", "data") + "/";
basketsFolderName = filesFolderName + i18n("HTML export folder (baskets)", "baskets") + "/";
@@ -168,25 +168,25 @@ void HTMLExporter::exportBasket(Basket *basket, bool isSubBasket)
std::cout << " basketsFolderName:" << basketsFolderName << std::endl;
// Create the data folder for this basket:
- QDir dir;
+ TQDir dir;
dir.mkdir(dataFolderPath);
- backgroundColorName = basket->backgroundColor().name().lower().mid(1);
+ backgroundColorName = TQString(basket->backgroundColor().name()).lower().mid(1);
// Generate basket icons:
- QString basketIcon16 = iconsFolderName + copyIcon(basket->icon(), 16);
- QString basketIcon32 = iconsFolderName + copyIcon(basket->icon(), 32);
+ TQString basketIcon16 = iconsFolderName + copyIcon(basket->icon(), 16);
+ TQString basketIcon32 = iconsFolderName + copyIcon(basket->icon(), 32);
// Generate the [+] image for groups:
- QPixmap expandGroup(Note::EXPANDER_WIDTH, Note::EXPANDER_HEIGHT);
+ TQPixmap expandGroup(Note::EXPANDER_WIDTH, Note::EXPANDER_HEIGHT);
expandGroup.fill(basket->backgroundColor());
- QPainter painter(&expandGroup);
+ TQPainter painter(&expandGroup);
Note::drawExpander(&painter, 0, 0, basket->backgroundColor(), /*expand=*/true, basket);
painter.end();
expandGroup.save(imagesFolderPath + "expand_group_" + backgroundColorName + ".png", "PNG");
// Generate the [-] image for groups:
- QPixmap foldGroup(Note::EXPANDER_WIDTH, Note::EXPANDER_HEIGHT);
+ TQPixmap foldGroup(Note::EXPANDER_WIDTH, Note::EXPANDER_HEIGHT);
foldGroup.fill(basket->backgroundColor());
painter.begin(&foldGroup);
Note::drawExpander(&painter, 0, 0, basket->backgroundColor(), /*expand=*/false, basket);
@@ -194,21 +194,21 @@ void HTMLExporter::exportBasket(Basket *basket, bool isSubBasket)
foldGroup.save(imagesFolderPath + "fold_group_" + backgroundColorName + ".png", "PNG");
// Open the file to write:
- QFile file(basketFilePath);
+ TQFile file(basketFilePath);
if (!file.open(IO_WriteOnly))
return;
- stream.setDevice(&file);
- stream.setEncoding(QTextStream::UnicodeUTF8);
+ stream.setDevice(TQT_TQIODEVICE(&file));
+ stream.setEncoding(TQTextStream::UnicodeUTF8);
// Compute the colors to draw dragient for notes:
- QColor topBgColor;
- QColor bottomBgColor;
+ TQColor topBgColor;
+ TQColor bottomBgColor;
Note::getGradientColors(basket->backgroundColor(), &topBgColor, &bottomBgColor);
// Compute the gradient image for notes:
- QString gradientImageFileName = Basket::saveGradientBackground(basket->backgroundColor(), basket->QScrollView::font(), imagesFolderPath);
+ TQString gradientImageFileName = Basket::saveGradientBackground(basket->backgroundColor(), basket->TQScrollView::font(), imagesFolderPath);
// Output the header:
- QString borderColor = Tools::mixColor(basket->backgroundColor(), basket->textColor()).name();
+ TQString borderColor = Tools::mixColor(basket->backgroundColor(), basket->textColor()).name();
stream <<
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n"
"<html>\n"
@@ -238,7 +238,7 @@ void HTMLExporter::exportBasket(Basket *basket, bool isSubBasket)
}
stream <<
" .basket { background-color: " << basket->backgroundColor().name() << "; border: solid " << borderColor << " 1px; "
- "font: " << Tools::cssFontDefinition(basket->QScrollView::font()) << "; color: " << basket->textColor().name() << "; padding: 1px; width: 100%; }\n"
+ "font: " << Tools::cssFontDefinition(basket->TQScrollView::font()) << "; color: " << basket->textColor().name() << "; padding: 1px; width: 100%; }\n"
" table.basket { border-collapse: collapse; }\n"
" .basket * { padding: 0; margin: 0; }\n"
" .basket table { width: 100%; border-spacing: 0; _border-collapse: collapse; }\n"
@@ -259,10 +259,10 @@ void HTMLExporter::exportBasket(Basket *basket, bool isSubBasket)
<< LinkLook::launcherLook->toCSS("launcher", basket->textColor())
<<
" .unknown { margin: 1px 2px; border: 1px solid " << borderColor << "; -moz-border-radius: 4px; }\n";
- QValueList<State*> states = basket->usedStates();
- QString statesCss;
+ TQValueList<State*> states = basket->usedStates();
+ TQString statesCss;
for (State::List::Iterator it = states.begin(); it != states.end(); ++it)
- statesCss += (*it)->toCSS(imagesFolderPath, imagesFolderName, basket->QScrollView::font());
+ statesCss += (*it)->toCSS(imagesFolderPath, imagesFolderName, basket->TQScrollView::font());
stream <<
statesCss <<
" .credits { text-align: right; margin: 3px 0 0 0; _margin-top: -17px; font-size: 80%; color: " << borderColor << "; }\n"
@@ -270,7 +270,7 @@ void HTMLExporter::exportBasket(Basket *basket, bool isSubBasket)
" <title>" << Tools::textToHTMLWithoutP(basket->basketName()) << "</title>\n"
" <link rel=\"shortcut icon\" type=\"image/png\" href=\"" << basketIcon16 << "\">\n";
// Create the column handle image:
- QPixmap columnHandle(Note::RESIZER_WIDTH, 50);
+ TQPixmap columnHandle(Note::RESIZER_WIDTH, 50);
painter.begin(&columnHandle);
Note::drawInactiveResizer(&painter, 0, 0, columnHandle.height(), basket->backgroundColor(), /*column=*/true);
painter.end();
@@ -289,7 +289,7 @@ void HTMLExporter::exportBasket(Basket *basket, bool isSubBasket)
// TODO: Make sure only filtered notes are exported!
// if (decoration()->filterData().isFiltering)
// stream <<
-// " <p>" << i18n("Notes matching the filter &quot;%1&quot;:").arg(Tools::textToHTMLWithoutP(decoration()->filterData().string)) << "</p>\n";
+// " <p>" << i18n("Notes matching the filter &quot;%1&quot;:").tqarg(Tools::textToHTMLWithoutP(decoration()->filterData().string)) << "</p>\n";
stream <<
" <div class=\"basketSurrounder\">\n";
@@ -313,18 +313,18 @@ void HTMLExporter::exportBasket(Basket *basket, bool isSubBasket)
else
stream <<
" </div>\n";
- stream << QString(
+ stream << TQString(
" </div>\n"
- " <p class=\"credits\">%1</p>\n").arg(
+ " <p class=\"credits\">%1</p>\n").tqarg(
i18n("Made with %1, a KDE tool to take notes and keep information at hand.")
- .arg("<a href=\"http://basket.kde.org/\">%1</a> %2")
- .arg(kapp->aboutData()->programName(), VERSION));
+ .tqarg("<a href=\"http://basket.kde.org/\">%1</a> %2")
+ .tqarg(kapp->aboutData()->programName(), VERSION));
// Copy a transparent GIF image in the folder, needed for the JavaScript hack:
- QString gifFileName = "spacer.gif";
- QFile transGIF(imagesFolderPath + gifFileName);
+ TQString gifFileName = "spacer.gif";
+ TQFile transGIF(imagesFolderPath + gifFileName);
if (!transGIF.exists() && transGIF.open(IO_WriteOnly)) {
- QDataStream streamGIF(&transGIF);
+ TQDataStream streamGIF(&transGIF);
// This is a 1px*1px transparent GIF image:
const uchar blankGIF[] = {
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x0a, 0x00, 0x0a, 0x00,
@@ -375,10 +375,10 @@ void HTMLExporter::exportBasket(Basket *basket, bool isSubBasket)
void HTMLExporter::exportNote(Note *note, int indent)
{
- QString spaces;
+ TQString spaces;
if (note->isColumn()) {
- QString width = "";
+ TQString width = "";
if (false/*TODO: DEBUG AND REENABLE: hasResizer()*/) {
// As we cannot be precise in CSS (say eg. "width: 50%-40px;"),
// we output a percentage that is approximatively correct.
@@ -396,7 +396,7 @@ void HTMLExporter::exportNote(Note *note, int indent)
widthValue = 1;
if (widthValue > 100)
widthValue = 100;
- width = QString(" width=\"%1%\"").arg(QString::number(widthValue));
+ width = TQString(" width=\"%1%\"").tqarg(TQString::number(widthValue));
}
stream << spaces.fill(' ', indent) << "<td class=\"column\"" << width << ">\n";
@@ -413,9 +413,9 @@ void HTMLExporter::exportNote(Note *note, int indent)
return;
}
- QString freeStyle;
+ TQString freeStyle;
if (note->isFree())
- freeStyle = " style=\"position: absolute; left: " + QString::number(note->x()) + "px; top: " + QString::number(note->y()) + "px; width: " + QString::number(note->groupWidth()) + "px\"";
+ freeStyle = " style=\"position: absolute; left: " + TQString::number(note->x()) + "px; top: " + TQString::number(note->y()) + "px; width: " + TQString::number(note->groupWidth()) + "px\"";
if (note->isGroup()) {
stream << '\n' << spaces.fill(' ', indent) << "<table" << freeStyle << ">\n"; // Note content is expected to be on the same HTML line, but NOT groups
@@ -438,7 +438,7 @@ void HTMLExporter::exportNote(Note *note, int indent)
stream << '\n' << spaces.fill(' ', indent) << "</table>\n" /*<< spaces.fill(' ', indent - 1)*/;
} else {
// Additionnal class for the content (link, netword, color...):
- QString additionnalClasses = note->content()->cssClass();
+ TQString additionnalClasses = note->content()->cssClass();
if (!additionnalClasses.isEmpty())
additionnalClasses = " " + additionnalClasses;
// Assign the style of each associted tags:
@@ -451,7 +451,7 @@ void HTMLExporter::exportNote(Note *note, int indent)
for (State::List::Iterator it = note->states().begin(); it != note->states().end(); ++it)
if (!(*it)->emblem().isEmpty()) {
int emblemSize = 16;
- QString iconFileName = copyIcon((*it)->emblem(), emblemSize);
+ TQString iconFileName = copyIcon((*it)->emblem(), emblemSize);
stream << "<img src=\"" << iconsFolderName << iconFileName
<< "\" width=\"" << emblemSize << "\" height=\"" << emblemSize
<< "\" alt=\"" << (*it)->textEquivalent() << "\" title=\"" << (*it)->fullName() << "\">";
@@ -474,9 +474,9 @@ void HTMLExporter::writeBasketTree(Basket *currentBasket)
void HTMLExporter::writeBasketTree(Basket *currentBasket, Basket *basket, int indent)
{
// Compute variable HTML code:
- QString spaces;
- QString cssClass = (basket == currentBasket ? " class=\"current\"" : "");
- QString link = "#";
+ TQString spaces;
+ TQString cssClass = (basket == currentBasket ? " class=\"current\"" : "");
+ TQString link = "#";
if (currentBasket != basket) {
if (currentBasket == exportedBasket) {
link = basketsFolderName + basket->folderName().left(basket->folderName().length() - 1) + ".html";
@@ -486,7 +486,7 @@ void HTMLExporter::writeBasketTree(Basket *currentBasket, Basket *basket, int in
link = basket->folderName().left(basket->folderName().length() - 1) + ".html";
}
}
- QString spanStyle = "";
+ TQString spanStyle = "";
if (basket->backgroundColorSetting().isValid() || basket->textColorSetting().isValid()) {
spanStyle = " style=\"background-color: " + basket->backgroundColor().name() + "; color: " + basket->textColor().name() + "\"";
}
@@ -519,16 +519,16 @@ void HTMLExporter::writeBasketTree(Basket *currentBasket, Basket *basket, int in
* It is optimized so that you can have an empty folder receiving the icons
* and call copyIcon() each time you encounter one during export process.
*/
-QString HTMLExporter::copyIcon(const QString &iconName, int size)
+TQString HTMLExporter::copyIcon(const TQString &iconName, int size)
{
if (iconName.isEmpty())
return "";
// Sometimes icon can be "favicons/www.kde.org", we replace the '/' with a '_'
- QString fileName = iconName; // QString::replace() isn't const, so I must copy the string before
- fileName = "ico" + QString::number(size) + "_" + fileName.replace("/", "_") + ".png";
- QString fullPath = iconsFolderPath + fileName;
- if (!QFile::exists(fullPath))
+ TQString fileName = iconName; // TQString::tqreplace() isn't const, so I must copy the string before
+ fileName = "ico" + TQString::number(size) + "_" + fileName.tqreplace("/", "_") + ".png";
+ TQString fullPath = iconsFolderPath + fileName;
+ if (!TQFile::exists(fullPath))
DesktopIcon(iconName, size).save(fullPath, "PNG");
return fileName;
}
@@ -539,14 +539,14 @@ QString HTMLExporter::copyIcon(const QString &iconName, int size)
* The first copy isn't yet started, so the dest file isn't created and this method
* returns the same filename !!!!!!!!!!!!!!!!!!!!
*/
-QString HTMLExporter::copyFile(const QString &srcPath, bool createIt)
+TQString HTMLExporter::copyFile(const TQString &srcPath, bool createIt)
{
- QString fileName = Tools::fileNameForNewFile(KURL(srcPath).fileName(), dataFolderPath);
- QString fullPath = dataFolderPath + fileName;
+ TQString fileName = Tools::fileNameForNewFile(KURL(srcPath).fileName(), dataFolderPath);
+ TQString fullPath = dataFolderPath + fileName;
if (createIt) {
// We create the file to be sure another very near call to copyFile() willn't choose the same name:
- QFile file(KURL(fullPath).path());
+ TQFile file(KURL(fullPath).path());
if (file.open(IO_WriteOnly))
file.close();
// And then we copy the file AND overwriting the file we juste created: