diff options
Diffstat (limited to 'kipi-plugins/simpleviewerexport/simpleviewerexport.cpp')
-rw-r--r-- | kipi-plugins/simpleviewerexport/simpleviewerexport.cpp | 216 |
1 files changed, 108 insertions, 108 deletions
diff --git a/kipi-plugins/simpleviewerexport/simpleviewerexport.cpp b/kipi-plugins/simpleviewerexport/simpleviewerexport.cpp index eab94d9..1d6a975 100644 --- a/kipi-plugins/simpleviewerexport/simpleviewerexport.cpp +++ b/kipi-plugins/simpleviewerexport/simpleviewerexport.cpp @@ -23,12 +23,12 @@ // QT includes -#include <qtimer.h> -#include <qimage.h> -#include <qfile.h> -#include <qdir.h> -#include <qcstring.h> -#include <qdatastream.h> +#include <tqtimer.h> +#include <tqimage.h> +#include <tqfile.h> +#include <tqdir.h> +#include <tqcstring.h> +#include <tqdatastream.h> // KDE includes @@ -77,17 +77,17 @@ namespace KIPISimpleViewerExportPlugin // maxium size of a simpleviewer thumbnail // TODO: read from configfile const int maxThumbSize = 45; -const QString viewer("viewer.swf"); +const TQString viewer("viewer.swf"); -void SimpleViewerExport::run(KIPI::Interface* interface, QObject *parent) +void SimpleViewerExport::run(KIPI::Interface* interface, TQObject *tqparent) { - SimpleViewerExport *plugin = new SimpleViewerExport(interface, parent); + SimpleViewerExport *plugin = new SimpleViewerExport(interface, tqparent); if(!plugin->checkSimpleViewer()) { if(!plugin->installSimpleViewer()) { - KMessageBox::error(kapp->activeWindow(), i18n("SimpleViewer installation failed")); + KMessageBox::error(TQT_TQWIDGET(kapp->activeWindow()), i18n("SimpleViewer installation failed")); return; } } @@ -98,8 +98,8 @@ void SimpleViewerExport::run(KIPI::Interface* interface, QObject *parent) delete plugin; } -SimpleViewerExport::SimpleViewerExport(KIPI::Interface* interface, QObject *parent) - : QObject(parent) +SimpleViewerExport::SimpleViewerExport(KIPI::Interface* interface, TQObject *tqparent) + : TQObject(tqparent) { m_interface = interface; m_configDlg = 0; @@ -113,7 +113,7 @@ SimpleViewerExport::SimpleViewerExport(KIPI::Interface* interface, QObject *pare m_simpleViewerFiles.append("swfobject.js"); const KAboutData *data = KApplication::kApplication()->aboutData(); - m_hostName = QString::QString( data->appName() ); + m_hostName = TQString::TQString( data->appName() ); m_hostURL = data->homepage(); if (m_hostURL.isEmpty()) @@ -134,30 +134,30 @@ bool SimpleViewerExport::configure() m_canceled = false; if(!m_configDlg) - m_configDlg = new SVEDialog(m_interface, kapp->activeWindow()); + m_configDlg = new SVEDialog(m_interface, TQT_TQWIDGET(kapp->activeWindow())); bool configured = false; while(!configured) { - if(m_configDlg->exec() == QDialog::Rejected) + if(m_configDlg->exec() == TQDialog::Rejected) return false; configured = true; - if(KIO::NetAccess::exists(m_configDlg->exportURL(), false, kapp->activeWindow())) + if(KIO::NetAccess::exists(m_configDlg->exportURL(), false, TQT_TQWIDGET(kapp->activeWindow()))) { - int ret = KMessageBox::warningYesNoCancel(kapp->activeWindow(), + int ret = KMessageBox::warningYesNoCancel(TQT_TQWIDGET(kapp->activeWindow()), i18n("Target folder %1 already exists.\n" "Do you want to overwrite it (all data in this folder will be lost)") - .arg(m_configDlg->exportURL())); + .tqarg(m_configDlg->exportURL())); switch(ret) { case KMessageBox::Yes: - if(!KIO::NetAccess::del(m_configDlg->exportURL(), kapp->activeWindow())) + if(!KIO::NetAccess::del(m_configDlg->exportURL(), TQT_TQWIDGET(kapp->activeWindow()))) { - KMessageBox::error(kapp->activeWindow(), i18n("Could not delete %1\n" - "Please choose another export folder").arg(m_configDlg->exportURL())); + KMessageBox::error(TQT_TQWIDGET(kapp->activeWindow()), i18n("Could not delete %1\n" + "Please choose another export folder").tqarg(m_configDlg->exportURL())); configured = false; } break; @@ -181,10 +181,10 @@ void SimpleViewerExport::startExport() if(m_canceled) return; - m_progressDlg = new KIPI::BatchProgressDialog(kapp->activeWindow(), i18n("Flash Export")); + m_progressDlg = new KIPI::BatchProgressDialog(TQT_TQWIDGET(kapp->activeWindow()), i18n("Flash Export")); - connect(m_progressDlg, SIGNAL(cancelClicked()), - this, SLOT(slotCancel())); + connect(m_progressDlg, TQT_SIGNAL(cancelClicked()), + this, TQT_SLOT(slotCancel())); m_progressDlg->show(); kapp->processEvents(); @@ -193,7 +193,7 @@ void SimpleViewerExport::startExport() m_progressDlg->addedAction(i18n("Estimate the number of actions to do..."), KIPI::StartingMessage); m_albumsList = m_configDlg->getSelectedAlbums(); m_totalActions = 0; - for( QValueList<KIPI::ImageCollection>::Iterator it = m_albumsList.begin() ; + for( TQValueList<KIPI::ImageCollection>::Iterator it = m_albumsList.begin() ; !m_canceled && (it != m_albumsList.end()) ; ++it ) { m_totalActions += (*it).images().count(); @@ -264,13 +264,13 @@ void SimpleViewerExport::slotProcess() if(m_canceled) { - int ret = KMessageBox::warningYesNo(kapp->activeWindow(), + int ret = KMessageBox::warningYesNo(TQT_TQWIDGET(kapp->activeWindow()), i18n("Export was canceled.\n" "Do you want to delete the yet created files in %1 ?") - .arg(m_configDlg->exportURL())); + .tqarg(m_configDlg->exportURL())); if(ret == KMessageBox::Yes) { - KIO::NetAccess::del(m_configDlg->exportURL(), kapp->activeWindow()); + KIO::NetAccess::del(m_configDlg->exportURL(), TQT_TQWIDGET(kapp->activeWindow())); } } @@ -286,27 +286,27 @@ bool SimpleViewerExport::createExportDirectories() m_progressDlg->addedAction(i18n("Creating directories..."), KIPI::StartingMessage); KURL root = m_configDlg->exportURL(); - if(!KIO::NetAccess::mkdir(root, kapp->activeWindow())) + if(!KIO::NetAccess::mkdir(root, TQT_TQWIDGET(kapp->activeWindow()))) { - m_progressDlg->addedAction(i18n("Could not create folder '%1'").arg(root.url()), + m_progressDlg->addedAction(i18n("Could not create folder '%1'").tqarg(root.url()), KIPI::ErrorMessage); return(false); } KURL thumbsDir = m_tempDir->name(); thumbsDir.addPath("/thumbs"); - if(!KIO::NetAccess::mkdir(thumbsDir, kapp->activeWindow())) + if(!KIO::NetAccess::mkdir(thumbsDir, TQT_TQWIDGET(kapp->activeWindow()))) { - m_progressDlg->addedAction(i18n("Could not create folder '%1'").arg(thumbsDir.url()), + m_progressDlg->addedAction(i18n("Could not create folder '%1'").tqarg(thumbsDir.url()), KIPI::ErrorMessage); return(false); } KURL imagesDir = m_tempDir->name(); imagesDir.addPath("/images"); - if(!KIO::NetAccess::mkdir(imagesDir, kapp->activeWindow())) + if(!KIO::NetAccess::mkdir(imagesDir, TQT_TQWIDGET(kapp->activeWindow()))) { - m_progressDlg->addedAction(i18n("Could not create folder '%1'").arg(imagesDir.url()), + m_progressDlg->addedAction(i18n("Could not create folder '%1'").tqarg(imagesDir.url()), KIPI::ErrorMessage); return(false); } @@ -332,40 +332,40 @@ bool SimpleViewerExport::exportImages() KURL xmlFile(m_tempDir->name()); xmlFile.addPath("/gallery.xml"); - QFile file(xmlFile.path()); + TQFile file(xmlFile.path()); file.open(IO_WriteOnly); - QDomDocument xmlDoc; - xmlDoc.appendChild(xmlDoc.createProcessingInstruction( QString::fromLatin1("xml"), - QString::fromLatin1("version=\"1.0\" encoding=\"UTF-8\"") ) ); - QDomElement galleryElem = xmlDoc.createElement(QString::fromLatin1("simpleviewerGallery")); + TQDomDocument xmlDoc; + xmlDoc.appendChild(xmlDoc.createProcessingInstruction( TQString::tqfromLatin1("xml"), + TQString::tqfromLatin1("version=\"1.0\" encoding=\"UTF-8\"") ) ); + TQDomElement galleryElem = xmlDoc.createElement(TQString::tqfromLatin1("simpleviewerGallery")); xmlDoc.appendChild( galleryElem ); - galleryElem.setAttribute(QString::fromLatin1("maxImageWidth"), m_configDlg->maxImageDimension()); - galleryElem.setAttribute(QString::fromLatin1("maxImageHeight"), m_configDlg->maxImageDimension()); - galleryElem.setAttribute(QString::fromLatin1("textColor"), m_configDlg->textColor().name().replace("#", "0x")); - galleryElem.setAttribute(QString::fromLatin1("frameColor"), m_configDlg->frameColor().name().replace("#", "0x")); - galleryElem.setAttribute(QString::fromLatin1("bgColor"), m_configDlg->backgroundColor().name().replace("#", "0x")); - galleryElem.setAttribute(QString::fromLatin1("frameWidth"), m_configDlg->frameWidth()); - galleryElem.setAttribute(QString::fromLatin1("stagePadding"), m_configDlg->stagePadding()); - galleryElem.setAttribute(QString::fromLatin1("thumbnailColumns"), m_configDlg->thumbnailColumns()); - galleryElem.setAttribute(QString::fromLatin1("thumbnailRows"), m_configDlg->thumbnailRows()); - galleryElem.setAttribute(QString::fromLatin1("navPosition"), m_configDlg->navPosition()); - galleryElem.setAttribute(QString::fromLatin1("navDirection"), m_configDlg->navDirection()); - galleryElem.setAttribute(QString::fromLatin1("title"), m_configDlg->title()); - galleryElem.setAttribute(QString::fromLatin1("imagePath"), QString()); - galleryElem.setAttribute(QString::fromLatin1("thumbPath"), QString()); + galleryElem.setAttribute(TQString::tqfromLatin1("maxImageWidth"), m_configDlg->maxImageDimension()); + galleryElem.setAttribute(TQString::tqfromLatin1("maxImageHeight"), m_configDlg->maxImageDimension()); + galleryElem.setAttribute(TQString::tqfromLatin1("textColor"), TQString(m_configDlg->textColor().name()).tqreplace("#", "0x")); + galleryElem.setAttribute(TQString::tqfromLatin1("frameColor"), TQString(m_configDlg->frameColor().name()).tqreplace("#", "0x")); + galleryElem.setAttribute(TQString::tqfromLatin1("bgColor"), TQString(m_configDlg->backgroundColor().name()).tqreplace("#", "0x")); + galleryElem.setAttribute(TQString::tqfromLatin1("frameWidth"), m_configDlg->frameWidth()); + galleryElem.setAttribute(TQString::tqfromLatin1("stagePadding"), m_configDlg->stagePadding()); + galleryElem.setAttribute(TQString::tqfromLatin1("thumbnailColumns"), m_configDlg->thumbnailColumns()); + galleryElem.setAttribute(TQString::tqfromLatin1("thumbnailRows"), m_configDlg->thumbnailRows()); + galleryElem.setAttribute(TQString::tqfromLatin1("navPosition"), m_configDlg->navPosition()); + galleryElem.setAttribute(TQString::tqfromLatin1("navDirection"), m_configDlg->navDirection()); + galleryElem.setAttribute(TQString::tqfromLatin1("title"), m_configDlg->title()); + galleryElem.setAttribute(TQString::tqfromLatin1("imagePath"), TQString()); + galleryElem.setAttribute(TQString::tqfromLatin1("thumbPath"), TQString()); KExiv2Iface::KExiv2 meta; - QImage image; - QImage thumbnail; - QString tmp; - QString newName; + TQImage image; + TQImage thumbnail; + TQString tmp; + TQString newName; int index = 1; int maxSize = m_configDlg->imagesExportSize(); bool resizeImages = m_configDlg->resizeExportImages(); - for( QValueList<KIPI::ImageCollection>::Iterator it = m_albumsList.begin() ; + for( TQValueList<KIPI::ImageCollection>::Iterator it = m_albumsList.begin() ; !m_canceled && (it != m_albumsList.end()) ; ++it ) { KURL::List images = (*it).images(); @@ -375,44 +375,44 @@ bool SimpleViewerExport::exportImages() { kapp->processEvents(); KURL url = *it; - QFileInfo fileInfo(url.path()); + TQFileInfo fileInfo(url.path()); - m_progressDlg->addedAction(i18n("Processing %1").arg(url.filename()), KIPI::StartingMessage); + m_progressDlg->addedAction(i18n("Processing %1").tqarg(url.filename()), KIPI::StartingMessage); // Check if RAW file. #if KDCRAW_VERSION < 0x000106 - QString rawFilesExt(KDcrawIface::DcrawBinary::instance()->rawFiles()); + TQString rawFilesExt(KDcrawIface::DcrawBinary::instance()->rawFiles()); #else - QString rawFilesExt(KDcrawIface::KDcraw::rawFiles()); + TQString rawFilesExt(KDcrawIface::KDcraw::rawFiles()); #endif - if (rawFilesExt.upper().contains( fileInfo.extension(false).upper() )) + if (rawFilesExt.upper().tqcontains( fileInfo.extension(false).upper() )) KDcrawIface::KDcraw::loadDcrawPreview(image, url.path()); else image.load(url.path()); if(image.isNull()) { - m_progressDlg->addedAction(i18n("Could not open image '%1'").arg(url.filename()), + m_progressDlg->addedAction(i18n("Could not open image '%1'").tqarg(url.filename()), KIPI::WarningMessage); continue; } if(!createThumbnail(image, thumbnail)) { - m_progressDlg->addedAction(i18n("Could not create thumbnail from '%1'").arg(url.filename()), + m_progressDlg->addedAction(i18n("Could not create thumbnail from '%1'").tqarg(url.filename()), KIPI::WarningMessage); continue; } if(resizeImages && !resizeImage(image, maxSize, image)) { - m_progressDlg->addedAction(i18n("Could not resize image '%1'").arg(url.filename()), + m_progressDlg->addedAction(i18n("Could not resize image '%1'").tqarg(url.filename()), KIPI::WarningMessage); continue; } meta.load(url.path()); - newName = QString("%1.%2").arg(tmp.sprintf("%03i", index)).arg(QString("jpg")); + newName = TQString("%1.%2").tqarg(tmp.sprintf("%03i", index)).tqarg(TQString("jpg")); KURL thumbnailPath(thumbsDir); thumbnailPath.addPath(newName); @@ -423,7 +423,7 @@ bool SimpleViewerExport::exportImages() image.save(imagePath.path(), "JPEG"); // Backup metadata from original image. - meta.setImageProgramId(QString("Kipi-plugins"), QString(kipiplugins_version)); + meta.setImageProgramId(TQString("Kipi-plugins"), TQString(kipiplugins_version)); meta.setImageDimensions(image.size()); meta.save(imagePath.path()); @@ -433,8 +433,8 @@ bool SimpleViewerExport::exportImages() } } - QCString data(xmlDoc.toCString()); - QDataStream stream( &file ); + TQCString data(xmlDoc.toCString()); + TQDataStream stream( &file ); stream.writeRawBytes(data.data(), data.size()); file.close(); @@ -443,7 +443,7 @@ bool SimpleViewerExport::exportImages() return true; } -bool SimpleViewerExport::createThumbnail(const QImage &image, QImage &thumbnail) +bool SimpleViewerExport::createThumbnail(const TQImage &image, TQImage &thumbnail) { int w = image.width(); int h = image.height(); @@ -467,7 +467,7 @@ bool SimpleViewerExport::createThumbnail(const QImage &image, QImage &thumbnail) return resizeImage(image, maxSize, thumbnail); } -bool SimpleViewerExport::resizeImage(const QImage &image, int maxSize, QImage &resizedImage) +bool SimpleViewerExport::resizeImage(const TQImage &image, int maxSize, TQImage &resizedImage) { int w = image.width(); int h = image.height(); @@ -492,13 +492,13 @@ bool SimpleViewerExport::resizeImage(const QImage &image, int maxSize, QImage &r return true; } -void SimpleViewerExport::cfgAddImage(QDomDocument &xmlDoc, QDomElement &galleryElem, - const KURL &url, const QString& newName) +void SimpleViewerExport::cfgAddImage(TQDomDocument &xmlDoc, TQDomElement &galleryElem, + const KURL &url, const TQString& newName) { if(m_canceled) return; - QString comment; + TQString comment; if(m_configDlg->showExifComments()) { @@ -507,20 +507,20 @@ void SimpleViewerExport::cfgAddImage(QDomDocument &xmlDoc, QDomElement &galleryE } else { - comment = QString(); + comment = TQString(); } - QDomElement img = xmlDoc.createElement(QString::fromLatin1("image")); + TQDomElement img = xmlDoc.createElement(TQString::tqfromLatin1("image")); galleryElem.appendChild(img); - QDomElement name = xmlDoc.createElement(QString::fromLatin1("name")); + TQDomElement name = xmlDoc.createElement(TQString::tqfromLatin1("name")); img.appendChild(name); - QDomText nametxt = xmlDoc.createTextNode(newName); + TQDomText nametxt = xmlDoc.createTextNode(newName); name.appendChild(nametxt); - QDomElement caption = xmlDoc.createElement(QString::fromLatin1("caption")); + TQDomElement caption = xmlDoc.createElement(TQString::tqfromLatin1("caption")); img.appendChild(caption); - QDomText captiontxt = xmlDoc.createTextNode(comment); + TQDomText captiontxt = xmlDoc.createTextNode(comment); caption.appendChild(captiontxt); } @@ -531,7 +531,7 @@ bool SimpleViewerExport::createIndex() m_progressDlg->addedAction(i18n("Creating index.html..."), KIPI::StartingMessage); - QString indexTemplateName = locate("data", "kipiplugin_simpleviewerexport/index.template"); + TQString indexTemplateName = locate("data", "kipiplugin_simpleviewerexport/index.template"); if(indexTemplateName.isEmpty()) { //TODO: errormsg @@ -539,21 +539,21 @@ bool SimpleViewerExport::createIndex() return false; } - QFile infile(indexTemplateName); + TQFile infile(indexTemplateName); infile.open(IO_ReadOnly); - QTextStream in(&infile); - QString indexTemplate = in.read(); + TQTextStream in(&infile); + TQString indexTemplate = in.read(); infile.close(); - indexTemplate.replace("{TITLE}", m_configDlg->title()); - indexTemplate.replace("{COLOR}", m_configDlg->textColor().name()); - indexTemplate.replace("{BGCOLOR}", m_configDlg->backgroundColor().name()); - indexTemplate.replace("{HOSTURL}", m_hostURL); - indexTemplate.replace("{HOSTNAME}", m_hostName); + indexTemplate.tqreplace("{TITLE}", m_configDlg->title()); + indexTemplate.tqreplace("{COLOR}", m_configDlg->textColor().name()); + indexTemplate.tqreplace("{BGCOLOR}", m_configDlg->backgroundColor().name()); + indexTemplate.tqreplace("{HOSTURL}", m_hostURL); + indexTemplate.tqreplace("{HOSTNAME}", m_hostName); - QFile outfile(m_tempDir->name() + "/index.html"); + TQFile outfile(m_tempDir->name() + "/index.html"); outfile.open(IO_WriteOnly); - QTextStream out(&outfile); + TQTextStream out(&outfile); out << indexTemplate; outfile.close(); @@ -570,7 +570,7 @@ bool SimpleViewerExport::copySimpleViewer() m_progressDlg->addedAction(i18n("Copying flash files..."), KIPI::StartingMessage); - QString dataDir; + TQString dataDir; // Due to its license, simpleviewer is installed in $KDEHOME dataDir = locate("data", "kipiplugin_simpleviewerexport/simpleviewer/"); @@ -579,13 +579,13 @@ bool SimpleViewerExport::copySimpleViewer() if(dataDir.isEmpty()) return false; - QStringList files; - QStringList entries; - QDir dir; + TQStringList files; + TQStringList entries; + TQDir dir; dir.setPath(dataDir); - entries = dir.entryList(QDir::Files); - for(QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) + entries = dir.entryList(TQDir::Files); + for(TQStringList::Iterator it = entries.begin(); it != entries.end(); ++it) { files.append(dir.absPath() + "/" + *it); } @@ -593,8 +593,8 @@ bool SimpleViewerExport::copySimpleViewer() // files distributed with the plugin are installed in $KDEDIRS dataDir = locate("data", "kipiplugin_simpleviewerexport/simpleviewer_html/"); dir.setPath(dataDir); - entries = dir.entryList(QDir::Files); - for(QStringList::Iterator it = entries.begin(); it != entries.end(); ++it) + entries = dir.entryList(TQDir::Files); + for(TQStringList::Iterator it = entries.begin(); it != entries.end(); ++it) { files.append(dir.absPath() + "/" + *it); } @@ -628,10 +628,10 @@ bool SimpleViewerExport::checkSimpleViewer() const bool SimpleViewerExport::installSimpleViewer() { - FirstRunDlg *firstRunDlg = new FirstRunDlg(kapp->activeWindow()); - if(firstRunDlg->exec() == QDialog::Accepted) + FirstRunDlg *firstRunDlg = new FirstRunDlg(TQT_TQWIDGET(kapp->activeWindow())); + if(firstRunDlg->exec() == TQDialog::Accepted) { - QString url = firstRunDlg->getURL(); + TQString url = firstRunDlg->getURL(); delete firstRunDlg; if(unzip(url)) @@ -647,7 +647,7 @@ bool SimpleViewerExport::installSimpleViewer() return false; } -bool SimpleViewerExport::unzip(const QString &url) +bool SimpleViewerExport::unzip(const TQString &url) { KZip zip(url); @@ -672,7 +672,7 @@ bool SimpleViewerExport::openArchive(KZip &zip) bool SimpleViewerExport::extractArchive(KZip &zip) { // read root directory content - QStringList names = zip.directory()->entries(); + TQStringList names = zip.directory()->entries(); if(names.count() != 1) { kdDebug() << "Wrong SimpleViewer Version or corrupted archive" << endl; @@ -691,7 +691,7 @@ bool SimpleViewerExport::extractArchive(KZip &zip) const KArchiveDirectory *dir = dynamic_cast<const KArchiveDirectory*>(root); // extract the needed files from SimpleViewer archive - for(QStringList::Iterator it = m_simpleViewerFiles.begin(); + for(TQStringList::Iterator it = m_simpleViewerFiles.begin(); it != m_simpleViewerFiles.end(); ++it ) { const KArchiveEntry *entry = dir->entry(*it); @@ -712,9 +712,9 @@ bool SimpleViewerExport::extractFile(const KArchiveEntry *entry) return false; const KArchiveFile *entryFile = dynamic_cast<const KArchiveFile*>(entry); - QByteArray array = entryFile->data(); + TQByteArray array = entryFile->data(); - QFile file( m_dataLocal + entry->name() ); + TQFile file( m_dataLocal + entry->name() ); if(file.open( IO_WriteOnly )) { int ret = file.writeBlock(array); |