diff -r 325958acb69b -r 2eeafc34e470 misc.cpp --- a/misc.cpp Mon Oct 10 11:20:25 2005 +0000 +++ b/misc.cpp Mon Apr 24 10:05:10 2006 +0000 @@ -70,127 +70,6 @@ return QPoint ((int) (x),(int) (y)); } -QString maskPath(QString p) -{ - // Change " " to "\ " to enable blanks in filenames - p=p.replace(QChar('&'),"\\&"); - return p.replace(QChar(' '),"\\ "); -} - -QString convertToRel (const QString &src, const QString &dst) -{ - QString s=src; - QString d=dst; - int i; - - if (s==d) - { - // Special case, we just need the name of the file, - // not the complete path - i=d.findRev ("/"); - d=d.right (d.length()-i-1); - } else - { - // Find relative path from src to dst - - // Remove the first "/" - if (s.section ("/",0,0).isEmpty()) - { - s=s.right (s.length()-1); - d=d.right (d.length()-1); - } - - // remove identical left parts - while (s.section("/",0,0) == d.section("/",0,0) ) - { - i=s.find ("/"); - s=s.right (s.length()-i-1); - d=d.right (d.length()-i-1); - } - - int srcsep=s.contains("/"); - int dstsep=d.contains("/"); - if (srcsep >= dstsep ) - { - // find path to go up first and then back to dst - i=1; - while (i<=srcsep) - { - d="../"+d; - i++; - } - } - } - return d; -} - -QString makeUniqueDir (QString s) -{ - char *p; - int bytes=s.length(); - p=(char*) malloc (bytes+1); - int i; - for (i=0;ifileName() != "." && fi->fileName() != ".." ) - { - if ( !d.cd(fi->fileName()) ) - qWarning ("removeDir() cannot find the directory "+fi->fileName()); - else - { - // Recursively remove subdirs - removeDir (d); - d.cdUp(); - } - } - ++itdir; - } - // Traverse files - d.setFilter( QDir::Files| QDir::Hidden | QDir::NoSymLinks ); - const QFileInfoList *filelist = d.entryInfoList(); - QFileInfoListIterator itfile( *filelist ); - - while ( (fi = itfile.current()) != 0 ) - { - QFile (fi->filePath()).remove(); - - ++itfile; - } - - if (!d.rmdir(d.path())) - qWarning ("removeDir("+d.path()+") failed!"); -} - -void makeSubDirs (const QString &s) -{ - QDir d(s); - d.mkdir(s); - d.mkdir ("images"); - d.mkdir ("flags"); -} // returns masked "<" ">" "&" QString quotemeta(const QString &s) @@ -286,36 +165,3 @@ return s; } - - -ImagePreview::ImagePreview (QWidget *parent=0): QLabel (parent) -{ -} - -void ImagePreview::previewUrl( const QUrl &u ) -{ - QString path = u.path(); - QPixmap pix( path ); - if ( pix.isNull() ) - setText( QObject::tr("This is not an image.") ); - else - { - float max_w=300; - float max_h=300; - float r; - if (pix.width()>max_w) - { - r=max_w / pix.width(); - pix.resize(qRound(pix.width()*r), qRound(pix.height()*r)); - // TODO not a resize, but a shrink/enlarge is needed here... - } - if (pix.height()>max_h) - { - r=max_h / pix.height(); - pix.resize(qRound(pix.width()*r), qRound(pix.height()*r)); - // TODO not a resize, but a shrink/enlarge is needed here... - } - setPixmap( pix ); - } -} -