summaryrefslogtreecommitdiff
authoralwin <alwin>2004-04-04 02:44:21 (UTC)
committer alwin <alwin>2004-04-04 02:44:21 (UTC)
commitdf0b892f8ec86ae6d21351a8ce1677d904dcdb2a (patch) (unidiff)
tree57dfd32247fe39ff480cc5e174675150112ed46f
parent354ad5e87ce582ee45b52cd6019bb94348958584 (diff)
downloadopie-df0b892f8ec86ae6d21351a8ce1677d904dcdb2a.zip
opie-df0b892f8ec86ae6d21351a8ce1677d904dcdb2a.tar.gz
opie-df0b892f8ec86ae6d21351a8ce1677d904dcdb2a.tar.bz2
first shot of an image info widget (this moment encapsulated just in a test
dlg which will removed later)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp13
-rw-r--r--noncore/graphics/opie-eye/gui/imageinfoui.cpp114
-rw-r--r--noncore/graphics/opie-eye/gui/imageinfoui.h48
-rw-r--r--noncore/graphics/opie-eye/phunk_view.pro8
4 files changed, 177 insertions, 6 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index f415d39..ac4b899 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -1,383 +1,390 @@
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#include <gui/imageinfoui.h>
9 10
10#include <iface/dirview.h> 11#include <iface/dirview.h>
11#include <iface/dirlister.h> 12#include <iface/dirlister.h>
12 13
13#include <opie2/oconfig.h> 14#include <opie2/oconfig.h>
14#include <opie2/okeyconfigwidget.h> 15#include <opie2/okeyconfigwidget.h>
15#include <opie2/odebug.h> 16#include <opie2/odebug.h>
16 17
17#include <qpe/resource.h> 18#include <qpe/resource.h>
18#include <qpe/qpemessagebox.h> 19#include <qpe/qpemessagebox.h>
19#include <qpe/ir.h> 20#include <qpe/ir.h>
20#include <qpe/qcopenvelope_qws.h> 21#include <qpe/qcopenvelope_qws.h>
21 22#include <qpe/qpeapplication.h>
22 23
23#include <qiconview.h> 24#include <qiconview.h>
24#include <qlabel.h> 25#include <qlabel.h>
25#include <qhbox.h> 26#include <qhbox.h>
26#include <qcombobox.h> 27#include <qcombobox.h>
27#include <qdir.h> 28#include <qdir.h>
28#include <qapplication.h> 29#include <qapplication.h>
29#include <qmainwindow.h> 30#include <qmainwindow.h>
30#include <qtimer.h> 31#include <qtimer.h>
31#include <qstyle.h> 32#include <qstyle.h>
32 33
33 34
34using Opie::Ui::OKeyConfigItem; 35using Opie::Ui::OKeyConfigItem;
35 36
36namespace { 37namespace {
37 QPixmap* _dirPix = 0; 38 QPixmap* _dirPix = 0;
38 QPixmap* _unkPix = 0; 39 QPixmap* _unkPix = 0;
39 class IconViewItem : public QIconViewItem { 40 class IconViewItem : public QIconViewItem {
40 public: 41 public:
41 IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); 42 IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false);
42 QPixmap* pixmap()const; 43 QPixmap* pixmap()const;
43 QString path()const { return m_path; } 44 QString path()const { return m_path; }
44 bool isDir()const { return m_isDir; } 45 bool isDir()const { return m_isDir; }
45 void setText( const QString& ); 46 void setText( const QString& );
46 47
47 48
48 private: 49 private:
49 mutable QPixmap* m_pix; 50 mutable QPixmap* m_pix;
50 QString m_path; 51 QString m_path;
51 bool m_isDir : 1; 52 bool m_isDir : 1;
52 bool m_noInfo :1; 53 bool m_noInfo :1;
53 }; 54 };
54 55
55 56
56/* 57/*
57 * If we request an Image or String 58 * If we request an Image or String
58 * we add it to the map 59 * we add it to the map
59 */ 60 */
60 QMap<QString, IconViewItem*> g_stringInf; 61 QMap<QString, IconViewItem*> g_stringInf;
61 QMap<QString, IconViewItem*> g_stringPix; 62 QMap<QString, IconViewItem*> g_stringPix;
62 63
63 IconViewItem::IconViewItem( QIconView* view,const QString& path, 64 IconViewItem::IconViewItem( QIconView* view,const QString& path,
64 const QString& name, bool isDir ) 65 const QString& name, bool isDir )
65 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), 66 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ),
66 m_noInfo( false ) 67 m_noInfo( false )
67 { 68 {
68 if ( isDir && !_dirPix ) 69 if ( isDir && !_dirPix )
69 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); 70 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser"));
70 else if ( !isDir && !_unkPix ) 71 else if ( !isDir && !_unkPix )
71 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); 72 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) );
72 } 73 }
73 inline QPixmap* IconViewItem::pixmap()const { 74 inline QPixmap* IconViewItem::pixmap()const {
74// qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", 75// qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d",
75// rect().x(),rect().y(),rect().width(),rect().height(), 76// rect().x(),rect().y(),rect().width(),rect().height(),
76// iconView()->contentsX(), iconView()->contentsY()); 77// iconView()->contentsX(), iconView()->contentsY());
77 78
78 if ( m_isDir ) 79 if ( m_isDir )
79 return _dirPix; 80 return _dirPix;
80 else{ 81 else{
81 if (!m_noInfo && !g_stringInf.contains( m_path ) ) { 82 if (!m_noInfo && !g_stringInf.contains( m_path ) ) {
82 currentView()->dirLister()->imageInfo( m_path ); 83 currentView()->dirLister()->imageInfo( m_path );
83 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); 84 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this));
84 } 85 }
85 86
86 m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); 87 m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 );
87 if ( !m_pix && !g_stringPix.contains( m_path )) { 88 if ( !m_pix && !g_stringPix.contains( m_path )) {
88 currentView()->dirLister()->thumbNail( m_path, 64, 64 ); 89 currentView()->dirLister()->thumbNail( m_path, 64, 64 );
89 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); 90 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
90 } 91 }
91 return m_pix ? m_pix : _unkPix; 92 return m_pix ? m_pix : _unkPix;
92 } 93 }
93 } 94 }
94 inline void IconViewItem::setText( const QString& str ) { 95 inline void IconViewItem::setText( const QString& str ) {
95 QString text = QIconViewItem::text()+"\n"+str; 96 QString text = QIconViewItem::text()+"\n"+str;
96 m_noInfo = true; 97 m_noInfo = true;
97 QIconViewItem::setText( text ); 98 QIconViewItem::setText( text );
98 } 99 }
99} 100}
100 101
101 102
102PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) 103PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg )
103 : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) 104 : QVBox( wid ), m_cfg( cfg ), m_updatet( false )
104{ 105{
105 { 106 {
106 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 107 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
107 } 108 }
108 m_path = QDir::homeDirPath(); 109 m_path = QDir::homeDirPath();
109 110
110 QHBox *hbox = new QHBox( this ); 111 QHBox *hbox = new QHBox( this );
111 QLabel* lbl = new QLabel( hbox ); 112 QLabel* lbl = new QLabel( hbox );
112 lbl->setText( tr("View as" ) ); 113 lbl->setText( tr("View as" ) );
113 114
114 m_views = new QComboBox( hbox, "View As" ); 115 m_views = new QComboBox( hbox, "View As" );
115 connect( m_views, SIGNAL(activated(int)), 116 connect( m_views, SIGNAL(activated(int)),
116 this, SLOT(slotViewChanged(int)) ); 117 this, SLOT(slotViewChanged(int)) );
117 118
118 m_view= new QIconView( this ); 119 m_view= new QIconView( this );
119 connect(m_view, SIGNAL(clicked(QIconViewItem*) ), 120 connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
120 this, SLOT(slotClicked(QIconViewItem*)) ); 121 this, SLOT(slotClicked(QIconViewItem*)) );
121 122
122 m_view->setArrangement( QIconView::LeftToRight ); 123 m_view->setArrangement( QIconView::LeftToRight );
123 m_view->setItemTextPos( QIconView::Right ); 124 m_view->setItemTextPos( QIconView::Right );
124 125
125 int dw = QApplication::desktop()->width(); 126 int dw = QApplication::desktop()->width();
126 int viewerWidth = dw-style().scrollBarExtent().width(); 127 int viewerWidth = dw-style().scrollBarExtent().width();
127 m_view->setGridX( viewerWidth-3*m_view->spacing()); 128 m_view->setGridX( viewerWidth-3*m_view->spacing());
128 m_view->setGridY( fontMetrics().height()*2+40 ); 129 m_view->setGridY( fontMetrics().height()*2+40 );
129 130
130 131
131 initKeys(); 132 initKeys();
132 133
133 loadViews(); 134 loadViews();
134 slotViewChanged( m_views->currentItem() ); 135 slotViewChanged( m_views->currentItem() );
135} 136}
136 137
137PIconView::~PIconView() { 138PIconView::~PIconView() {
138 { 139 {
139 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 140 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
140 } 141 }
141 m_viewManager->save(); 142 m_viewManager->save();
142 delete m_viewManager; 143 delete m_viewManager;
143} 144}
144 145
145Opie::Ui::OKeyConfigManager* PIconView::manager() { 146Opie::Ui::OKeyConfigManager* PIconView::manager() {
146 return m_viewManager; 147 return m_viewManager;
147} 148}
148 149
149void PIconView::initKeys() { 150void PIconView::initKeys() {
150 Opie::Ui::OKeyPair::List lst; 151 Opie::Ui::OKeyPair::List lst;
151 lst.append( Opie::Ui::OKeyPair::upArrowKey() ); 152 lst.append( Opie::Ui::OKeyPair::upArrowKey() );
152 lst.append( Opie::Ui::OKeyPair::downArrowKey() ); 153 lst.append( Opie::Ui::OKeyPair::downArrowKey() );
153 lst.append( Opie::Ui::OKeyPair::leftArrowKey() ); 154 lst.append( Opie::Ui::OKeyPair::leftArrowKey() );
154 lst.append( Opie::Ui::OKeyPair::rightArrowKey() ); 155 lst.append( Opie::Ui::OKeyPair::rightArrowKey() );
155 lst.append( Opie::Ui::OKeyPair::returnKey() ); 156 lst.append( Opie::Ui::OKeyPair::returnKey() );
156 157
157 m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", 158 m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "View-KeyBoard-Config",
158 lst, false,this, "keyconfig name" ); 159 lst, false,this, "keyconfig name" );
159 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", 160 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam",
160 Resource::loadPixmap("beam"), BeamItem, 161 Resource::loadPixmap("beam"), BeamItem,
161 Opie::Ui::OKeyPair(Qt::Key_B, Qt::ShiftButton), 162 Opie::Ui::OKeyPair(Qt::Key_B, Qt::ShiftButton),
162 this, SLOT(slotBeam())) ); 163 this, SLOT(slotBeam())) );
163 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", 164 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete",
164 Resource::loadPixmap("trash"), DeleteItem, 165 Resource::loadPixmap("trash"), DeleteItem,
165 Opie::Ui::OKeyPair(Qt::Key_D, Qt::ShiftButton), 166 Opie::Ui::OKeyPair(Qt::Key_D, Qt::ShiftButton),
166 this, SLOT(slotTrash())) ); 167 this, SLOT(slotTrash())) );
167 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", 168 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view",
168 Resource::loadPixmap("1to1"), ViewItem, 169 Resource::loadPixmap("1to1"), ViewItem,
169 Opie::Ui::OKeyPair(Qt::Key_V, Qt::ShiftButton), 170 Opie::Ui::OKeyPair(Qt::Key_V, Qt::ShiftButton),
170 this, SLOT(slotShowImage()))); 171 this, SLOT(slotShowImage())));
171 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", 172 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info",
172 Resource::loadPixmap("DocumentTypeWord"), InfoItem, 173 Resource::loadPixmap("DocumentTypeWord"), InfoItem,
173 Opie::Ui::OKeyPair(Qt::Key_I, Qt::ShiftButton ), 174 Opie::Ui::OKeyPair(Qt::Key_I, Qt::ShiftButton ),
174 this, SLOT(slotImageInfo()) ) ); 175 this, SLOT(slotImageInfo()) ) );
175 m_viewManager->load(); 176 m_viewManager->load();
176 m_viewManager->handleWidget( m_view ); 177 m_viewManager->handleWidget( m_view );
177} 178}
178 179
179void PIconView::slotDirUp() { 180void PIconView::slotDirUp() {
180 QDir dir( m_path ); 181 QDir dir( m_path );
181 dir.cdUp(); 182 dir.cdUp();
182 slotChangeDir( dir.absPath() ); 183 slotChangeDir( dir.absPath() );
183 184
184} 185}
185 186
186void PIconView::slotChangeDir(const QString& path) { 187void PIconView::slotChangeDir(const QString& path) {
187 if ( !currentView() ) 188 if ( !currentView() )
188 return; 189 return;
189 190
190 PDirLister *lister = currentView()->dirLister(); 191 PDirLister *lister = currentView()->dirLister();
191 if (!lister ) 192 if (!lister )
192 return; 193 return;
193 194
194 lister->setStartPath( path ); 195 lister->setStartPath( path );
195 m_path = lister->currentPath(); 196 m_path = lister->currentPath();
196 197
197 m_view->viewport()->setUpdatesEnabled( false ); 198 m_view->viewport()->setUpdatesEnabled( false );
198 m_view->clear(); 199 m_view->clear();
199 addFolders( lister->folders() ); 200 addFolders( lister->folders() );
200 addFiles( lister->files() ); 201 addFiles( lister->files() );
201 m_view->viewport()->setUpdatesEnabled( true ); 202 m_view->viewport()->setUpdatesEnabled( true );
202 203
203 // Also invalidate the cache. We can't cancel the operations anyway 204 // Also invalidate the cache. We can't cancel the operations anyway
204 g_stringPix.clear(); 205 g_stringPix.clear();
205 g_stringInf.clear(); 206 g_stringInf.clear();
206 207
207 // looks ugly 208 // looks ugly
208 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); 209 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
209} 210}
210 211
211QString PIconView::currentFileName(bool &isDir)const { 212QString PIconView::currentFileName(bool &isDir)const {
212 isDir = false; 213 isDir = false;
213 QIconViewItem* _it = m_view->currentItem(); 214 QIconViewItem* _it = m_view->currentItem();
214 if ( !_it ) 215 if ( !_it )
215 return QString::null; 216 return QString::null;
216 217
217 IconViewItem* it = static_cast<IconViewItem*>( _it ); 218 IconViewItem* it = static_cast<IconViewItem*>( _it );
218 isDir = it->isDir(); 219 isDir = it->isDir();
219 return it->path(); 220 return it->path();
220} 221}
221 222
222void PIconView::slotTrash() { 223void PIconView::slotTrash() {
223 bool isDir; 224 bool isDir;
224 QString pa = currentFileName( isDir ); 225 QString pa = currentFileName( isDir );
225 if ( isDir && pa.isEmpty() ) 226 if ( isDir && pa.isEmpty() )
226 return; 227 return;
227 228
228 if (!QPEMessageBox::confirmDelete( this, 229 if (!QPEMessageBox::confirmDelete( this,
229 tr("Delete Image" ), 230 tr("Delete Image" ),
230 tr("the Image %1" ).arg(pa))) 231 tr("the Image %1" ).arg(pa)))
231 return 232 return
232 233
233 234
234 currentView()->dirLister()->deleteImage( pa ); 235 currentView()->dirLister()->deleteImage( pa );
235 delete m_view->currentItem(); 236 delete m_view->currentItem();
236} 237}
237void PIconView::loadViews() { 238void PIconView::loadViews() {
238 ViewMap::Iterator it; 239 ViewMap::Iterator it;
239 ViewMap* map = viewMap(); 240 ViewMap* map = viewMap();
240 for ( it = map->begin(); it != map->end(); ++it ) 241 for ( it = map->begin(); it != map->end(); ++it )
241 m_views->insertItem( QObject::tr(it.key() ) ); 242 m_views->insertItem( QObject::tr(it.key() ) );
242} 243}
243 244
244void PIconView::resetView() { 245void PIconView::resetView() {
245 slotViewChanged(m_views->currentItem()); 246 slotViewChanged(m_views->currentItem());
246} 247}
247 248
248void PIconView::slotViewChanged( int i) { 249void PIconView::slotViewChanged( int i) {
249 if (!m_views->count() ) { 250 if (!m_views->count() ) {
250 setCurrentView( 0l); 251 setCurrentView( 0l);
251 return; 252 return;
252 } 253 }
253 254
254 PDirView* cur = currentView(); 255 PDirView* cur = currentView();
255 delete cur; 256 delete cur;
256 QString str = m_views->text(i); 257 QString str = m_views->text(i);
257 cur = (*(*viewMap())[str])(*m_cfg); 258 cur = (*(*viewMap())[str])(*m_cfg);
258 setCurrentView( cur ); 259 setCurrentView( cur );
259 260
260 /* connect to the signals of the lister */ 261 /* connect to the signals of the lister */
261 PDirLister* lis = cur->dirLister(); 262 PDirLister* lis = cur->dirLister();
262 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), 263 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )),
263 this, SLOT( slotThumbInfo(const QString&, const QString&))); 264 this, SLOT( slotThumbInfo(const QString&, const QString&)));
264 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), 265 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
265 this, SLOT(slotThumbNail(const QString&, const QPixmap&))); 266 this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
266 connect(lis, SIGNAL(sig_start()), 267 connect(lis, SIGNAL(sig_start()),
267 this, SLOT(slotStart())); 268 this, SLOT(slotStart()));
268 connect(lis, SIGNAL(sig_end()) , 269 connect(lis, SIGNAL(sig_end()) ,
269 this, SLOT(slotEnd()) ); 270 this, SLOT(slotEnd()) );
270 271
271 272
272 /* reload now */ 273 /* reload now */
273 QTimer::singleShot( 0, this, SLOT(slotReloadDir())); 274 QTimer::singleShot( 0, this, SLOT(slotReloadDir()));
274} 275}
275 276
276 277
277void PIconView::slotReloadDir() { 278void PIconView::slotReloadDir() {
278 slotChangeDir( m_path ); 279 slotChangeDir( m_path );
279} 280}
280 281
281 282
282void PIconView::addFolders( const QStringList& lst) { 283void PIconView::addFolders( const QStringList& lst) {
283 QStringList::ConstIterator it; 284 QStringList::ConstIterator it;
284 285
285 for(it=lst.begin(); it != lst.end(); ++it ) { 286 for(it=lst.begin(); it != lst.end(); ++it ) {
286 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); 287 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true );
287 } 288 }
288 289
289} 290}
290 291
291void PIconView::addFiles( const QStringList& lst) { 292void PIconView::addFiles( const QStringList& lst) {
292 QStringList::ConstIterator it; 293 QStringList::ConstIterator it;
293 for (it=lst.begin(); it!= lst.end(); ++it ) 294 for (it=lst.begin(); it!= lst.end(); ++it )
294 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); 295 (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) );
295 296
296} 297}
297 298
298void PIconView::slotClicked(QIconViewItem* _it) { 299void PIconView::slotClicked(QIconViewItem* _it) {
299 if(!_it ) 300 if(!_it )
300 return; 301 return;
301 302
302 IconViewItem* it = static_cast<IconViewItem*>(_it); 303 IconViewItem* it = static_cast<IconViewItem*>(_it);
303 if( it->isDir() ) 304 if( it->isDir() )
304 slotChangeDir( it->path() ); 305 slotChangeDir( it->path() );
305 else // view image 306 else // view image
306 ; 307 ;
307} 308}
308 309
309void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { 310void PIconView::slotThumbInfo( const QString& _path, const QString& str ) {
310 IconViewItem* item = g_stringInf[_path]; 311 IconViewItem* item = g_stringInf[_path];
311 if (!item ) 312 if (!item )
312 return; 313 return;
313 314
314 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), 315 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
315 m_view->contentsWidth(), m_view->contentsHeight() ) ) ) 316 m_view->contentsWidth(), m_view->contentsHeight() ) ) )
316 m_updatet = true; 317 m_updatet = true;
317 318
318 item->setText( str ); 319 item->setText( str );
319 g_stringInf.remove( _path ); 320 g_stringInf.remove( _path );
320} 321}
321void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { 322void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) {
322 IconViewItem* item = g_stringPix[_path]; 323 IconViewItem* item = g_stringPix[_path];
323 if (!item ) 324 if (!item )
324 return; 325 return;
325 326
326 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), 327 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
327 m_view->contentsWidth(), m_view->contentsHeight() ) ) ) 328 m_view->contentsWidth(), m_view->contentsHeight() ) ) )
328 m_updatet = true; 329 m_updatet = true;
329 330
330 if (pix.width()>0) 331 if (pix.width()>0)
331 PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); 332 PPixmapCache::self()->insertImage( _path, pix, 64, 64 );
332 333
333 334
334 g_stringPix.remove( _path ); 335 g_stringPix.remove( _path );
335} 336}
336 337
337 338
338void PIconView::slotRename() { 339void PIconView::slotRename() {
339 340
340} 341}
341 342
342void PIconView::slotBeam() { 343void PIconView::slotBeam() {
343 bool isDir; 344 bool isDir;
344 QString pa = currentFileName( isDir ); 345 QString pa = currentFileName( isDir );
345 if ( isDir && pa.isEmpty() ) 346 if ( isDir && pa.isEmpty() )
346 return; 347 return;
347 348
348 Ir* ir = new Ir( this ); 349 Ir* ir = new Ir( this );
349 connect( ir, SIGNAL(done(Ir*)), 350 connect( ir, SIGNAL(done(Ir*)),
350 this, SLOT(slotBeamDone(Ir*))); 351 this, SLOT(slotBeamDone(Ir*)));
351 ir->send(pa, tr( "Image" ) ); 352 ir->send(pa, tr( "Image" ) );
352 353
353} 354}
354 355
355void PIconView::slotBeamDone( Ir* ir) { 356void PIconView::slotBeamDone( Ir* ir) {
356 delete ir; 357 delete ir;
357} 358}
358 359
359void PIconView::slotStart() { 360void PIconView::slotStart() {
360 m_view->viewport()->setUpdatesEnabled( false ); 361 m_view->viewport()->setUpdatesEnabled( false );
361 qWarning( "Sig Start" ); 362 qWarning( "Sig Start" );
362} 363}
363 364
364void PIconView::slotEnd() { 365void PIconView::slotEnd() {
365 qWarning( "SLot End" ); 366 qWarning( "SLot End" );
366 if ( m_updatet ) 367 if ( m_updatet )
367 m_view->arrangeItemsInGrid( ); 368 m_view->arrangeItemsInGrid( );
368 m_view->viewport()->setUpdatesEnabled( true ); 369 m_view->viewport()->setUpdatesEnabled( true );
369 m_updatet = false; 370 m_updatet = false;
370} 371}
371 372
372void PIconView::slotShowImage() { 373void PIconView::slotShowImage() {
373 374
374} 375}
375void PIconView::slotShowImage( const QString& ) { 376void PIconView::slotShowImage( const QString& ) {
376 377
377} 378}
378void PIconView::slotImageInfo() { 379void PIconView::slotImageInfo() {
379 380 qDebug("image info");
381 bool isDir = false;
382 QString name = currentFileName(isDir);
383 if (isDir) return;
384 infoDlg dlg(name);
385 QPEApplication::execDialog(&dlg);
380} 386}
381void PIconView::slotImageInfo( const QString& ) {
382 387
388void PIconView::slotImageInfo( const QString& ) {
389
383} 390}
diff --git a/noncore/graphics/opie-eye/gui/imageinfoui.cpp b/noncore/graphics/opie-eye/gui/imageinfoui.cpp
new file mode 100644
index 0000000..177df77
--- a/dev/null
+++ b/noncore/graphics/opie-eye/gui/imageinfoui.cpp
@@ -0,0 +1,114 @@
1#include "imageinfoui.h"
2
3#include <qframe.h>
4#include <qlabel.h>
5#include <qpushbutton.h>
6#include <qtextview.h>
7#include <qlayout.h>
8#include <qvariant.h>
9#include <qtooltip.h>
10#include <qwhatsthis.h>
11#include <qimage.h>
12#include <qpixmap.h>
13#include <qstring.h>
14
15#include <lib/slavemaster.h>
16#include <lib/imagecache.h>
17
18#include <qpe/qcopenvelope_qws.h>
19#include <qpe/resource.h>
20
21imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WFlags fl )
22 : QWidget( parent, name, fl ),currentFile(_path)
23{
24 {
25 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
26 }
27 if ( !name )
28 setName( "imageinfo" );
29 resize( 289, 335 );
30 setCaption( tr( "Image info" ) );
31 imageinfoLayout = new QVBoxLayout( this );
32 imageinfoLayout->setSpacing(2);
33 imageinfoLayout->setMargin(2);
34
35 PixmapLabel1 = new QLabel( this, "PixmapLabel1" );
36 PixmapLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, PixmapLabel1->sizePolicy().hasHeightForWidth() ) );
37 PixmapLabel1->setScaledContents( TRUE );
38 imageinfoLayout->addWidget( PixmapLabel1 );
39
40 Line1 = new QFrame( this, "Line1" );
41 Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken );
42 imageinfoLayout->addWidget( Line1 );
43
44 fnameLabel = new QLabel( this, "FnameLabel" );
45 imageinfoLayout->addWidget( fnameLabel);
46
47 TextView1 = new QTextView( this, "TextView1" );
48 TextView1->setFrameShadow( QTextView::Plain );
49 QToolTip::add( TextView1, tr( "Displays info of selected image" ) );
50 QWhatsThis::add( TextView1, tr( "Displays info of selected image" ) );
51 imageinfoLayout->addWidget( TextView1 );
52
53 SlaveMaster* master = SlaveMaster::self();
54 connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)),
55 this, SLOT(slot_fullInfo(const QString&, const QString&)) );
56 connect(master, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
57 this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
58 slotChangeName(_path);
59}
60
61void imageinfo::slotChangeName(const QString&_path)
62{
63 currentFile=_path;
64 fnameLabel->setText("<qt><center><b>"+currentFile+"</b></center></qt>");
65 SlaveMaster::self()->imageInfo( currentFile );
66
67 QPixmap*m_pix = PPixmapCache::self()->cachedImage( _path, 64, 64 );
68 if (!m_pix) {
69 PixmapLabel1->setPixmap(QPixmap( Resource::loadPixmap( "UnknownDocument" )));
70 } else {
71 PixmapLabel1->setPixmap(*m_pix);
72 }
73}
74
75imageinfo::~imageinfo()
76{
77 {
78 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
79 }
80}
81
82void imageinfo::slot_fullInfo(const QString&_path, const QString&_t)
83{
84 if (_path == currentFile) {
85 qDebug(_t);
86 QString t = _t;
87 t.replace(QRegExp("\n"),"<br>");
88 TextView1->setText(t);
89 }
90}
91
92void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix)
93{
94 if (_pix.width()>0)
95 PPixmapCache::self()->insertImage( _path, _pix, 64, 64 );
96 if (_path == currentFile) {
97 PixmapLabel1->setPixmap( _pix );
98 }
99}
100
101/* for testing */
102infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name)
103 :QDialog(parent,name,true,WStyle_ContextHelp)
104{
105 QVBoxLayout*dlglayout = new QVBoxLayout(this);
106 dlglayout->setSpacing(2);
107 dlglayout->setMargin(1);
108 imageinfo*inf = new imageinfo(fname,this);
109 dlglayout->addWidget(inf);
110}
111
112infoDlg::~infoDlg()
113{
114}
diff --git a/noncore/graphics/opie-eye/gui/imageinfoui.h b/noncore/graphics/opie-eye/gui/imageinfoui.h
new file mode 100644
index 0000000..34ec937
--- a/dev/null
+++ b/noncore/graphics/opie-eye/gui/imageinfoui.h
@@ -0,0 +1,48 @@
1#ifndef IMAGEINFO_H
2#define IMAGEINFO_H
3
4#include <qvariant.h>
5#include <qwidget.h>
6#include <qdialog.h>
7
8class QVBoxLayout;
9class QHBoxLayout;
10class QGridLayout;
11class QFrame;
12class QLabel;
13class QTextView;
14
15class imageinfo : public QWidget
16{
17 Q_OBJECT
18
19public:
20 imageinfo(const QString&_path, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
21 ~imageinfo();
22
23 QLabel* PixmapLabel1;
24 QLabel* fnameLabel;
25 QFrame* Line1;
26 QTextView* TextView1;
27
28protected:
29 QVBoxLayout* imageinfoLayout;
30 QString currentFile;
31
32protected slots:
33 virtual void slot_fullInfo(const QString&, const QString&);
34 virtual void slotThumbNail(const QString&, const QPixmap&);
35
36 virtual void slotChangeName(const QString&);
37};
38
39/* for testing purpose */
40class infoDlg:public QDialog
41{
42 Q_OBJECT
43public:
44 infoDlg(const QString&,QWidget * parent=0, const char * name=0);
45 virtual ~infoDlg();
46};
47
48#endif // IMAGEINFO_H
diff --git a/noncore/graphics/opie-eye/phunk_view.pro b/noncore/graphics/opie-eye/phunk_view.pro
index 3547af0..17fa22c 100644
--- a/noncore/graphics/opie-eye/phunk_view.pro
+++ b/noncore/graphics/opie-eye/phunk_view.pro
@@ -1,34 +1,36 @@
1CONFIG += qt warn_on quick-app 1CONFIG += qt warn_on quick-app
2DESTDIR = $(OPIEDIR)/bin 2DESTDIR = $(OPIEDIR)/bin
3TEMPLATE = app 3TEMPLATE = app
4TARGET = opie-eye 4TARGET = opie-eye
5# the name of the resulting object 5# the name of the resulting object
6 6
7HEADERS = gui/iconview.h gui/filesystem.h gui/mainwindow.h \ 7HEADERS = gui/iconview.h gui/filesystem.h gui/mainwindow.h \
8 lib/imagecache.h impl/dir/dir_dirview.h \ 8 lib/imagecache.h impl/dir/dir_dirview.h \
9 iface/dirview.h iface/dirlister.h iface/ifaceinfo.h \ 9 iface/dirview.h iface/dirlister.h iface/ifaceinfo.h \
10 impl/dir/dir_lister.h impl/dir/dir_ifaceinfo.h \ 10 impl/dir/dir_lister.h impl/dir/dir_ifaceinfo.h \
11 lib/slavemaster.h \ 11 lib/slavemaster.h \
12 iface/slaveiface.h 12 iface/slaveiface.h \
13 gui/imageinfoui.h
13 14
14# A list header files 15# A list header files
15 16
16 17
17SOURCES = gui/iconview.cpp gui/filesystem.cpp gui/mainwindow.cpp \ 18SOURCES = gui/iconview.cpp gui/filesystem.cpp gui/mainwindow.cpp \
18 lib/imagecache.cpp lib/viewmap.cpp \ 19 lib/imagecache.cpp lib/viewmap.cpp \
19 impl/dir/dir_dirview.cpp iface/dirlister.cpp \ 20 impl/dir/dir_dirview.cpp iface/dirlister.cpp \
20 iface/dirview.cpp impl/dir/dir_lister.cpp \ 21 iface/dirview.cpp impl/dir/dir_lister.cpp \
21 impl/dir/dir_ifaceinfo.cpp lib/slavemaster.cpp 22 impl/dir/dir_ifaceinfo.cpp lib/slavemaster.cpp \
23 gui/imageinfoui.cpp
22# A list of source files 24# A list of source files
23 25
24INTERFACES = 26INTERFACES =
25# list of ui files 27# list of ui files
26 28
27INCLUDEPATH += . $(OPIEDIR)/include 29INCLUDEPATH += . $(OPIEDIR)/include
28DEPENDPATH += $(OPIEDIR)/include 30DEPENDPATH += $(OPIEDIR)/include
29 31
30 32
31 33
32LIBS += -lqpe -lopieui2 34LIBS += -lqpe -lopieui2
33 35
34include ( $(OPIEDIR)/include.pro ) 36include ( $(OPIEDIR)/include.pro )