summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp6
-rw-r--r--noncore/graphics/opie-eye/lib/slavemaster.cpp7
-rw-r--r--noncore/graphics/opie-eye/slave/slavereciever.cpp7
3 files changed, 17 insertions, 3 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index 0b80012..38a621e 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -48,149 +48,153 @@ namespace {
48 48
49/* 49/*
50 * If we request an Image or String 50 * If we request an Image or String
51 * we add it to the map 51 * we add it to the map
52 */ 52 */
53 QMap<QString, IconViewItem*> g_stringInf; 53 QMap<QString, IconViewItem*> g_stringInf;
54 QMap<QString, IconViewItem*> g_stringPix; 54 QMap<QString, IconViewItem*> g_stringPix;
55 55
56 IconViewItem::IconViewItem( QIconView* view,const QString& path, 56 IconViewItem::IconViewItem( QIconView* view,const QString& path,
57 const QString& name, bool isDir ) 57 const QString& name, bool isDir )
58 : QIconViewItem( view ), m_path( path ), m_isDir( isDir ), 58 : QIconViewItem( view ), m_path( path ), m_isDir( isDir ),
59 m_noInfo( false ) 59 m_noInfo( false )
60 { 60 {
61 QIconViewItem::setText( name ); 61 QIconViewItem::setText( name );
62 if ( isDir && !_dirPix ) 62 if ( isDir && !_dirPix )
63 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); 63 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser"));
64 else if ( !isDir && !_unkPix ) 64 else if ( !isDir && !_unkPix )
65 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); 65 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) );
66 } 66 }
67 inline QPixmap* IconViewItem::pixmap()const { 67 inline QPixmap* IconViewItem::pixmap()const {
68 if ( m_isDir ) 68 if ( m_isDir )
69 return _dirPix; 69 return _dirPix;
70 else{ 70 else{
71 if (!m_noInfo && !g_stringInf.contains( m_path ) ) { 71 if (!m_noInfo && !g_stringInf.contains( m_path ) ) {
72 currentView()->dirLister()->imageInfo( m_path ); 72 currentView()->dirLister()->imageInfo( m_path );
73 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); 73 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this));
74 } 74 }
75 75
76 m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); 76 m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 );
77 if ( !m_pix && !g_stringPix.contains( m_path )) { 77 if ( !m_pix && !g_stringPix.contains( m_path )) {
78 currentView()->dirLister()->thumbNail( m_path, 64, 64 ); 78 currentView()->dirLister()->thumbNail( m_path, 64, 64 );
79 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); 79 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
80 } 80 }
81 return m_pix ? m_pix : _unkPix; 81 return m_pix ? m_pix : _unkPix;
82 } 82 }
83 } 83 }
84 inline void IconViewItem::setText( const QString& str ) { 84 inline void IconViewItem::setText( const QString& str ) {
85 QString text = QIconViewItem::text()+"\n"+str; 85 QString text = QIconViewItem::text()+"\n"+str;
86 m_noInfo = true; 86 m_noInfo = true;
87 QIconViewItem::setText( text ); 87 QIconViewItem::setText( text );
88 } 88 }
89} 89}
90 90
91 91
92PIconView::PIconView( QWidget* wid, Config* cfg ) 92PIconView::PIconView( QWidget* wid, Config* cfg )
93 : QVBox( wid ), m_cfg( cfg ) 93 : QVBox( wid ), m_cfg( cfg )
94{ 94{
95 { 95 {
96 QCopEnvelope( "QPE/Application/opie-eye_slave", "foo()" ); 96// QCopEnvelope( "QPE/Application/opie-eye_slave", "foo()" );
97 } 97 }
98 m_path = QDir::homeDirPath(); 98 m_path = QDir::homeDirPath();
99 99
100 QHBox *hbox = new QHBox( this ); 100 QHBox *hbox = new QHBox( this );
101 QLabel* lbl = new QLabel( hbox ); 101 QLabel* lbl = new QLabel( hbox );
102 lbl->setText( tr("View as" ) ); 102 lbl->setText( tr("View as" ) );
103 103
104 m_views = new QComboBox( hbox, "View As" ); 104 m_views = new QComboBox( hbox, "View As" );
105 connect( m_views, SIGNAL(activated(int)), 105 connect( m_views, SIGNAL(activated(int)),
106 this, SLOT(slotViewChanged(int)) ); 106 this, SLOT(slotViewChanged(int)) );
107 107
108 m_view= new QIconView( this ); 108 m_view= new QIconView( this );
109 connect(m_view, SIGNAL(clicked(QIconViewItem*) ), 109 connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
110 this, SLOT(slotClicked(QIconViewItem*)) ); 110 this, SLOT(slotClicked(QIconViewItem*)) );
111 111
112 m_view->setArrangement( QIconView::LeftToRight ); 112 m_view->setArrangement( QIconView::LeftToRight );
113 m_view->setItemTextPos( QIconView::Right ); 113 m_view->setItemTextPos( QIconView::Right );
114 114
115 115
116 int dw = QApplication::desktop()->width(); 116 int dw = QApplication::desktop()->width();
117 int viewerWidth = dw-style().scrollBarExtent().width(); 117 int viewerWidth = dw-style().scrollBarExtent().width();
118 m_view->setGridX( viewerWidth-2*m_view->spacing() ); 118 m_view->setGridX( viewerWidth-2*m_view->spacing() );
119 m_view->setGridY( fontMetrics().height()*2+40 ); 119 m_view->setGridY( fontMetrics().height()*2+40 );
120 loadViews(); 120 loadViews();
121 slotViewChanged( m_views->currentItem() ); 121 slotViewChanged( m_views->currentItem() );
122} 122}
123 123
124PIconView::~PIconView() { 124PIconView::~PIconView() {
125} 125}
126 126
127void PIconView::slotDirUp() { 127void PIconView::slotDirUp() {
128 QDir dir( m_path ); 128 QDir dir( m_path );
129 dir.cdUp(); 129 dir.cdUp();
130 slotChangeDir( dir.absPath() ); 130 slotChangeDir( dir.absPath() );
131 131
132} 132}
133 133
134void PIconView::slotChangeDir(const QString& path) { 134void PIconView::slotChangeDir(const QString& path) {
135 if ( !currentView() ) 135 if ( !currentView() )
136 return; 136 return;
137 137
138 PDirLister *lister = currentView()->dirLister(); 138 PDirLister *lister = currentView()->dirLister();
139 if (!lister ) 139 if (!lister )
140 return; 140 return;
141 141
142 lister->setStartPath( path ); 142 lister->setStartPath( path );
143 m_path = lister->currentPath(); 143 m_path = lister->currentPath();
144 144
145 m_view->clear(); 145 m_view->clear();
146 addFolders( lister->folders() ); 146 addFolders( lister->folders() );
147 addFiles( lister->files() ); 147 addFiles( lister->files() );
148 148
149 // Also invalidate the cache. We can't cancel the operations anyway
150 g_stringPix.clear();
151 g_stringInf.clear();
152
149 // looks ugly 153 // looks ugly
150 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); 154 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
151} 155}
152 156
153QString PIconView::currentFileName(bool &isDir)const { 157QString PIconView::currentFileName(bool &isDir)const {
154 isDir = false; 158 isDir = false;
155 QIconViewItem* _it = m_view->currentItem(); 159 QIconViewItem* _it = m_view->currentItem();
156 if ( !_it ) 160 if ( !_it )
157 return QString::null; 161 return QString::null;
158 162
159 IconViewItem* it = static_cast<IconViewItem*>( _it ); 163 IconViewItem* it = static_cast<IconViewItem*>( _it );
160 isDir = it->isDir(); 164 isDir = it->isDir();
161 return it->path(); 165 return it->path();
162} 166}
163 167
164void PIconView::slotTrash() { 168void PIconView::slotTrash() {
165 bool isDir; 169 bool isDir;
166 QString pa = currentFileName( isDir ); 170 QString pa = currentFileName( isDir );
167 if ( isDir && pa.isEmpty() ) 171 if ( isDir && pa.isEmpty() )
168 return; 172 return;
169 173
170 if (!QPEMessageBox::confirmDelete( this, 174 if (!QPEMessageBox::confirmDelete( this,
171 tr("Delete Image" ), 175 tr("Delete Image" ),
172 tr("the Image %1" ).arg(pa))) 176 tr("the Image %1" ).arg(pa)))
173 return 177 return
174 178
175 179
176 currentView()->dirLister()->deleteImage( pa ); 180 currentView()->dirLister()->deleteImage( pa );
177 delete m_view->currentItem(); 181 delete m_view->currentItem();
178} 182}
179void PIconView::loadViews() { 183void PIconView::loadViews() {
180 ViewMap::Iterator it; 184 ViewMap::Iterator it;
181 ViewMap* map = viewMap(); 185 ViewMap* map = viewMap();
182 for ( it = map->begin(); it != map->end(); ++it ) 186 for ( it = map->begin(); it != map->end(); ++it )
183 m_views->insertItem( QObject::tr(it.key() ) ); 187 m_views->insertItem( QObject::tr(it.key() ) );
184} 188}
185 189
186void PIconView::resetView() { 190void PIconView::resetView() {
187 slotViewChanged(m_views->currentItem()); 191 slotViewChanged(m_views->currentItem());
188} 192}
189 193
190void PIconView::slotViewChanged( int i) { 194void PIconView::slotViewChanged( int i) {
191 if (!m_views->count() ) { 195 if (!m_views->count() ) {
192 setCurrentView( 0l); 196 setCurrentView( 0l);
193 return; 197 return;
194 } 198 }
195 199
196 PDirView* cur = currentView(); 200 PDirView* cur = currentView();
diff --git a/noncore/graphics/opie-eye/lib/slavemaster.cpp b/noncore/graphics/opie-eye/lib/slavemaster.cpp
index 18dc883..4e28535 100644
--- a/noncore/graphics/opie-eye/lib/slavemaster.cpp
+++ b/noncore/graphics/opie-eye/lib/slavemaster.cpp
@@ -1,70 +1,75 @@
1#include "slavemaster.h" 1#include "slavemaster.h"
2 2
3#include <qpe/qpeapplication.h> 3#include <qpe/qpeapplication.h>
4#include <qpe/qcopenvelope_qws.h> 4#include <qpe/qcopenvelope_qws.h>
5 5
6#include <qcopchannel_qws.h> 6#include <qcopchannel_qws.h>
7#include <qtimer.h> 7#include <qtimer.h>
8 8
9QDataStream & operator << (QDataStream & str, bool b) 9QDataStream & operator << (QDataStream & str, bool b)
10{ 10{
11 str << Q_INT8(b); 11 str << Q_INT8(b);
12 return str; 12 return str;
13} 13}
14QDataStream & operator >> (QDataStream & str, bool & b) 14QDataStream & operator >> (QDataStream & str, bool & b)
15{ 15{
16 Q_INT8 l; 16 Q_INT8 l;
17 str >> l; 17 str >> l;
18 b = bool(l); 18 b = bool(l);
19 return str; 19 return str;
20} 20}
21
22/*
23 * ! We don't put a Pixmap in!!!!
24 */
21QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { 25QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) {
22 return s << inf.file << inf.pixmap << inf.width << inf.height; 26 qWarning( "Image request is %s %d %d", inf.file.latin1(), inf.width, inf.height );
27 return s << inf.file << inf.width << inf.height;
23} 28}
24QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { 29QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) {
25 s >> inf.file >> inf.pixmap >> inf.width >> inf.height; 30 s >> inf.file >> inf.pixmap >> inf.width >> inf.height;
26 return s; 31 return s;
27} 32}
28QDataStream &operator<<( QDataStream& s, const ImageInfo& i) { 33QDataStream &operator<<( QDataStream& s, const ImageInfo& i) {
29 return s << i.kind << i.file << i.info; 34 return s << i.kind << i.file << i.info;
30} 35}
31QDataStream &operator>>( QDataStream& s, ImageInfo& i ) { 36QDataStream &operator>>( QDataStream& s, ImageInfo& i ) {
32 s >> i.kind >> i.file >> i.info; 37 s >> i.kind >> i.file >> i.info;
33 return s; 38 return s;
34} 39}
35 40
36 41
37 42
38SlaveMaster* SlaveMaster::m_master = 0; 43SlaveMaster* SlaveMaster::m_master = 0;
39 44
40SlaveMaster::SlaveMaster() 45SlaveMaster::SlaveMaster()
41 : m_started( false ) 46 : m_started( false )
42{ 47{
43 QCopChannel *chan= new QCopChannel( "QPE/opie-eye",this ); 48 QCopChannel *chan= new QCopChannel( "QPE/opie-eye",this );
44 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), 49 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)),
45 this, SLOT(recieve(const QCString&,const QByteArray&)) ); 50 this, SLOT(recieve(const QCString&,const QByteArray&)) );
46} 51}
47 52
48SlaveMaster::~SlaveMaster() { 53SlaveMaster::~SlaveMaster() {
49} 54}
50 55
51SlaveMaster* SlaveMaster::self() { 56SlaveMaster* SlaveMaster::self() {
52 if ( !m_master ) 57 if ( !m_master )
53 m_master = new SlaveMaster; 58 m_master = new SlaveMaster;
54 return m_master; 59 return m_master;
55} 60}
56 61
57void SlaveMaster::thumbInfo( const QString& str) { 62void SlaveMaster::thumbInfo( const QString& str) {
58 m_inThumbInfo.append( str ); 63 m_inThumbInfo.append( str );
59 64
60 if ( !m_started ) { 65 if ( !m_started ) {
61 QTimer::singleShot( 0, this, SLOT(slotTimerStart())); 66 QTimer::singleShot( 0, this, SLOT(slotTimerStart()));
62 m_started = true; 67 m_started = true;
63 } 68 }
64} 69}
65 70
66void SlaveMaster::imageInfo( const QString& str ) { 71void SlaveMaster::imageInfo( const QString& str ) {
67 m_inImageInfo.append( str ); 72 m_inImageInfo.append( str );
68 if ( !m_started ) { 73 if ( !m_started ) {
69 QTimer::singleShot( 0, this, SLOT(slotTimerStart())); 74 QTimer::singleShot( 0, this, SLOT(slotTimerStart()));
70 m_started = true; 75 m_started = true;
diff --git a/noncore/graphics/opie-eye/slave/slavereciever.cpp b/noncore/graphics/opie-eye/slave/slavereciever.cpp
index 951f3df..c8e33d4 100644
--- a/noncore/graphics/opie-eye/slave/slavereciever.cpp
+++ b/noncore/graphics/opie-eye/slave/slavereciever.cpp
@@ -1,83 +1,88 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 */ 3 */
4 4
5#include "slavereciever.h" 5#include "slavereciever.h"
6#include "slaveiface.h" 6#include "slaveiface.h"
7 7
8#include <qpe/qcopenvelope_qws.h> 8#include <qpe/qcopenvelope_qws.h>
9#include <qpe/qpeapplication.h> 9#include <qpe/qpeapplication.h>
10 10
11#include <qtimer.h> 11#include <qtimer.h>
12 12
13static SlaveObjects* _slaveObj = 0; 13static SlaveObjects* _slaveObj = 0;
14 14
15QDataStream & operator << (QDataStream & str, bool b) 15QDataStream & operator << (QDataStream & str, bool b)
16{ 16{
17 str << Q_INT8(b); 17 str << Q_INT8(b);
18 return str; 18 return str;
19} 19}
20 20
21QDataStream & operator >> (QDataStream & str, bool & b) 21QDataStream & operator >> (QDataStream & str, bool & b)
22{ 22{
23 Q_INT8 l; 23 Q_INT8 l;
24 str >> l; 24 str >> l;
25 b = bool(l); 25 b = bool(l);
26 return str; 26 return str;
27} 27}
28 28
29 29
30 30
31QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { 31QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) {
32 return s << inf.file << inf.pixmap << inf.width << inf.height; 32 return s << inf.file << inf.pixmap << inf.width << inf.height;
33} 33}
34
35/*
36 * GUI sends no QPIxmap!!!
37 */
34QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { 38QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) {
35 s >> inf.file >> inf.pixmap >> inf.width >> inf.height; 39 s >> inf.file >> inf.width >> inf.height;
40 qWarning( "Recieved %s %d %d", inf.file.latin1(), inf.width, inf.height );
36 return s; 41 return s;
37} 42}
38QDataStream &operator<<( QDataStream& s, const ImageInfo& i) { 43QDataStream &operator<<( QDataStream& s, const ImageInfo& i) {
39 return s << i.kind << i.file << i.info; 44 return s << i.kind << i.file << i.info;
40} 45}
41QDataStream &operator>>( QDataStream& s, ImageInfo& i ) { 46QDataStream &operator>>( QDataStream& s, ImageInfo& i ) {
42 s >> i.kind >> i.file >> i.info; 47 s >> i.kind >> i.file >> i.info;
43 return s; 48 return s;
44} 49}
45 50
46 51
47 52
48SlaveObjects* slaveObjects() { 53SlaveObjects* slaveObjects() {
49 if ( !_slaveObj ) 54 if ( !_slaveObj )
50 _slaveObj = new SlaveObjects; 55 _slaveObj = new SlaveObjects;
51 return _slaveObj; 56 return _slaveObj;
52} 57}
53 58
54SlaveReciever::SlaveReciever( QObject* par) 59SlaveReciever::SlaveReciever( QObject* par)
55 : QObject( par ) 60 : QObject( par )
56{ 61{
57 m_inf = new QTimer(this); 62 m_inf = new QTimer(this);
58 connect(m_inf,SIGNAL(timeout()), 63 connect(m_inf,SIGNAL(timeout()),
59 this, SLOT(slotImageInfo())); 64 this, SLOT(slotImageInfo()));
60 m_pix = new QTimer(this); 65 m_pix = new QTimer(this);
61 connect(m_pix,SIGNAL(timeout()), 66 connect(m_pix,SIGNAL(timeout()),
62 this, SLOT(slotThumbNail())); 67 this, SLOT(slotThumbNail()));
63 68
64 m_out = new QTimer(this); 69 m_out = new QTimer(this);
65 connect(m_out,SIGNAL(timeout()), 70 connect(m_out,SIGNAL(timeout()),
66 this, SLOT(slotSend())); 71 this, SLOT(slotSend()));
67 72
68 SlaveObjects *obj = slaveObjects(); // won't be changed 73 SlaveObjects *obj = slaveObjects(); // won't be changed
69 SlaveMap::Iterator it; 74 SlaveMap::Iterator it;
70 SlaveMap* map = slaveMap(); // SlaveMap won't be changed during execution!!! 75 SlaveMap* map = slaveMap(); // SlaveMap won't be changed during execution!!!
71 for(it = map->begin(); it != map->end(); ++it ) { 76 for(it = map->begin(); it != map->end(); ++it ) {
72 obj->insert( it.key(), (*it.data())() ); 77 obj->insert( it.key(), (*it.data())() );
73 } 78 }
74} 79}
75 80
76SlaveReciever::~SlaveReciever() { 81SlaveReciever::~SlaveReciever() {
77} 82}
78 83
79void SlaveReciever::recieveAnswer( const QCString& string, const QByteArray& ar) { 84void SlaveReciever::recieveAnswer( const QCString& string, const QByteArray& ar) {
80 qWarning( "String is %s", string.data() ); 85 qWarning( "String is %s", string.data() );
81 QDataStream stream(ar, IO_ReadOnly ); 86 QDataStream stream(ar, IO_ReadOnly );
82 QStringList lst; 87 QStringList lst;
83 static ImageInfo inf; 88 static ImageInfo inf;