summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/umlviewimageexportermodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'umbrello/umbrello/umlviewimageexportermodel.cpp')
-rw-r--r--umbrello/umbrello/umlviewimageexportermodel.cpp152
1 files changed, 76 insertions, 76 deletions
diff --git a/umbrello/umbrello/umlviewimageexportermodel.cpp b/umbrello/umbrello/umlviewimageexportermodel.cpp
index e829a3f7..7f34c104 100644
--- a/umbrello/umbrello/umlviewimageexportermodel.cpp
+++ b/umbrello/umbrello/umlviewimageexportermodel.cpp
@@ -16,14 +16,14 @@
#include <math.h>
// include files for Qt
-#include <qstringlist.h>
-#include <qrect.h>
-#include <qimage.h>
-#include <qpicture.h>
-#include <qpainter.h>
-#include <qprinter.h>
-#include <qdir.h>
-#include <qregexp.h>
+#include <tqstringlist.h>
+#include <tqrect.h>
+#include <tqimage.h>
+#include <tqpicture.h>
+#include <tqpainter.h>
+#include <tqprinter.h>
+#include <tqdir.h>
+#include <tqregexp.h>
// kde include files
#include <kdebug.h>
@@ -39,30 +39,30 @@
#include "umllistview.h"
#include "umllistviewitem.h"
-static QStringList supportedImageTypesList;
-static QStringList supportedMimeTypesList;
+static TQStringList supportedImageTypesList;
+static TQStringList supportedMimeTypesList;
-QStringList UMLViewImageExporterModel::supportedImageTypes() {
+TQStringList UMLViewImageExporterModel::supportedImageTypes() {
if (!supportedImageTypesList.size()) {
// specific supported formats
supportedImageTypesList << "eps";
supportedImageTypesList << "svg";
// QT supported formats
- QStrList qImageFormats = QImage::outputFormats();
+ TQStrList qImageFormats = TQImage::outputFormats();
for (const char* format = qImageFormats.first(); format; format = qImageFormats.next()) {
- supportedImageTypesList << QString(format).lower();
+ supportedImageTypesList << TQString(format).lower();
}
}
return supportedImageTypesList;
}
-QStringList UMLViewImageExporterModel::supportedMimeTypes() {
+TQStringList UMLViewImageExporterModel::supportedMimeTypes() {
if (!supportedMimeTypesList.size()) {
- QStringList imageTypes = UMLViewImageExporterModel::supportedImageTypes();
- for(QStringList::Iterator it = imageTypes.begin(); it != imageTypes.end(); ++it ) {
- QString mimeType = imageTypeToMimeType(*it);
+ TQStringList imageTypes = UMLViewImageExporterModel::supportedImageTypes();
+ for(TQStringList::Iterator it = imageTypes.begin(); it != imageTypes.end(); ++it ) {
+ TQString mimeType = imageTypeToMimeType(*it);
if (!mimeType.isNull())
supportedMimeTypesList.append(mimeType);
}
@@ -71,47 +71,47 @@ QStringList UMLViewImageExporterModel::supportedMimeTypes() {
return supportedMimeTypesList;
}
-QString UMLViewImageExporterModel::imageTypeToMimeType(const QString& imageType) {
- const QString imgType = imageType.lower();
- if (QString("bmp") == imgType) return "image/x-bmp";
- if (QString("jpeg") == imgType) return "image/jpeg";
- if (QString("pbm") == imgType) return "image/x-portable-bitmap";
- if (QString("pgm") == imgType) return "image/x-portable-greymap";
- if (QString("png") == imgType) return "image/png";
- if (QString("ppm") == imgType) return "image/x-portable-pixmap";
- if (QString("xbm") == imgType) return "image/x-xbm";
- if (QString("xpm") == imgType) return "image/x-xpm";
- if (QString("eps") == imgType) return "image/x-eps";
- if (QString("svg") == imgType) return "image/svg+xml";
- return QString::null;
+TQString UMLViewImageExporterModel::imageTypeToMimeType(const TQString& imageType) {
+ const TQString imgType = imageType.lower();
+ if (TQString("bmp") == imgType) return "image/x-bmp";
+ if (TQString("jpeg") == imgType) return "image/jpeg";
+ if (TQString("pbm") == imgType) return "image/x-portable-bitmap";
+ if (TQString("pgm") == imgType) return "image/x-portable-greymap";
+ if (TQString("png") == imgType) return "image/png";
+ if (TQString("ppm") == imgType) return "image/x-portable-pixmap";
+ if (TQString("xbm") == imgType) return "image/x-xbm";
+ if (TQString("xpm") == imgType) return "image/x-xpm";
+ if (TQString("eps") == imgType) return "image/x-eps";
+ if (TQString("svg") == imgType) return "image/svg+xml";
+ return TQString::null;
}
-QString UMLViewImageExporterModel::mimeTypeToImageType(const QString& mimeType) {
- if (QString("image/x-bmp") == mimeType) return "bmp";
- if (QString("image/jpeg") == mimeType) return "jpeg";
- if (QString("image/x-portable-bitmap") == mimeType) return "pbm";
- if (QString("image/x-portable-greymap") == mimeType) return "pgm";
- if (QString("image/png") == mimeType) return "png";
- if (QString("image/x-portable-pixmap") == mimeType) return "ppm";
- if (QString("image/x-xbm") == mimeType) return "xbm";
- if (QString("image/x-xpm") == mimeType) return "xpm";
- if (QString("image/x-eps") == mimeType) return "eps";
- if (QString("image/svg+xml") == mimeType) return "svg";
- return QString::null;
+TQString UMLViewImageExporterModel::mimeTypeToImageType(const TQString& mimeType) {
+ if (TQString("image/x-bmp") == mimeType) return "bmp";
+ if (TQString("image/jpeg") == mimeType) return "jpeg";
+ if (TQString("image/x-portable-bitmap") == mimeType) return "pbm";
+ if (TQString("image/x-portable-greymap") == mimeType) return "pgm";
+ if (TQString("image/png") == mimeType) return "png";
+ if (TQString("image/x-portable-pixmap") == mimeType) return "ppm";
+ if (TQString("image/x-xbm") == mimeType) return "xbm";
+ if (TQString("image/x-xpm") == mimeType) return "xpm";
+ if (TQString("image/x-eps") == mimeType) return "eps";
+ if (TQString("image/svg+xml") == mimeType) return "svg";
+ return TQString::null;
}
-QStringList UMLViewImageExporterModel::exportAllViews(const QString &imageType, const KURL &directory, bool useFolders) const {
+TQStringList UMLViewImageExporterModel::exportAllViews(const TQString &imageType, const KURL &directory, bool useFolders) const {
UMLApp *app = UMLApp::app();
// contains all the error messages returned by exportView calls
- QStringList errors;
+ TQStringList errors;
UMLViewList views = app->getDocument()->getViewIterator();
for(UMLView *view = views.first(); view; view = views.next()) {
KURL url = directory;
url.addPath(getDiagramFileName(view, imageType, useFolders));
- QString returnString = exportView(view, imageType, url);
+ TQString returnString = exportView(view, imageType, url);
if (!returnString.isNull()) {
errors.append(view->getName() + ": " + returnString);
}
@@ -120,7 +120,7 @@ QStringList UMLViewImageExporterModel::exportAllViews(const QString &imageType,
return errors;
}
-QString UMLViewImageExporterModel::exportView(UMLView* view, const QString &imageType, const KURL &url) const {
+TQString UMLViewImageExporterModel::exportView(UMLView* view, const TQString &imageType, const KURL &url) const {
// create the needed directories
if (!prepareDirectory(url)) {
return i18n("Can not create directory: %1").arg(url.directory());
@@ -129,7 +129,7 @@ QString UMLViewImageExporterModel::exportView(UMLView* view, const QString &imag
// The fileName will be used when exporting the image. If the url isn't local,
// the fileName is the name of a temporal local file to export the image to, and then
// upload it to its destiny
- QString fileName;
+ TQString fileName;
// tmpFile needs to be unlinked before exiting the method!!!
KTempFile tmpFile;
if (url.isLocalFile()) {
@@ -139,7 +139,7 @@ QString UMLViewImageExporterModel::exportView(UMLView* view, const QString &imag
}
// check that the diagram isn't empty
- QRect rect = view->getDiagramRect();
+ TQRect rect = view->getDiagramRect();
if (rect.isEmpty()) {
tmpFile.unlink();
return i18n("Can not save an empty diagram");
@@ -160,11 +160,11 @@ QString UMLViewImageExporterModel::exportView(UMLView* view, const QString &imag
} //!isLocalFile
tmpFile.unlink();
- return QString::null;
+ return TQString::null;
}
-QString UMLViewImageExporterModel::getDiagramFileName(UMLView *view, const QString &imageType, bool useFolders /* = false */) const {
- QString name = view->getName() + '.' + imageType.lower();
+TQString UMLViewImageExporterModel::getDiagramFileName(UMLView *view, const TQString &imageType, bool useFolders /* = false */) const {
+ TQString name = view->getName() + '.' + imageType.lower();
if (!useFolders) {
return name;
@@ -194,8 +194,8 @@ bool UMLViewImageExporterModel::prepareDirectory(const KURL &url) const {
directory.setPath("");
// creates the directory and any needed parent directories
- QStringList dirs = QStringList::split(QDir::separator(), url.directory());
- for (QStringList::ConstIterator it = dirs.begin() ; it != dirs.end(); ++it ) {
+ TQStringList dirs = TQStringList::split(TQDir::separator(), url.directory());
+ for (TQStringList::ConstIterator it = dirs.begin() ; it != dirs.end(); ++it ) {
directory.addPath(*it);
if (!KIO::NetAccess::exists(directory, true, UMLApp::app())) {
@@ -209,11 +209,11 @@ bool UMLViewImageExporterModel::prepareDirectory(const KURL &url) const {
return true;
}
-bool UMLViewImageExporterModel::exportViewTo(UMLView* view, const QString &imageType, const QString &fileName) const {
+bool UMLViewImageExporterModel::exportViewTo(UMLView* view, const TQString &imageType, const TQString &fileName) const {
// remove 'blue squares' from exported picture.
view->clearSelected();
- QString imageMimeType = UMLViewImageExporterModel::imageTypeToMimeType(imageType);
+ TQString imageMimeType = UMLViewImageExporterModel::imageTypeToMimeType(imageType);
if (imageMimeType == "image/x-eps") {
if (!exportViewToEps(view, fileName, true)) {
return false;
@@ -231,7 +231,7 @@ bool UMLViewImageExporterModel::exportViewTo(UMLView* view, const QString &image
return true;
}
-bool UMLViewImageExporterModel::exportViewToEps(UMLView* view, const QString &fileName, bool isEPS) const {
+bool UMLViewImageExporterModel::exportViewToEps(UMLView* view, const TQString &fileName, bool isEPS) const {
bool exportSuccessful = true;
// print the image to a normal postscript file,
@@ -241,27 +241,27 @@ bool UMLViewImageExporterModel::exportViewToEps(UMLView* view, const QString &fi
// because we want to work with postscript
// user-coordinates, set to the resolution
// of the printer (which should be 72dpi here)
- QPrinter *printer;
+ TQPrinter *printer;
if (isEPS == false) {
- printer = new QPrinter(QPrinter::PrinterResolution);
+ printer = new TQPrinter(TQPrinter::PrinterResolution);
} else {
- printer = new QPrinter(QPrinter::ScreenResolution);
+ printer = new TQPrinter(TQPrinter::ScreenResolution);
}
printer->setOutputToFile(true);
printer->setOutputFileName(fileName);
- printer->setColorMode(QPrinter::Color);
+ printer->setColorMode(TQPrinter::Color);
// do not call printer.setup(); because we want no user
// interaction here
- QPainter *painter = new QPainter(printer);
+ TQPainter *painter = new TQPainter(printer);
// make sure the widget sizes will be according to the
// actually used printer font, important for getDiagramRect()
// and the actual painting
view->forceUpdateWidgetFontMetrics(painter);
- QRect rect = view->getDiagramRect();
+ TQRect rect = view->getDiagramRect();
painter->translate(-rect.x(),-rect.y());
view->getDiagram(rect,*painter);
@@ -282,19 +282,19 @@ bool UMLViewImageExporterModel::exportViewToEps(UMLView* view, const QString &fi
return exportSuccessful;
}
-bool UMLViewImageExporterModel::fixEPS(const QString &fileName, const QRect& rect) const {
+bool UMLViewImageExporterModel::fixEPS(const TQString &fileName, const TQRect& rect) const {
// now open the file and make a correct eps out of it
- QFile epsfile(fileName);
+ TQFile epsfile(fileName);
if (! epsfile.open(IO_ReadOnly)) {
return false;
}
// read
- QTextStream ts(&epsfile);
- QString fileContent = ts.read();
+ TQTextStream ts(&epsfile);
+ TQString fileContent = ts.read();
epsfile.close();
// read information
- QRegExp rx("%%BoundingBox:\\s*(-?[\\d\\.:]+)\\s*(-?[\\d\\.:]+)\\s*(-?[\\d\\.:]+)\\s*(-?[\\d\\.:]+)");
+ TQRegExp rx("%%BoundingBox:\\s*(-?[\\d\\.:]+)\\s*(-?[\\d\\.:]+)\\s*(-?[\\d\\.:]+)\\s*(-?[\\d\\.:]+)");
const int pos = rx.search(fileContent);
if (pos < 0) {
kError() << "UMLViewImageExporterModel::fixEPS(" << fileName
@@ -320,7 +320,7 @@ bool UMLViewImageExporterModel::fixEPS(const QString &fileName, const QRect& rec
// modify content
fileContent.replace(pos,rx.cap(0).length(),
- QString("%%BoundingBox: %1 %2 %3 %4").arg(left).arg(bottom).arg(right).arg(top));
+ TQString("%%BoundingBox: %1 %2 %3 %4").arg(left).arg(bottom).arg(right).arg(top));
ts << fileContent;
epsfile.close();
@@ -328,14 +328,14 @@ bool UMLViewImageExporterModel::fixEPS(const QString &fileName, const QRect& rec
return true;
}
-bool UMLViewImageExporterModel::exportViewToSvg(UMLView* view, const QString &fileName) const {
+bool UMLViewImageExporterModel::exportViewToSvg(UMLView* view, const TQString &fileName) const {
bool exportSuccesful;
- QPicture* diagram = new QPicture();
+ TQPicture* diagram = new TQPicture();
// do not call printer.setup(); because we want no user
// interaction here
- QPainter* painter = new QPainter();
+ TQPainter* painter = new TQPainter();
painter->begin( diagram );
// make sure the widget sizes will be according to the
@@ -343,11 +343,11 @@ bool UMLViewImageExporterModel::exportViewToSvg(UMLView* view, const QString &fi
// and the actual painting
view->forceUpdateWidgetFontMetrics(painter);
- QRect rect = view->getDiagramRect();
+ TQRect rect = view->getDiagramRect();
painter->translate(-rect.x(),-rect.y());
view->getDiagram(rect,*painter);
painter->end();
- exportSuccesful = diagram->save(fileName, QString("SVG").ascii());
+ exportSuccesful = diagram->save(fileName, TQString("SVG").ascii());
// delete painter and printer before we try to open and fix the file
delete painter;
@@ -358,9 +358,9 @@ bool UMLViewImageExporterModel::exportViewToSvg(UMLView* view, const QString &fi
return exportSuccesful;
}
-bool UMLViewImageExporterModel::exportViewToPixmap(UMLView* view, const QString &imageType, const QString &fileName) const {
- QRect rect = view->getDiagramRect();
- QPixmap diagram(rect.width(), rect.height());
+bool UMLViewImageExporterModel::exportViewToPixmap(UMLView* view, const TQString &imageType, const TQString &fileName) const {
+ TQRect rect = view->getDiagramRect();
+ TQPixmap diagram(rect.width(), rect.height());
view->getDiagram(rect, diagram);
return diagram.save(fileName, imageType.upper().ascii());
}