author | zecke <zecke> | 2004-03-23 00:36:37 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-23 00:36:37 (UTC) |
commit | d7581f7cd0ba6adb43ee5c4bdeae696c0a16ae3b (patch) (unidiff) | |
tree | c65e9015323fb7fc4fec45038aa0f0a19b43252f | |
parent | 428b687982966dc2efabaf6dbcc55ad0ea30aa10 (diff) | |
download | opie-d7581f7cd0ba6adb43ee5c4bdeae696c0a16ae3b.zip opie-d7581f7cd0ba6adb43ee5c4bdeae696c0a16ae3b.tar.gz opie-d7581f7cd0ba6adb43ee5c4bdeae696c0a16ae3b.tar.bz2 |
Fix communication. It seems like QPixmap and QDataStream
do not mix well if the QPixmap is not valid..
invalidate image requests if we change the dir
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 6 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/lib/slavemaster.cpp | 7 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/slave/slavereciever.cpp | 7 |
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 | |||
@@ -1,296 +1,300 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | * No WArranty... | 3 | * No WArranty... |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "iconview.h" | 6 | #include "iconview.h" |
7 | 7 | ||
8 | #include <lib/imagecache.h> | 8 | #include <lib/imagecache.h> |
9 | 9 | ||
10 | #include <iface/dirview.h> | 10 | #include <iface/dirview.h> |
11 | #include <iface/dirlister.h> | 11 | #include <iface/dirlister.h> |
12 | 12 | ||
13 | #include <qpe/config.h> | 13 | #include <qpe/config.h> |
14 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
15 | #include <qpe/qpemessagebox.h> | 15 | #include <qpe/qpemessagebox.h> |
16 | #include <qpe/ir.h> | 16 | #include <qpe/ir.h> |
17 | #include <qpe/qcopenvelope_qws.h> | 17 | #include <qpe/qcopenvelope_qws.h> |
18 | 18 | ||
19 | #include <qiconview.h> | 19 | #include <qiconview.h> |
20 | #include <qlabel.h> | 20 | #include <qlabel.h> |
21 | #include <qhbox.h> | 21 | #include <qhbox.h> |
22 | #include <qcombobox.h> | 22 | #include <qcombobox.h> |
23 | #include <qdir.h> | 23 | #include <qdir.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
26 | #include <qtimer.h> | 26 | #include <qtimer.h> |
27 | #include <qstyle.h> | 27 | #include <qstyle.h> |
28 | 28 | ||
29 | 29 | ||
30 | 30 | ||
31 | namespace { | 31 | namespace { |
32 | QPixmap* _dirPix = 0; | 32 | QPixmap* _dirPix = 0; |
33 | QPixmap* _unkPix = 0; | 33 | QPixmap* _unkPix = 0; |
34 | class IconViewItem : public QIconViewItem { | 34 | class IconViewItem : public QIconViewItem { |
35 | public: | 35 | public: |
36 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); | 36 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); |
37 | QPixmap* pixmap()const; | 37 | QPixmap* pixmap()const; |
38 | QString path()const { return m_path; } | 38 | QString path()const { return m_path; } |
39 | bool isDir()const { return m_isDir; } | 39 | bool isDir()const { return m_isDir; } |
40 | void setText( const QString& ); | 40 | void setText( const QString& ); |
41 | private: | 41 | private: |
42 | mutable QPixmap* m_pix; | 42 | mutable QPixmap* m_pix; |
43 | QString m_path; | 43 | QString m_path; |
44 | bool m_isDir : 1; | 44 | bool m_isDir : 1; |
45 | bool m_noInfo :1; | 45 | bool m_noInfo :1; |
46 | }; | 46 | }; |
47 | 47 | ||
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 | ||
92 | PIconView::PIconView( QWidget* wid, Config* cfg ) | 92 | PIconView::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 | ||
124 | PIconView::~PIconView() { | 124 | PIconView::~PIconView() { |
125 | } | 125 | } |
126 | 126 | ||
127 | void PIconView::slotDirUp() { | 127 | void 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 | ||
134 | void PIconView::slotChangeDir(const QString& path) { | 134 | void 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 | ||
153 | QString PIconView::currentFileName(bool &isDir)const { | 157 | QString 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 | ||
164 | void PIconView::slotTrash() { | 168 | void 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 | } |
179 | void PIconView::loadViews() { | 183 | void 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 | ||
186 | void PIconView::resetView() { | 190 | void PIconView::resetView() { |
187 | slotViewChanged(m_views->currentItem()); | 191 | slotViewChanged(m_views->currentItem()); |
188 | } | 192 | } |
189 | 193 | ||
190 | void PIconView::slotViewChanged( int i) { | 194 | void 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(); |
197 | delete cur; | 201 | delete cur; |
198 | QString str = m_views->text(i); | 202 | QString str = m_views->text(i); |
199 | cur = (*(*viewMap())[str])(*m_cfg); | 203 | cur = (*(*viewMap())[str])(*m_cfg); |
200 | setCurrentView( cur ); | 204 | setCurrentView( cur ); |
201 | 205 | ||
202 | /* connect to the signals of the lister */ | 206 | /* connect to the signals of the lister */ |
203 | PDirLister* lis = cur->dirLister(); | 207 | PDirLister* lis = cur->dirLister(); |
204 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), | 208 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), |
205 | this, SLOT( slotThumbInfo(const QString&, const QString&))); | 209 | this, SLOT( slotThumbInfo(const QString&, const QString&))); |
206 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 210 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
207 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 211 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
208 | connect(lis, SIGNAL(sig_start()), | 212 | connect(lis, SIGNAL(sig_start()), |
209 | this, SLOT(slotStart())); | 213 | this, SLOT(slotStart())); |
210 | connect(lis, SIGNAL(sig_end()) , | 214 | connect(lis, SIGNAL(sig_end()) , |
211 | this, SLOT(slotEnd()) ); | 215 | this, SLOT(slotEnd()) ); |
212 | 216 | ||
213 | 217 | ||
214 | /* reload now */ | 218 | /* reload now */ |
215 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); | 219 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); |
216 | } | 220 | } |
217 | 221 | ||
218 | 222 | ||
219 | void PIconView::slotReloadDir() { | 223 | void PIconView::slotReloadDir() { |
220 | slotChangeDir( m_path ); | 224 | slotChangeDir( m_path ); |
221 | } | 225 | } |
222 | 226 | ||
223 | 227 | ||
224 | void PIconView::addFolders( const QStringList& lst) { | 228 | void PIconView::addFolders( const QStringList& lst) { |
225 | QStringList::ConstIterator it; | 229 | QStringList::ConstIterator it; |
226 | 230 | ||
227 | for(it=lst.begin(); it != lst.end(); ++it ) { | 231 | for(it=lst.begin(); it != lst.end(); ++it ) { |
228 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); | 232 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); |
229 | } | 233 | } |
230 | 234 | ||
231 | } | 235 | } |
232 | 236 | ||
233 | void PIconView::addFiles( const QStringList& lst) { | 237 | void PIconView::addFiles( const QStringList& lst) { |
234 | QStringList::ConstIterator it; | 238 | QStringList::ConstIterator it; |
235 | for (it=lst.begin(); it!= lst.end(); ++it ) | 239 | for (it=lst.begin(); it!= lst.end(); ++it ) |
236 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); | 240 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); |
237 | 241 | ||
238 | } | 242 | } |
239 | 243 | ||
240 | void PIconView::slotClicked(QIconViewItem* _it) { | 244 | void PIconView::slotClicked(QIconViewItem* _it) { |
241 | if(!_it ) | 245 | if(!_it ) |
242 | return; | 246 | return; |
243 | 247 | ||
244 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 248 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
245 | if( it->isDir() ) | 249 | if( it->isDir() ) |
246 | slotChangeDir( it->path() ); | 250 | slotChangeDir( it->path() ); |
247 | else // view image | 251 | else // view image |
248 | ; | 252 | ; |
249 | } | 253 | } |
250 | 254 | ||
251 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { | 255 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { |
252 | if ( g_stringInf.contains( _path ) ) { | 256 | if ( g_stringInf.contains( _path ) ) { |
253 | IconViewItem* item = g_stringInf[_path]; | 257 | IconViewItem* item = g_stringInf[_path]; |
254 | item->setText( str ); | 258 | item->setText( str ); |
255 | item->repaint(); | 259 | item->repaint(); |
256 | g_stringInf.remove( _path ); | 260 | g_stringInf.remove( _path ); |
257 | } | 261 | } |
258 | } | 262 | } |
259 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { | 263 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { |
260 | if ( g_stringPix.contains( _path ) ) { | 264 | if ( g_stringPix.contains( _path ) ) { |
261 | IconViewItem* item = g_stringPix[_path]; | 265 | IconViewItem* item = g_stringPix[_path]; |
262 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); | 266 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); |
263 | item->repaint(); | 267 | item->repaint(); |
264 | g_stringPix.remove( _path ); | 268 | g_stringPix.remove( _path ); |
265 | } | 269 | } |
266 | } | 270 | } |
267 | 271 | ||
268 | 272 | ||
269 | void PIconView::slotRename() { | 273 | void PIconView::slotRename() { |
270 | 274 | ||
271 | } | 275 | } |
272 | 276 | ||
273 | void PIconView::slotBeam() { | 277 | void PIconView::slotBeam() { |
274 | bool isDir; | 278 | bool isDir; |
275 | QString pa = currentFileName( isDir ); | 279 | QString pa = currentFileName( isDir ); |
276 | if ( isDir && pa.isEmpty() ) | 280 | if ( isDir && pa.isEmpty() ) |
277 | return; | 281 | return; |
278 | 282 | ||
279 | Ir* ir = new Ir( this ); | 283 | Ir* ir = new Ir( this ); |
280 | connect( ir, SIGNAL(done(Ir*)), | 284 | connect( ir, SIGNAL(done(Ir*)), |
281 | this, SLOT(slotBeamDone(Ir*))); | 285 | this, SLOT(slotBeamDone(Ir*))); |
282 | ir->send(pa, tr( "Image" ) ); | 286 | ir->send(pa, tr( "Image" ) ); |
283 | 287 | ||
284 | } | 288 | } |
285 | 289 | ||
286 | void PIconView::slotBeamDone( Ir* ir) { | 290 | void PIconView::slotBeamDone( Ir* ir) { |
287 | delete ir; | 291 | delete ir; |
288 | } | 292 | } |
289 | 293 | ||
290 | void PIconView::slotStart() { | 294 | void PIconView::slotStart() { |
291 | m_view->setUpdatesEnabled( false ); | 295 | m_view->setUpdatesEnabled( false ); |
292 | } | 296 | } |
293 | 297 | ||
294 | void PIconView::slotEnd() { | 298 | void PIconView::slotEnd() { |
295 | m_view->setUpdatesEnabled( true ); | 299 | m_view->setUpdatesEnabled( true ); |
296 | } | 300 | } |
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,145 +1,150 @@ | |||
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 | ||
9 | QDataStream & operator << (QDataStream & str, bool b) | 9 | QDataStream & 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 | } |
14 | QDataStream & operator >> (QDataStream & str, bool & b) | 14 | QDataStream & 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 | */ | ||
21 | QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { | 25 | QDataStream &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 | } |
24 | QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { | 29 | QDataStream &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 | } |
28 | QDataStream &operator<<( QDataStream& s, const ImageInfo& i) { | 33 | QDataStream &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 | } |
31 | QDataStream &operator>>( QDataStream& s, ImageInfo& i ) { | 36 | QDataStream &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 | ||
38 | SlaveMaster* SlaveMaster::m_master = 0; | 43 | SlaveMaster* SlaveMaster::m_master = 0; |
39 | 44 | ||
40 | SlaveMaster::SlaveMaster() | 45 | SlaveMaster::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 | ||
48 | SlaveMaster::~SlaveMaster() { | 53 | SlaveMaster::~SlaveMaster() { |
49 | } | 54 | } |
50 | 55 | ||
51 | SlaveMaster* SlaveMaster::self() { | 56 | SlaveMaster* 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 | ||
57 | void SlaveMaster::thumbInfo( const QString& str) { | 62 | void 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 | ||
66 | void SlaveMaster::imageInfo( const QString& str ) { | 71 | void 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; |
71 | } | 76 | } |
72 | } | 77 | } |
73 | 78 | ||
74 | void SlaveMaster::thumbNail( const QString& str, int w, int h ) { | 79 | void SlaveMaster::thumbNail( const QString& str, int w, int h ) { |
75 | if ( str.isEmpty() ) { | 80 | if ( str.isEmpty() ) { |
76 | qWarning( "Asking for empty nail" ); | 81 | qWarning( "Asking for empty nail" ); |
77 | return; | 82 | return; |
78 | } | 83 | } |
79 | qWarning( "Asking for thumbNail in size %d %d" + str, w,h ); | 84 | qWarning( "Asking for thumbNail in size %d %d" + str, w,h ); |
80 | PixmapInfo item; | 85 | PixmapInfo item; |
81 | item.file = str; item.width = w; item.height = h; | 86 | item.file = str; item.width = w; item.height = h; |
82 | item.pixmap = QPixmap(); | 87 | item.pixmap = QPixmap(); |
83 | m_inThumbNail.append( item ); | 88 | m_inThumbNail.append( item ); |
84 | 89 | ||
85 | if ( !m_started ) { | 90 | if ( !m_started ) { |
86 | QTimer::singleShot( 0, this, SLOT(slotTimerStart())); | 91 | QTimer::singleShot( 0, this, SLOT(slotTimerStart())); |
87 | m_started = true; | 92 | m_started = true; |
88 | } | 93 | } |
89 | } | 94 | } |
90 | 95 | ||
91 | 96 | ||
92 | void SlaveMaster::recieve( const QCString& str, const QByteArray& at) { | 97 | void SlaveMaster::recieve( const QCString& str, const QByteArray& at) { |
93 | 98 | ||
94 | ImageInfos infos; | 99 | ImageInfos infos; |
95 | PixmapInfos pixinfos; | 100 | PixmapInfos pixinfos; |
96 | 101 | ||
97 | QDataStream stream( at, IO_ReadOnly ); | 102 | QDataStream stream( at, IO_ReadOnly ); |
98 | if ( str == "pixmapsHandled(PixmapList)" ) | 103 | if ( str == "pixmapsHandled(PixmapList)" ) |
99 | stream >> pixinfos; | 104 | stream >> pixinfos; |
100 | else if ( str == "pixmapsHandled(StringList)" ) | 105 | else if ( str == "pixmapsHandled(StringList)" ) |
101 | stream >> infos; | 106 | stream >> infos; |
102 | 107 | ||
103 | qWarning( "PixInfos %d", pixinfos.count() ); | 108 | qWarning( "PixInfos %d", pixinfos.count() ); |
104 | 109 | ||
105 | bool got_data = ( !infos.isEmpty() || !pixinfos.isEmpty() ); | 110 | bool got_data = ( !infos.isEmpty() || !pixinfos.isEmpty() ); |
106 | if ( got_data ) { | 111 | if ( got_data ) { |
107 | emit sig_start(); | 112 | emit sig_start(); |
108 | for ( ImageInfos::Iterator _it = infos.begin(); _it != infos.end(); ++_it ) { | 113 | for ( ImageInfos::Iterator _it = infos.begin(); _it != infos.end(); ++_it ) { |
109 | if ( (*_it).kind ) | 114 | if ( (*_it).kind ) |
110 | emit sig_fullInfo( (*_it).file, (*_it).info ); | 115 | emit sig_fullInfo( (*_it).file, (*_it).info ); |
111 | else | 116 | else |
112 | emit sig_thumbInfo( (*_it).file, (*_it).info ); | 117 | emit sig_thumbInfo( (*_it).file, (*_it).info ); |
113 | } | 118 | } |
114 | 119 | ||
115 | for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) | 120 | for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) |
116 | emit sig_thumbNail( (*it).file, (*it).pixmap ); | 121 | emit sig_thumbNail( (*it).file, (*it).pixmap ); |
117 | emit sig_end(); | 122 | emit sig_end(); |
118 | } | 123 | } |
119 | } | 124 | } |
120 | 125 | ||
121 | void SlaveMaster::slotTimerStart() { | 126 | void SlaveMaster::slotTimerStart() { |
122 | m_started = false; | 127 | m_started = false; |
123 | 128 | ||
124 | if ( !m_inThumbInfo.isEmpty() ) { | 129 | if ( !m_inThumbInfo.isEmpty() ) { |
125 | QCopEnvelope env("QPE/opie-eye_slave", "thumbInfos(QStringList)" ); | 130 | QCopEnvelope env("QPE/opie-eye_slave", "thumbInfos(QStringList)" ); |
126 | env << m_inThumbInfo; | 131 | env << m_inThumbInfo; |
127 | } | 132 | } |
128 | if ( !m_inImageInfo.isEmpty() ) { | 133 | if ( !m_inImageInfo.isEmpty() ) { |
129 | QCopEnvelope env("QPE/opie-eye_slave", "fullInfos(QStringList)" ); | 134 | QCopEnvelope env("QPE/opie-eye_slave", "fullInfos(QStringList)" ); |
130 | env << m_inImageInfo; | 135 | env << m_inImageInfo; |
131 | } | 136 | } |
132 | if ( !m_inThumbNail.isEmpty() ) { | 137 | if ( !m_inThumbNail.isEmpty() ) { |
133 | QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); | 138 | QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); |
134 | env << m_inThumbNail; | 139 | env << m_inThumbNail; |
135 | } | 140 | } |
136 | 141 | ||
137 | 142 | ||
138 | m_inThumbInfo.clear(); | 143 | m_inThumbInfo.clear(); |
139 | m_inImageInfo.clear(); | 144 | m_inImageInfo.clear(); |
140 | m_inThumbNail.clear(); | 145 | m_inThumbNail.clear(); |
141 | } | 146 | } |
142 | 147 | ||
143 | QImage SlaveMaster::image( const QString& str, PDirLister::Factor, int ) { | 148 | QImage SlaveMaster::image( const QString& str, PDirLister::Factor, int ) { |
144 | return QImage(); | 149 | return QImage(); |
145 | } | 150 | } |
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,214 +1,219 @@ | |||
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 | ||
13 | static SlaveObjects* _slaveObj = 0; | 13 | static SlaveObjects* _slaveObj = 0; |
14 | 14 | ||
15 | QDataStream & operator << (QDataStream & str, bool b) | 15 | QDataStream & 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 | ||
21 | QDataStream & operator >> (QDataStream & str, bool & b) | 21 | QDataStream & 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 | ||
31 | QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { | 31 | QDataStream &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 | */ | ||
34 | QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { | 38 | QDataStream &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 | } |
38 | QDataStream &operator<<( QDataStream& s, const ImageInfo& i) { | 43 | QDataStream &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 | } |
41 | QDataStream &operator>>( QDataStream& s, ImageInfo& i ) { | 46 | QDataStream &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 | ||
48 | SlaveObjects* slaveObjects() { | 53 | SlaveObjects* 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 | ||
54 | SlaveReciever::SlaveReciever( QObject* par) | 59 | SlaveReciever::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 | ||
76 | SlaveReciever::~SlaveReciever() { | 81 | SlaveReciever::~SlaveReciever() { |
77 | } | 82 | } |
78 | 83 | ||
79 | void SlaveReciever::recieveAnswer( const QCString& string, const QByteArray& ar) { | 84 | void 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; |
84 | static PixmapInfo pix; | 89 | static PixmapInfo pix; |
85 | 90 | ||
86 | if ( string == "thumbInfo(QString)" ) { | 91 | if ( string == "thumbInfo(QString)" ) { |
87 | stream >> inf.file; | 92 | stream >> inf.file; |
88 | m_inList.append(inf); | 93 | m_inList.append(inf); |
89 | }else if ( string == "thumbInfos(QStringList)" ) { | 94 | }else if ( string == "thumbInfos(QStringList)" ) { |
90 | stream >> lst; | 95 | stream >> lst; |
91 | for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 96 | for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
92 | qWarning( "Adding thumbinfo for file "+ *it ); | 97 | qWarning( "Adding thumbinfo for file "+ *it ); |
93 | inf.file = (*it); | 98 | inf.file = (*it); |
94 | m_inList.append(inf); | 99 | m_inList.append(inf); |
95 | } | 100 | } |
96 | }else if ( string == "fullInfo(QString)" ) { | 101 | }else if ( string == "fullInfo(QString)" ) { |
97 | inf.kind = true; | 102 | inf.kind = true; |
98 | stream >> inf.file; | 103 | stream >> inf.file; |
99 | m_inList.append(inf); | 104 | m_inList.append(inf); |
100 | }else if ( string == "fullInfos(QStringList)" ) { | 105 | }else if ( string == "fullInfos(QStringList)" ) { |
101 | stream >> lst; | 106 | stream >> lst; |
102 | for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 107 | for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { |
103 | qWarning( "Adding fullInfo for"+ *it ); | 108 | qWarning( "Adding fullInfo for"+ *it ); |
104 | inf.file = (*it); | 109 | inf.file = (*it); |
105 | inf.kind = true; | 110 | inf.kind = true; |
106 | m_inList.append(inf); | 111 | m_inList.append(inf); |
107 | } | 112 | } |
108 | }else if ( string == "pixmapInfo(QString,int,int)" ) { | 113 | }else if ( string == "pixmapInfo(QString,int,int)" ) { |
109 | stream >> pix.file >> pix.width >> pix.height; | 114 | stream >> pix.file >> pix.width >> pix.height; |
110 | m_inPix.append(pix); | 115 | m_inPix.append(pix); |
111 | }else if ( string == "pixmapInfos(PixmapInfos)" ) { | 116 | }else if ( string == "pixmapInfos(PixmapInfos)" ) { |
112 | PixmapList list; | 117 | PixmapList list; |
113 | stream >> list; | 118 | stream >> list; |
114 | for(PixmapList::Iterator it = list.begin(); it != list.end(); ++it ) { | 119 | for(PixmapList::Iterator it = list.begin(); it != list.end(); ++it ) { |
115 | qWarning( "Got %d %d " + (*it).file, (*it).width , (*it).height ); | 120 | qWarning( "Got %d %d " + (*it).file, (*it).width , (*it).height ); |
116 | m_inPix.append(*it); | 121 | m_inPix.append(*it); |
117 | } | 122 | } |
118 | } | 123 | } |
119 | 124 | ||
120 | if (!m_inf->isActive() && !m_inList.isEmpty() ) | 125 | if (!m_inf->isActive() && !m_inList.isEmpty() ) |
121 | m_inf->start(5); | 126 | m_inf->start(5); |
122 | 127 | ||
123 | if (!m_pix->isActive() && !m_inPix.isEmpty() ) | 128 | if (!m_pix->isActive() && !m_inPix.isEmpty() ) |
124 | m_pix->start(5); | 129 | m_pix->start(5); |
125 | 130 | ||
126 | QPEApplication::setKeepRunning(); | 131 | QPEApplication::setKeepRunning(); |
127 | 132 | ||
128 | } | 133 | } |
129 | 134 | ||
130 | PixmapList SlaveReciever::outPix()const { | 135 | PixmapList SlaveReciever::outPix()const { |
131 | return m_outPix; | 136 | return m_outPix; |
132 | } | 137 | } |
133 | 138 | ||
134 | StringList SlaveReciever::outInf()const{ | 139 | StringList SlaveReciever::outInf()const{ |
135 | return m_outList; | 140 | return m_outList; |
136 | } | 141 | } |
137 | 142 | ||
138 | void SlaveReciever::slotImageInfo() { | 143 | void SlaveReciever::slotImageInfo() { |
139 | ImageInfo inf = m_inList.first(); | 144 | ImageInfo inf = m_inList.first(); |
140 | m_inList.remove( inf ); | 145 | m_inList.remove( inf ); |
141 | 146 | ||
142 | static SlaveObjects::Iterator it; | 147 | static SlaveObjects::Iterator it; |
143 | static SlaveObjects* map = slaveObjects(); // SlaveMap won't be changed during execution!!! | 148 | static SlaveObjects* map = slaveObjects(); // SlaveMap won't be changed during execution!!! |
144 | for(it = map->begin(); it != map->end(); ++it ) { | 149 | for(it = map->begin(); it != map->end(); ++it ) { |
145 | if( (*it)->supports(inf.file ) ) { | 150 | if( (*it)->supports(inf.file ) ) { |
146 | /* full image info */ | 151 | /* full image info */ |
147 | if (inf.kind ) | 152 | if (inf.kind ) |
148 | inf.info = (*it)->fullImageInfo( inf.file ); | 153 | inf.info = (*it)->fullImageInfo( inf.file ); |
149 | else | 154 | else |
150 | inf.info = (*it)->iconViewName( inf.file ); | 155 | inf.info = (*it)->iconViewName( inf.file ); |
151 | m_outList.append( inf ); | 156 | m_outList.append( inf ); |
152 | break; | 157 | break; |
153 | } | 158 | } |
154 | } | 159 | } |
155 | 160 | ||
156 | if (m_inList.isEmpty() ) | 161 | if (m_inList.isEmpty() ) |
157 | m_inf->stop(); | 162 | m_inf->stop(); |
158 | if (!m_out->isActive() && !m_outList.isEmpty() ) | 163 | if (!m_out->isActive() && !m_outList.isEmpty() ) |
159 | m_out->start( 100 ); | 164 | m_out->start( 100 ); |
160 | } | 165 | } |
161 | 166 | ||
162 | void SlaveReciever::slotThumbNail() { | 167 | void SlaveReciever::slotThumbNail() { |
163 | PixmapInfo inf = m_inPix.first(); | 168 | PixmapInfo inf = m_inPix.first(); |
164 | m_inPix.remove( inf ); | 169 | m_inPix.remove( inf ); |
165 | 170 | ||
166 | static SlaveObjects::Iterator it; | 171 | static SlaveObjects::Iterator it; |
167 | static SlaveObjects* map = slaveObjects(); // SlaveMap won't be changed during execution!!! | 172 | static SlaveObjects* map = slaveObjects(); // SlaveMap won't be changed during execution!!! |
168 | for(it = map->begin(); it != map->end(); ++it ) { | 173 | for(it = map->begin(); it != map->end(); ++it ) { |
169 | SlaveInterface* iface = it.data(); | 174 | SlaveInterface* iface = it.data(); |
170 | if( iface->supports(inf.file ) ) { | 175 | if( iface->supports(inf.file ) ) { |
171 | /* pixmap */ | 176 | /* pixmap */ |
172 | qWarning( "Asking for thumbNail in size %d %d for "+inf.file, inf.width, inf.height ); | 177 | qWarning( "Asking for thumbNail in size %d %d for "+inf.file, inf.width, inf.height ); |
173 | inf.pixmap = iface->pixmap(inf.file, 64, 64); | 178 | inf.pixmap = iface->pixmap(inf.file, 64, 64); |
174 | m_outPix.append( inf ); | 179 | m_outPix.append( inf ); |
175 | break; | 180 | break; |
176 | } | 181 | } |
177 | } | 182 | } |
178 | 183 | ||
179 | 184 | ||
180 | 185 | ||
181 | if(m_inPix.isEmpty() ) | 186 | if(m_inPix.isEmpty() ) |
182 | m_pix->stop(); | 187 | m_pix->stop(); |
183 | if(!m_out->isActive() && !m_outPix.isEmpty() ) | 188 | if(!m_out->isActive() && !m_outPix.isEmpty() ) |
184 | m_out->start(100); | 189 | m_out->start(100); |
185 | } | 190 | } |
186 | 191 | ||
187 | void SlaveReciever::slotSend() { | 192 | void SlaveReciever::slotSend() { |
188 | 193 | ||
189 | m_out->stop(); | 194 | m_out->stop(); |
190 | 195 | ||
191 | qWarning( "Sending %d %d", outPix().count(), outInf().count() ); | 196 | qWarning( "Sending %d %d", outPix().count(), outInf().count() ); |
192 | /* queue it and send */ | 197 | /* queue it and send */ |
193 | /* if this ever gets a service introduce request queues | 198 | /* if this ever gets a service introduce request queues |
194 | * so we can differinatate between different clients | 199 | * so we can differinatate between different clients |
195 | */ | 200 | */ |
196 | if (! m_outPix.isEmpty() ) { | 201 | if (! m_outPix.isEmpty() ) { |
197 | QCopEnvelope answer("QPE/opie-eye", "pixmapsHandled(PixmapList)" ); | 202 | QCopEnvelope answer("QPE/opie-eye", "pixmapsHandled(PixmapList)" ); |
198 | answer << outPix(); | 203 | answer << outPix(); |
199 | for ( PixmapList::Iterator it = m_outPix.begin();it!=m_outPix.end();++it ) { | 204 | for ( PixmapList::Iterator it = m_outPix.begin();it!=m_outPix.end();++it ) { |
200 | qWarning( "Sending out %s %d %d", (*it).file.latin1(), (*it).width, (*it).height ); | 205 | qWarning( "Sending out %s %d %d", (*it).file.latin1(), (*it).width, (*it).height ); |
201 | } | 206 | } |
202 | } | 207 | } |
203 | if ( !m_outList.isEmpty() ) { | 208 | if ( !m_outList.isEmpty() ) { |
204 | QCopEnvelope answer("QPE/opie-eye", "pixmapsHandled(StringList)" ); | 209 | QCopEnvelope answer("QPE/opie-eye", "pixmapsHandled(StringList)" ); |
205 | answer << outInf(); | 210 | answer << outInf(); |
206 | for ( StringList::Iterator it = m_outList.begin();it!=m_outList.end();++it ) { | 211 | for ( StringList::Iterator it = m_outList.begin();it!=m_outList.end();++it ) { |
207 | qWarning( "Sending out2 " + (*it).file ); | 212 | qWarning( "Sending out2 " + (*it).file ); |
208 | } | 213 | } |
209 | } | 214 | } |
210 | 215 | ||
211 | m_outList.clear(); | 216 | m_outList.clear(); |
212 | m_outPix.clear(); | 217 | m_outPix.clear(); |
213 | } | 218 | } |
214 | 219 | ||