# HG changeset patch # User insilmaril # Date 1136281481 0 # Node ID f75489896084ad6e0146d521a611ebb83c1a837e # Parent 728f51b71e7132fac2ddc0bffeb2c87f8b720c8a 1.7.6 New features for floatimages and fixes diff -r 728f51b71e71 -r f75489896084 misc.cpp --- a/misc.cpp Tue Jan 03 09:44:41 2006 +0000 +++ b/misc.cpp Tue Jan 03 09:44:41 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 ); - } -} - diff -r 728f51b71e71 -r f75489896084 misc.h --- a/misc.h Tue Jan 03 09:44:41 2006 +0000 +++ b/misc.h Tue Jan 03 09:44:41 2006 +0000 @@ -7,19 +7,12 @@ using namespace std; -enum LoadMode {NewMap,ImportAdd,ImportReplace}; -enum SaveMode {PartOfMap,CompleteMap,UndoCommand}; ///////////////////////////////////////////////////////////////////////////// QString qpointToString (const QPoint &p); extern ostream &operator<< (ostream &stream, QPoint const &p); float getAngle(const QPoint &); QPoint normalise (const QPoint &); -QString maskPath (QString ); -QString convertToRel (const QString &,const QString &); -QString makeUniqueDir (QString); -void removeDir(QDir); -void makeSubDirs (const QString &); QString quotemeta(const QString&); int max (int,int); class BranchObj; @@ -46,17 +39,4 @@ int indentwidth; }; -///////////////////////////////////////////////////////////////////////////// - -#include -#include -#include - -class ImagePreview : public QLabel, public QFilePreview -{ -public: - ImagePreview( QWidget * ); - void previewUrl( const QUrl & ); -}; - #endif