summaryrefslogtreecommitdiff
path: root/noncore/graphics/opie-eye/lib
Unidiff
Diffstat (limited to 'noncore/graphics/opie-eye/lib') (more/less context) (show whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/lib/imagecache.cpp87
-rw-r--r--noncore/graphics/opie-eye/lib/imagecache.h46
-rw-r--r--noncore/graphics/opie-eye/lib/slavemaster.cpp145
-rw-r--r--noncore/graphics/opie-eye/lib/slavemaster.h43
-rw-r--r--noncore/graphics/opie-eye/lib/viewmap.cpp25
5 files changed, 346 insertions, 0 deletions
diff --git a/noncore/graphics/opie-eye/lib/imagecache.cpp b/noncore/graphics/opie-eye/lib/imagecache.cpp
new file mode 100644
index 0000000..3b74a83
--- a/dev/null
+++ b/noncore/graphics/opie-eye/lib/imagecache.cpp
@@ -0,0 +1,87 @@
1/*
2 * GPLv2 zecke@handhelds.org
3 * No WArranty...
4 */
5
6#include <iface/dirview.h>
7#include <iface/dirlister.h>
8
9#include "imagecache.h"
10
11namespace {
12 PImageCache * _imgCache = 0;
13 PPixmapCache* _pxmCache = 0;
14}
15
16
17PImageCache::PImageCache()
18 : QCache<QImage>()
19{
20 /* just to set an initial value.. 4 big images */
21 setMaxCost( (1024*1024*16)/8*4 );
22}
23
24PImageCache::~PImageCache() {
25}
26
27PImageCache* PImageCache::self() {
28 if ( !_imgCache )
29 _imgCache = new PImageCache;
30 return _imgCache;
31}
32
33QImage* PImageCache::cachedImage( const QString& _path, int ori, int max ) {
34 QString path = QString( "%1_%2:" ).arg( ori ).arg( max );
35 path += _path;
36
37 QImage* img = find( path );
38 if ( !img ) {
39// img = currentView()->dirLister()->image( _path, PDirLister::Factor(ori), max);
40// insertImage( _path, img, ori, max );
41 currentView()->dirLister()->image( _path, PDirLister::Factor( ori ), max );
42 }
43
44
45 return img;
46}
47
48void PImageCache::insertImage( const QString& _path, const QImage* img, int ori, int max ) {
49 QString path = QString("%1_%2:" ).arg( ori ).arg( max );
50 path += _path;
51 insert( path, img, (img->height()*img->width()*img->depth())/8 );
52}
53
54
55PPixmapCache::PPixmapCache() {
56 /*
57 * 20 64x64 16 bit images
58 */
59 setMaxCost( 64*64*QPixmap::defaultDepth()/8*20 );
60}
61
62PPixmapCache::~PPixmapCache() {
63}
64
65PPixmapCache* PPixmapCache::self() {
66 if ( !_pxmCache )
67 _pxmCache = new PPixmapCache;
68
69 return _pxmCache;
70}
71
72QPixmap* PPixmapCache::cachedImage( const QString& _path, int width, int height ) {
73 QString path = QString( "%1_%2:" ).arg( width ).arg( height );
74 path += _path;
75
76 QPixmap* pxm = find( path );
77
78
79
80 return pxm;
81}
82
83void PPixmapCache::insertImage( const QString& _path, const QPixmap* pix, int width, int height ) {
84 QString path = QString("%1_%2:" ).arg( width ).arg( height );
85 path += _path;
86 insert( path, pix, (pix->height()*pix->width()*pix->depth())/8 );
87}
diff --git a/noncore/graphics/opie-eye/lib/imagecache.h b/noncore/graphics/opie-eye/lib/imagecache.h
new file mode 100644
index 0000000..076ecd3
--- a/dev/null
+++ b/noncore/graphics/opie-eye/lib/imagecache.h
@@ -0,0 +1,46 @@
1/*
2 * GPLv2 zecke@handhelds.org
3 * No WArranty...
4 */
5
6#ifndef PHUNK_IMAGE_CACHE_H
7#define PHUNK_IMAGE_CACHE_H
8
9#include <qimage.h>
10#include <qpixmap.h>
11#include <qcache.h>
12
13
14class PImageCache : public QCache<QImage> {
15private:
16 PImageCache();
17 ~PImageCache();
18
19public:
20 static PImageCache *self();
21 QImage* cachedImage( const QString& path, int orientation = 3, int max = 0); //const;
22 void insertImage( const QString& path, const QImage &, int orien = 3, int max = 0);
23 void insertImage( const QString& path, const QImage *, int orien=3, int max = 0 );
24};
25
26
27class PPixmapCache : public QCache<QPixmap> {
28private:
29 PPixmapCache();
30 ~PPixmapCache();
31public:
32 static PPixmapCache *self();
33 QPixmap* cachedImage( const QString& path, int width, int height );
34 void insertImage( const QString& path, const QPixmap &, int width, int height );
35 void insertImage( const QString& path, const QPixmap *, int width, int height );
36};
37
38inline void PPixmapCache::insertImage( const QString& path, const QPixmap& p, int width, int height ) {
39 insertImage( path, new QPixmap( p ), width, height );
40}
41
42inline void PImageCache::insertImage( const QString& path, const QImage& p, int width, int height ) {
43 insertImage( path, new QImage( p ), width, height );
44}
45
46#endif
diff --git a/noncore/graphics/opie-eye/lib/slavemaster.cpp b/noncore/graphics/opie-eye/lib/slavemaster.cpp
new file mode 100644
index 0000000..18dc883
--- a/dev/null
+++ b/noncore/graphics/opie-eye/lib/slavemaster.cpp
@@ -0,0 +1,145 @@
1#include "slavemaster.h"
2
3#include <qpe/qpeapplication.h>
4#include <qpe/qcopenvelope_qws.h>
5
6#include <qcopchannel_qws.h>
7#include <qtimer.h>
8
9QDataStream & operator << (QDataStream & str, bool b)
10{
11 str << Q_INT8(b);
12 return str;
13}
14QDataStream & operator >> (QDataStream & str, bool & b)
15{
16 Q_INT8 l;
17 str >> l;
18 b = bool(l);
19 return str;
20}
21QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) {
22 return s << inf.file << inf.pixmap << inf.width << inf.height;
23}
24QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) {
25 s >> inf.file >> inf.pixmap >> inf.width >> inf.height;
26 return s;
27}
28QDataStream &operator<<( QDataStream& s, const ImageInfo& i) {
29 return s << i.kind << i.file << i.info;
30}
31QDataStream &operator>>( QDataStream& s, ImageInfo& i ) {
32 s >> i.kind >> i.file >> i.info;
33 return s;
34}
35
36
37
38SlaveMaster* SlaveMaster::m_master = 0;
39
40SlaveMaster::SlaveMaster()
41 : m_started( false )
42{
43 QCopChannel *chan= new QCopChannel( "QPE/opie-eye",this );
44 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)),
45 this, SLOT(recieve(const QCString&,const QByteArray&)) );
46}
47
48SlaveMaster::~SlaveMaster() {
49}
50
51SlaveMaster* SlaveMaster::self() {
52 if ( !m_master )
53 m_master = new SlaveMaster;
54 return m_master;
55}
56
57void SlaveMaster::thumbInfo( const QString& str) {
58 m_inThumbInfo.append( str );
59
60 if ( !m_started ) {
61 QTimer::singleShot( 0, this, SLOT(slotTimerStart()));
62 m_started = true;
63 }
64}
65
66void SlaveMaster::imageInfo( const QString& str ) {
67 m_inImageInfo.append( str );
68 if ( !m_started ) {
69 QTimer::singleShot( 0, this, SLOT(slotTimerStart()));
70 m_started = true;
71 }
72}
73
74void SlaveMaster::thumbNail( const QString& str, int w, int h ) {
75 if ( str.isEmpty() ) {
76 qWarning( "Asking for empty nail" );
77 return;
78 }
79 qWarning( "Asking for thumbNail in size %d %d" + str, w,h );
80 PixmapInfo item;
81 item.file = str; item.width = w; item.height = h;
82 item.pixmap = QPixmap();
83 m_inThumbNail.append( item );
84
85 if ( !m_started ) {
86 QTimer::singleShot( 0, this, SLOT(slotTimerStart()));
87 m_started = true;
88 }
89}
90
91
92void SlaveMaster::recieve( const QCString& str, const QByteArray& at) {
93
94 ImageInfos infos;
95 PixmapInfos pixinfos;
96
97 QDataStream stream( at, IO_ReadOnly );
98 if ( str == "pixmapsHandled(PixmapList)" )
99 stream >> pixinfos;
100 else if ( str == "pixmapsHandled(StringList)" )
101 stream >> infos;
102
103 qWarning( "PixInfos %d", pixinfos.count() );
104
105 bool got_data = ( !infos.isEmpty() || !pixinfos.isEmpty() );
106 if ( got_data ) {
107 emit sig_start();
108 for ( ImageInfos::Iterator _it = infos.begin(); _it != infos.end(); ++_it ) {
109 if ( (*_it).kind )
110 emit sig_fullInfo( (*_it).file, (*_it).info );
111 else
112 emit sig_thumbInfo( (*_it).file, (*_it).info );
113 }
114
115 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it )
116 emit sig_thumbNail( (*it).file, (*it).pixmap );
117 emit sig_end();
118 }
119}
120
121void SlaveMaster::slotTimerStart() {
122 m_started = false;
123
124 if ( !m_inThumbInfo.isEmpty() ) {
125 QCopEnvelope env("QPE/opie-eye_slave", "thumbInfos(QStringList)" );
126 env << m_inThumbInfo;
127 }
128 if ( !m_inImageInfo.isEmpty() ) {
129 QCopEnvelope env("QPE/opie-eye_slave", "fullInfos(QStringList)" );
130 env << m_inImageInfo;
131 }
132 if ( !m_inThumbNail.isEmpty() ) {
133 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" );
134 env << m_inThumbNail;
135 }
136
137
138 m_inThumbInfo.clear();
139 m_inImageInfo.clear();
140 m_inThumbNail.clear();
141}
142
143QImage SlaveMaster::image( const QString& str, PDirLister::Factor, int ) {
144 return QImage();
145}
diff --git a/noncore/graphics/opie-eye/lib/slavemaster.h b/noncore/graphics/opie-eye/lib/slavemaster.h
new file mode 100644
index 0000000..f5284a6
--- a/dev/null
+++ b/noncore/graphics/opie-eye/lib/slavemaster.h
@@ -0,0 +1,43 @@
1#ifndef OPIE_EYE_SLAVE_MASTER_H
2#define OPIE_EYE_SLAVE_MASTER_H
3
4#include <iface/dirlister.h>
5#include <iface/slaveiface.h>
6
7#include <qobject.h>
8#include <qstring.h>
9#include <qsize.h>
10
11class SlaveMaster : public QObject {
12 Q_OBJECT
13 typedef QValueList<ImageInfo> ImageInfos;
14 typedef QValueList<PixmapInfo> PixmapInfos;
15public:
16 static SlaveMaster *self();
17
18 void thumbInfo( const QString& );
19 void imageInfo( const QString& );
20 void thumbNail( const QString&, int w, int h );
21 QImage image( const QString&, PDirLister::Factor, int );
22signals:
23 void sig_start();
24 void sig_end();
25
26 void sig_thumbInfo( const QString&, const QString& );
27 void sig_fullInfo( const QString&, const QString& );
28 void sig_thumbNail( const QString&, const QPixmap& );
29private slots:
30 void recieve( const QCString&, const QByteArray& );
31 void slotTimerStart();
32private:
33 SlaveMaster();
34 ~SlaveMaster();
35 static SlaveMaster *m_master;
36 bool m_started : 1;
37 QStringList m_inThumbInfo;
38 QStringList m_inImageInfo;
39 PixmapInfos m_inThumbNail;
40};
41
42
43#endif
diff --git a/noncore/graphics/opie-eye/lib/viewmap.cpp b/noncore/graphics/opie-eye/lib/viewmap.cpp
new file mode 100644
index 0000000..ca242b7
--- a/dev/null
+++ b/noncore/graphics/opie-eye/lib/viewmap.cpp
@@ -0,0 +1,25 @@
1#include <iface/dirview.h>
2
3
4namespace {
5 ViewMap *_viewMap = 0;
6 PDirView *_dirView = 0;
7}
8
9
10ViewMap *viewMap() {
11 if ( !_viewMap )
12 _viewMap = new ViewMap;
13
14 return _viewMap;
15}
16
17
18PDirView* currentView(){
19 return _dirView;
20}
21
22
23void setCurrentView( PDirView* view ) {
24 _dirView = view;
25}