1.1 --- a/misc.cpp Sun Jan 30 12:58:47 2005 +0000
1.2 +++ b/misc.cpp Wed Jul 05 10:29:54 2006 +0000
1.3 @@ -1,14 +1,20 @@
1.4 +#include <math.h>
1.5 +
1.6 #include <qregexp.h>
1.7 #include <qpoint.h>
1.8 -
1.9 -#include <math.h>
1.10 +#include <stdlib.h>
1.11
1.12 #include "misc.h"
1.13
1.14 +QString qpointToString (const QPoint &p)
1.15 +{
1.16 + return "(" + QString("%1").arg(p.x()) +","+ QString ("%1").arg (p.y()) +")";
1.17 +}
1.18
1.19 ostream &operator<< (ostream &stream, QPoint const &p)
1.20 {
1.21 - return (stream << "(" << p.x() << "," << p.y() << ")");
1.22 + stream << "("<<p.x()<<","<<p.y()<<")";
1.23 + return stream;
1.24 }
1.25
1.26 float getAngle(const QPoint &p)
1.27 @@ -65,49 +71,6 @@
1.28 return QPoint ((int) (x),(int) (y));
1.29 }
1.30
1.31 -QString maskPath(QString p)
1.32 -{
1.33 - // Change " " to "\ " to enable blanks in filenames
1.34 - p=p.replace(QChar('&'),"\\&");
1.35 - return p.replace(QChar(' '),"\\ ");
1.36 -}
1.37 -
1.38 -QString convertToRel (const QString &src, const QString &dst)
1.39 -{
1.40 - QString s=src;
1.41 - QString d=dst;
1.42 - int i;
1.43 - // Find relative path from src to dst
1.44 -
1.45 - // Remove the first "/"
1.46 - if (s.section ("/",0,0).isEmpty())
1.47 - {
1.48 - s=s.right (s.length()-1);
1.49 - d=d.right (d.length()-1);
1.50 - }
1.51 -
1.52 - // remove identical left parts
1.53 - while (s.section("/",0,0) == d.section("/",0,0) )
1.54 - {
1.55 - i=s.find ("/");
1.56 - s=s.right (s.length()-i-1);
1.57 - d=d.right (d.length()-i-1);
1.58 - }
1.59 -
1.60 - int srcsep=s.contains("/");
1.61 - int dstsep=d.contains("/");
1.62 - if (srcsep >= dstsep )
1.63 - {
1.64 - // find path to go up first and then back to dst
1.65 - i=1;
1.66 - while (i<=srcsep)
1.67 - {
1.68 - d="../"+d;
1.69 - i++;
1.70 - }
1.71 - }
1.72 - return d;
1.73 -}
1.74
1.75 // returns masked "<" ">" "&"
1.76 QString quotemeta(const QString &s)
1.77 @@ -203,36 +166,3 @@
1.78 return s;
1.79 }
1.80
1.81 -
1.82 -
1.83 -ImagePreview::ImagePreview (QWidget *parent=0): QLabel (parent)
1.84 -{
1.85 -}
1.86 -
1.87 -void ImagePreview::previewUrl( const QUrl &u )
1.88 -{
1.89 - QString path = u.path();
1.90 - QPixmap pix( path );
1.91 - if ( pix.isNull() )
1.92 - setText( QObject::tr("This is not an image.") );
1.93 - else
1.94 - {
1.95 - float max_w=300;
1.96 - float max_h=300;
1.97 - float r;
1.98 - if (pix.width()>max_w)
1.99 - {
1.100 - r=max_w / pix.width();
1.101 - pix.resize(lrint(pix.width()*r), lrint(pix.height()*r));
1.102 - // TODO not a resize, but a shrink/enlarge is needed here...
1.103 - }
1.104 - if (pix.height()>max_h)
1.105 - {
1.106 - r=max_h / pix.height();
1.107 - pix.resize(lrint(pix.width()*r), lrint(pix.height()*r));
1.108 - // TODO not a resize, but a shrink/enlarge is needed here...
1.109 - }
1.110 - setPixmap( pix );
1.111 - }
1.112 -}
1.113 -