author | zecke <zecke> | 2002-10-05 20:49:38 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-05 20:49:38 (UTC) |
commit | 19c0a4610292a95281a64655cef9c2d695a214dc (patch) (side-by-side diff) | |
tree | dde4afda2629a6e10d545d9492ada7b43e431ee7 /libopie/ofileselector/opixmapprovider.cpp | |
parent | d7f9d00fcc9261db9c4af4f1b4afde9d50e8a2a2 (diff) | |
download | opie-19c0a4610292a95281a64655cef9c2d695a214dc.zip opie-19c0a4610292a95281a64655cef9c2d695a214dc.tar.gz opie-19c0a4610292a95281a64655cef9c2d695a214dc.tar.bz2 |
more steps to make ofileselector modular
We now got the API for a factory so switching should work in future
and we now got a OPixmapProvider which provides us with pixmaps....
So an ImageViewer could install a differen OPixmapProvider
and a different OFileView to make Previewing
work
Diffstat (limited to 'libopie/ofileselector/opixmapprovider.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/ofileselector/opixmapprovider.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/libopie/ofileselector/opixmapprovider.cpp b/libopie/ofileselector/opixmapprovider.cpp new file mode 100644 index 0000000..b363e01 --- a/dev/null +++ b/libopie/ofileselector/opixmapprovider.cpp @@ -0,0 +1,83 @@ +#include <qfileinfo.h> + +#include <qpe/mimetype.h> +#include <qpe/resource.h> + +#include "opixmapprovider.h" + + + +OPixmapProvider::OPixmapProvider( OFileSelector* sel ) + : m_sel( sel ){ +} +OPixmapProvider::~OPixmapProvider() { +} +QPixmap OPixmapProvider::pixmap( int t, const QString& , + QFileInfo* info, bool isL ) { + QPixmap pix; + bool sy = t & Symlink ? true : false; + switch (t ) { + case File: + pix = file( info, sy, isL ); + break; + case Dir: + pix = dir( info, sy, isL ); + break; + case Symlink: + pix = sym( info, isL ); + break; + } + return pix; + +} +QPixmap OPixmapProvider::pixmap( int t, const QString& mime, + const QString& dir, const QString& file, + bool isL) { + QFileInfo *inf = new QFileInfo( dir + "/" + file ); + QPixmap pix = pixmap( t, mime, inf, isL ); + delete inf; + return pix; +} +OFileSelector* OPixmapProvider::selector() { + return m_sel; +} +QPixmap OPixmapProvider::file( QFileInfo* inf, bool , bool ) { + MimeType type( inf->absFilePath() ); + QPixmap pix = type.pixmap(); + + if ( pix.isNull() ) + pix = Resource::loadPixmap( "UnknownDocument-14"); + + if ( (selector()->mode() == OFileSelector::Open && + !inf->isReadable() ) || + (selector()->mode() == OFileSelector::Save && + !inf->isWritable() ) ) { + pix = Resource::loadPixmap( "locked" ); + } + return pix; + +} +QPixmap OPixmapProvider::dir( QFileInfo* inf, bool sym, bool ) { + QPixmap pix; + /* + * look at selector()->mode() and determine + * if a dir is locked + */ + if ( (selector()->mode() == OFileSelector::Open && + !inf->isReadable() ) || + (selector()->mode() == OFileSelector::Save && + !inf->isWritable() ) ) { + if ( sym ) + pix = selector()->pixmap("symlinkedlocked"); + else + pix = Resource::loadPixmap("lockedfolder"); + }else { + pix = sym ? selector()->pixmap("lockedfolder") : + Resource::loadPixmap("folder"); + + } + return pix; +} +QPixmap OPixmapProvider::sym( QFileInfo* , bool ) { + return Resource::loadPixmap("opie/symlink"); +} |