summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp64
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.h4
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.cpp15
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.h2
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp47
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.h3
-rw-r--r--noncore/graphics/opie-eye/impl/doc/doc_lister.cpp137
-rw-r--r--noncore/graphics/opie-eye/impl/doc/doc_lister.h8
8 files changed, 178 insertions, 102 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index 948477c..138e661 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -7,726 +7,742 @@
7 7
8#include <lib/imagecache.h> 8#include <lib/imagecache.h>
9#include <gui/imageinfoui.h> 9#include <gui/imageinfoui.h>
10 10
11#include <iface/dirview.h> 11#include <iface/dirview.h>
12#include <iface/dirlister.h> 12#include <iface/dirlister.h>
13 13
14#include <opie2/oconfig.h> 14#include <opie2/oconfig.h>
15#include <opie2/okeyconfigwidget.h> 15#include <opie2/okeyconfigwidget.h>
16#include <opie2/odebug.h> 16#include <opie2/odebug.h>
17#include <opie2/oimagescrollview.h> 17#include <opie2/oimagescrollview.h>
18 18
19#include <qpe/resource.h> 19#include <qpe/resource.h>
20#include <qpe/qpemessagebox.h> 20#include <qpe/qpemessagebox.h>
21#include <qpe/ir.h> 21#include <qpe/ir.h>
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24 24
25#include <qiconview.h> 25#include <qiconview.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qhbox.h> 27#include <qhbox.h>
28#include <qcombobox.h> 28#include <qcombobox.h>
29#include <qdir.h> 29#include <qdir.h>
30#include <qapplication.h> 30#include <qapplication.h>
31#include <qmainwindow.h> 31#include <qmainwindow.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qstyle.h> 33#include <qstyle.h>
34 34
35 35
36using Opie::Core::OKeyConfigItem; 36using Opie::Core::OKeyConfigItem;
37 37
38/* 38/*
39 * The Icons, Request Cache and IconViewItem for the IconView 39 * The Icons, Request Cache and IconViewItem for the IconView
40 */ 40 */
41namespace { 41namespace {
42 static QPixmap* _dirPix = 0; 42 static QPixmap* _dirPix = 0;
43 static QPixmap* _unkPix = 0; 43 static QPixmap* _unkPix = 0;
44 static QPixmap* _cpyPix = 0; 44 static QPixmap* _cpyPix = 0;
45 static QPixmap* _emptyPix = 0; 45 static QPixmap* _emptyPix = 0;
46 class IconViewItem : public QIconViewItem { 46 class IconViewItem : public QIconViewItem {
47 public: 47 public:
48 IconViewItem( QIconView*, const QString& path, const QString& name,int a_iconsize, bool isDir = false); 48 IconViewItem( QIconView*, const QString& path, const QString& name,int a_iconsize, bool isDir = false);
49 QPixmap* pixmap()const; 49 QPixmap* pixmap()const;
50 QString path()const { return m_path; } 50 QString path()const { return m_path; }
51 bool isDir()const { return m_isDir; } 51 bool isDir()const { return m_isDir; }
52 void setText( const QString& ); 52 void setText( const QString& );
53 bool textOnly()const{return m_textOnly;} 53 bool textOnly()const{return m_textOnly;}
54 void setTextOnly(bool how){m_textOnly=how;} 54 void setTextOnly(bool how){m_textOnly=how;}
55 /* just for starting recalc of item rect! */ 55 /* just for starting recalc of item rect! */
56 virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); 56 virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE );
57 /* just for starting recalc of item rect! */ 57 /* just for starting recalc of item rect! */
58 virtual void setPixmap( const QPixmap & icon); 58 virtual void setPixmap( const QPixmap & icon);
59 59
60 protected: 60 protected:
61 mutable QPixmap* m_pix; 61 mutable QPixmap* m_pix;
62 int m_iconsize; 62 int m_iconsize;
63 void check_pix()const; 63 void check_pix()const;
64 64
65 private: 65 private:
66 QString m_path; 66 QString m_path;
67 bool m_isDir : 1; 67 bool m_isDir : 1;
68 bool m_noInfo :1; 68 bool m_noInfo :1;
69 bool m_textOnly:1; 69 bool m_textOnly:1;
70 bool m_NameOnly:1; 70 bool m_NameOnly:1;
71 bool m_Pixset:1; 71 bool m_Pixset:1;
72 }; 72 };
73 class TextViewItem : public IconViewItem { 73 class TextViewItem : public IconViewItem {
74 TextViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize , bool isDir = false); 74 TextViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize , bool isDir = false);
75 QPixmap *pixmap()const; 75 QPixmap *pixmap()const;
76 void setText( const QString& ); 76 void setText( const QString& );
77 }; 77 };
78 class ThumbViewItem : public IconViewItem { 78 class ThumbViewItem : public IconViewItem {
79 ThumbViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize, bool isDir = false ); 79 ThumbViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize, bool isDir = false );
80 QPixmap *pixmap()const; 80 QPixmap *pixmap()const;
81 void setText( const QString& ); 81 void setText( const QString& );
82 }; 82 };
83 83
84 84
85/* 85/*
86 * If we request an Image or String 86 * If we request an Image or String
87 * we add it to the map 87 * we add it to the map
88 */ 88 */
89 static QMap<QString, IconViewItem*> g_stringInf; 89 static QMap<QString, IconViewItem*> g_stringInf;
90 static QMap<QString, IconViewItem*> g_stringPix; 90 static QMap<QString, IconViewItem*> g_stringPix;
91 91
92 IconViewItem::IconViewItem( QIconView* view,const QString& path, 92 IconViewItem::IconViewItem( QIconView* view,const QString& path,
93 const QString& name, int a_iconsize, bool isDir) 93 const QString& name, int a_iconsize, bool isDir)
94 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), 94 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ),
95 m_noInfo( false ),m_textOnly(false),m_Pixset(false) 95 m_noInfo( false ),m_textOnly(false),m_Pixset(false)
96 { 96 {
97 m_iconsize = a_iconsize; 97 m_iconsize = a_iconsize;
98 if ( isDir ) { 98 if ( isDir ) {
99 if (!_dirPix ) { 99 if (!_dirPix ) {
100 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); 100 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser"));
101 } 101 }
102 } else { 102 } else {
103 if (!_unkPix ) { 103 if (!_unkPix ) {
104 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); 104 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) );
105 } 105 }
106 } 106 }
107 check_pix(); 107 check_pix();
108 } 108 }
109 109
110 inline void IconViewItem::check_pix()const 110 inline void IconViewItem::check_pix()const
111 { 111 {
112 if (_dirPix && _dirPix->width()>m_iconsize) { 112 if (_dirPix && _dirPix->width()>m_iconsize) {
113 QImage Pix = _dirPix->convertToImage(); 113 QImage Pix = _dirPix->convertToImage();
114 *_dirPix = Pix.smoothScale(m_iconsize,m_iconsize); 114 *_dirPix = Pix.smoothScale(m_iconsize,m_iconsize);
115 } 115 }
116 if (!_cpyPix && _unkPix) { 116 if (!_cpyPix && _unkPix) {
117 if (_unkPix->width()>=m_iconsize) { 117 if (_unkPix->width()>=m_iconsize) {
118 QImage Pix = _unkPix->convertToImage(); 118 QImage Pix = _unkPix->convertToImage();
119 _cpyPix = new QPixmap(); 119 _cpyPix = new QPixmap();
120 if (_unkPix->width()>m_iconsize) { 120 if (_unkPix->width()>m_iconsize) {
121 *_cpyPix = Pix.smoothScale(m_iconsize,m_iconsize); 121 *_cpyPix = Pix.smoothScale(m_iconsize,m_iconsize);
122 } else { 122 } else {
123 _cpyPix->convertFromImage(Pix); 123 _cpyPix->convertFromImage(Pix);
124 } 124 }
125 125
126 } else { 126 } else {
127 _cpyPix = new QPixmap(m_iconsize,m_iconsize); 127 _cpyPix = new QPixmap(m_iconsize,m_iconsize);
128 _cpyPix->fill(); 128 _cpyPix->fill();
129 QPainter pa(_cpyPix); 129 QPainter pa(_cpyPix);
130 int offset = (m_iconsize-_unkPix->width())/2; 130 int offset = (m_iconsize-_unkPix->width())/2;
131 int offy = (m_iconsize-_unkPix->height())/2; 131 int offy = (m_iconsize-_unkPix->height())/2;
132 if (offy<0) offy=0; 132 if (offy<0) offy=0;
133 pa.drawPixmap(offset,offy,*_unkPix); 133 pa.drawPixmap(offset,offy,*_unkPix);
134 pa.end(); 134 pa.end();
135 } 135 }
136 } 136 }
137 } 137 }
138 138
139 inline void IconViewItem::setPixmap( const QPixmap & , bool, bool ) 139 inline void IconViewItem::setPixmap( const QPixmap & , bool, bool )
140 { 140 {
141 m_Pixset = true; 141 m_Pixset = true;
142 calcRect(text()); 142 calcRect(text());
143 } 143 }
144 inline void IconViewItem::setPixmap( const QPixmap & ) 144 inline void IconViewItem::setPixmap( const QPixmap & )
145 { 145 {
146 m_Pixset = true; 146 m_Pixset = true;
147 calcRect(text()); 147 calcRect(text());
148 } 148 }
149 149
150 inline QPixmap* IconViewItem::pixmap()const { 150 inline QPixmap* IconViewItem::pixmap()const {
151// owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y() 151// owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y()
152// << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX() 152// << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX()
153// << " " << iconView()->contentsY() << oendl; 153// << " " << iconView()->contentsY() << oendl;
154 154
155 if (textOnly()&&!m_isDir) { 155 if (textOnly()&&!m_isDir) {
156 if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); 156 if (!_emptyPix) _emptyPix = new QPixmap(0,0,1);
157 return _emptyPix; 157 return _emptyPix;
158 } 158 }
159 if ( m_isDir ) 159 if ( m_isDir )
160 return _dirPix; 160 return _dirPix;
161 else{ 161 else{
162 if (!m_noInfo && !g_stringInf.contains( m_path ) ) { 162 if (!m_noInfo && !g_stringInf.contains( m_path ) ) {
163 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); 163 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this));
164 currentView()->dirLister()->imageInfo( m_path ); 164 currentView()->dirLister()->imageInfo( m_path );
165 } 165 }
166 166
167 m_pix = PPixmapCache::self()->cachedImage( m_path, m_iconsize, m_iconsize ); 167 m_pix = PPixmapCache::self()->cachedImage( m_path, m_iconsize, m_iconsize );
168 if (!m_pix && !g_stringPix.contains( m_path )) { 168 if (!m_pix && !g_stringPix.contains( m_path )) {
169 check_pix(); 169 check_pix();
170 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); 170 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
171 currentView()->dirLister()->thumbNail( m_path, m_iconsize, m_iconsize); 171 currentView()->dirLister()->thumbNail( m_path, m_iconsize, m_iconsize);
172 } 172 }
173 return m_pix ? m_pix : _cpyPix; 173 return m_pix ? m_pix : _cpyPix;
174 } 174 }
175 } 175 }
176 inline void IconViewItem::setText( const QString& str ) { 176 inline void IconViewItem::setText( const QString& str ) {
177 QString text = QIconViewItem::text()+"\n"+str; 177 QString text = QIconViewItem::text()+"\n"+str;
178 m_noInfo = true; 178 m_noInfo = true;
179 QIconViewItem::setText( text ); 179 QIconViewItem::setText( text );
180 } 180 }
181} 181}
182 182
183 183
184/* 184/*
185 * Set up the GUI.. initialize the slave set up gui 185 * Set up the GUI.. initialize the slave set up gui
186 * and also load a dir 186 * and also load a dir
187 */ 187 */
188PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) 188PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg )
189 : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) 189 : QVBox( wid ), m_cfg( cfg ), m_updatet( false )
190{ 190{
191 { 191 {
192 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 192 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
193 } 193 }
194 m_path = QDir::homeDirPath(); 194 m_path = QDir::homeDirPath();
195 m_mode = 0; 195 m_mode = 0;
196 m_iconsize = 32; 196 m_iconsize = 32;
197 m_internalReset = false; 197 m_internalReset = false;
198 m_customWidget = 0; 198 m_customWidget = 0;
199 m_setDocCalled = false;
199 200
200 m_hbox = new QHBox( this ); 201 m_hbox = new QHBox( this );
201 QLabel* lbl = new QLabel( m_hbox ); 202 QLabel* lbl = new QLabel( m_hbox );
202 lbl->setText( tr("View as" ) ); 203 lbl->setText( tr("View as" ) );
203 204
204 m_views = new QComboBox( m_hbox, "View As" ); 205 m_views = new QComboBox( m_hbox, "View As" );
205 206
206 m_view= new QIconView( this ); 207 m_view= new QIconView( this );
207 connect(m_view, SIGNAL(clicked(QIconViewItem*) ), 208 connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
208 this, SLOT(slotClicked(QIconViewItem*)) ); 209 this, SLOT(slotClicked(QIconViewItem*)) );
209 connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), 210 connect(m_view, SIGNAL(returnPressed(QIconViewItem*)),
210 this, SLOT(slotClicked(QIconViewItem*)) ); 211 this, SLOT(slotClicked(QIconViewItem*)) );
211 212
212 m_view->setArrangement( QIconView::LeftToRight ); 213 m_view->setArrangement( QIconView::LeftToRight );
213 214
214 m_mode = m_cfg->readNumEntry("ListViewMode", 1); 215 m_mode = m_cfg->readNumEntry("ListViewMode", 1);
215 QString lastView = m_cfg->readEntry("LastView","");
216
217 if (m_mode < 1 || m_mode>3) m_mode = 1; 216 if (m_mode < 1 || m_mode>3) m_mode = 1;
218
219 m_view->setItemTextPos( QIconView::Right ); 217 m_view->setItemTextPos( QIconView::Right );
220 if (m_mode >1) { 218 if (m_mode >1) {
221 m_view->setResizeMode(QIconView::Adjust); 219 m_view->setResizeMode(QIconView::Adjust);
222 } else { 220 } else {
223 m_view->setResizeMode(QIconView::Fixed); 221 m_view->setResizeMode(QIconView::Fixed);
224 } 222 }
225 m_iconsize = m_cfg->readNumEntry("iconsize", 32); 223 m_iconsize = m_cfg->readNumEntry("iconsize", 32);
226 if (m_iconsize<12)m_iconsize = 12; 224 if (m_iconsize<12)m_iconsize = 12;
227 if (m_iconsize>64)m_iconsize = 64; 225 if (m_iconsize>64)m_iconsize = 64;
228 226
229 calculateGrid(); 227 calculateGrid();
230
231 initKeys(); 228 initKeys();
232
233 loadViews(); 229 loadViews();
234 int cc=0; 230}
235 for (; cc<m_views->count();++cc) { 231
236 if (m_views->text(cc)==lastView) { 232void PIconView::setDoccalled(bool how)
237 break; 233{
238 } 234 m_setDocCalled = how;
239 }
240 if (cc<m_views->count()) {
241 m_views->setCurrentItem(cc);
242 slotViewChanged(cc);
243 } else {
244 slotViewChanged(m_views->currentItem());
245 }
246 connect( m_views, SIGNAL(activated(int)),
247 this, SLOT(slotViewChanged(int)) );
248} 235}
249 236
250/* 237/*
251 * Unref the slave and save the keyboard manager 238 * Unref the slave and save the keyboard manager
252 */ 239 */
253PIconView::~PIconView() { 240PIconView::~PIconView() {
254 { 241 {
255 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 242 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
256 } 243 }
257 m_viewManager->save(); 244 m_viewManager->save();
258 delete m_viewManager; 245 delete m_viewManager;
259} 246}
260 247
261Opie::Core::OKeyConfigManager* PIconView::manager() { 248Opie::Core::OKeyConfigManager* PIconView::manager() {
262 return m_viewManager; 249 return m_viewManager;
263} 250}
264 251
265 252
266/* 253/*
267 * init the KeyBoard Shortcuts 254 * init the KeyBoard Shortcuts
268 * called from the c'tor 255 * called from the c'tor
269 */ 256 */
270void PIconView::initKeys() { 257void PIconView::initKeys() {
271 Opie::Core::OKeyPair::List lst; 258 Opie::Core::OKeyPair::List lst;
272 lst.append( Opie::Core::OKeyPair::upArrowKey() ); 259 lst.append( Opie::Core::OKeyPair::upArrowKey() );
273 lst.append( Opie::Core::OKeyPair::downArrowKey() ); 260 lst.append( Opie::Core::OKeyPair::downArrowKey() );
274 lst.append( Opie::Core::OKeyPair::leftArrowKey() ); 261 lst.append( Opie::Core::OKeyPair::leftArrowKey() );
275 lst.append( Opie::Core::OKeyPair::rightArrowKey() ); 262 lst.append( Opie::Core::OKeyPair::rightArrowKey() );
276 lst.append( Opie::Core::OKeyPair::returnKey() ); 263 lst.append( Opie::Core::OKeyPair::returnKey() );
277 264
278 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", 265 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config",
279 lst, false,this, "keyconfig name" ); 266 lst, false,this, "keyconfig name" );
280 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", 267 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam",
281 Resource::loadPixmap("beam"), BeamItem, 268 Resource::loadPixmap("beam"), BeamItem,
282 Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), 269 Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton),
283 this, SLOT(slotBeam())) ); 270 this, SLOT(slotBeam())) );
284 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", 271 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete",
285 Resource::loadPixmap("trash"), DeleteItem, 272 Resource::loadPixmap("trash"), DeleteItem,
286 Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), 273 Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton),
287 this, SLOT(slotTrash())) ); 274 this, SLOT(slotTrash())) );
288 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", 275 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view",
289 Resource::loadPixmap("1to1"), ViewItem, 276 Resource::loadPixmap("1to1"), ViewItem,
290 Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), 277 Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton),
291 this, SLOT(slotShowImage()))); 278 this, SLOT(slotShowImage())));
292 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", 279 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info",
293 Resource::loadPixmap("DocumentTypeWord"), InfoItem, 280 Resource::loadPixmap("DocumentTypeWord"), InfoItem,
294 Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), 281 Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ),
295 this, SLOT(slotImageInfo()) ) ); 282 this, SLOT(slotImageInfo()) ) );
296 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow", 283 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow",
297 Resource::loadPixmap("1to1"), SlideItem, 284 Resource::loadPixmap("1to1"), SlideItem,
298 Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton), 285 Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton),
299 this, SLOT(slotStartSlide()))); 286 this, SLOT(slotStartSlide())));
300 m_viewManager->load(); 287 m_viewManager->load();
301 m_viewManager->handleWidget( m_view ); 288 m_viewManager->handleWidget( m_view );
302} 289}
303 290
304 291
305/* 292/*
306 * change one dir up 293 * change one dir up
307 */ 294 */
308void PIconView::slotDirUp() 295void PIconView::slotDirUp()
309{ 296{
310 slotChangeDir( currentView()->dirLister()->dirUp( m_path ) ); 297 slotChangeDir( currentView()->dirLister()->dirUp( m_path ) );
311} 298}
312 299
313/* 300/*
314 * change the dir 301 * change the dir
315 */ 302 */
316void PIconView::slotChangeDir(const QString& path) { 303void PIconView::slotChangeDir(const QString& path) {
317 if ( !currentView() ) 304 if ( !currentView() )
318 return; 305 return;
319 306
320 PDirLister *lister = currentView()->dirLister(); 307 PDirLister *lister = currentView()->dirLister();
321 if (!lister ) 308 if (!lister )
322 return; 309 return;
323 310
324 /* 311 /*
325 * Say what we want and take what we get 312 * Say what we want and take what we get
326 */ 313 */
327 lister->setStartPath( path ); 314 lister->setStartPath( path );
328 m_path = lister->currentPath(); 315 m_path = lister->currentPath();
329 316
330 m_view->viewport()->setUpdatesEnabled( false ); 317 m_view->viewport()->setUpdatesEnabled( false );
331 m_view->clear(); 318 m_view->clear();
332 319
333 // Also invalidate the cache. We can't cancel the operations anyway 320 // Also invalidate the cache. We can't cancel the operations anyway
334 g_stringPix.clear(); 321 g_stringPix.clear();
335 g_stringInf.clear(); 322 g_stringInf.clear();
336 323
337 /* 324 /*
338 * add files and folders 325 * add files and folders
339 */ 326 */
340 addFolders( lister->folders() ); 327 addFolders( lister->folders() );
341 addFiles( lister->files() ); 328 addFiles( lister->files() );
342 m_view->viewport()->setUpdatesEnabled( true ); 329 m_view->viewport()->setUpdatesEnabled( true );
343 330
344 // looks ugly 331 // looks ugly
345 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); 332 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
346} 333}
347 334
348/** 335/**
349 * get the current file name 336 * get the current file name
350 * @param isDir see if this is a dir or real file 337 * @param isDir see if this is a dir or real file
351 */ 338 */
352QString PIconView::currentFileName(bool &isDir)const { 339QString PIconView::currentFileName(bool &isDir)const {
353 isDir = false; 340 isDir = false;
354 QIconViewItem* _it = m_view->currentItem(); 341 QIconViewItem* _it = m_view->currentItem();
355 if ( !_it ) 342 if ( !_it )
356 return QString::null; 343 return QString::null;
357 344
358 IconViewItem* it = static_cast<IconViewItem*>( _it ); 345 IconViewItem* it = static_cast<IconViewItem*>( _it );
359 isDir = it->isDir(); 346 isDir = it->isDir();
360 return it->path(); 347 return it->path();
361} 348}
362 349
363QString PIconView::nextFileName(bool &isDir)const 350QString PIconView::nextFileName(bool &isDir)const
364{ 351{
365 isDir = false; 352 isDir = false;
366 QIconViewItem* _it1 = m_view->currentItem(); 353 QIconViewItem* _it1 = m_view->currentItem();
367 if ( !_it1 ) 354 if ( !_it1 )
368 return QString::null; 355 return QString::null;
369 QIconViewItem* _it = _it1->nextItem(); 356 QIconViewItem* _it = _it1->nextItem();
370 if ( !_it ) 357 if ( !_it )
371 return QString::null; 358 return QString::null;
372 IconViewItem* it = static_cast<IconViewItem*>( _it ); 359 IconViewItem* it = static_cast<IconViewItem*>( _it );
373 isDir = it->isDir(); 360 isDir = it->isDir();
374 return it->path(); 361 return it->path();
375} 362}
376 363
377QString PIconView::prevFileName(bool &isDir)const{ 364QString PIconView::prevFileName(bool &isDir)const{
378 isDir = false; 365 isDir = false;
379 QIconViewItem* _it = m_view->currentItem(); 366 QIconViewItem* _it = m_view->currentItem();
380 if ( !_it ) 367 if ( !_it )
381 return QString::null; 368 return QString::null;
382 _it = _it->prevItem(); 369 _it = _it->prevItem();
383 if ( !_it ) 370 if ( !_it )
384 return QString::null; 371 return QString::null;
385 IconViewItem* it = static_cast<IconViewItem*>( _it ); 372 IconViewItem* it = static_cast<IconViewItem*>( _it );
386 isDir = it->isDir(); 373 isDir = it->isDir();
387 return it->path(); 374 return it->path();
388} 375}
389 376
390void PIconView::slotTrash() { 377void PIconView::slotTrash() {
391 bool isDir; 378 bool isDir;
392 QString pa = currentFileName( isDir ); 379 QString pa = currentFileName( isDir );
393 if ( isDir && pa.isEmpty() ) 380 if ( isDir && pa.isEmpty() )
394 return; 381 return;
395 382
396 if (!QPEMessageBox::confirmDelete( this, 383 if (!QPEMessageBox::confirmDelete( this,
397 tr("Delete Image" ), 384 tr("Delete Image" ),
398 tr("the Image %1" ).arg(pa))) 385 tr("the Image %1" ).arg(pa)))
399 return 386 return
400 387
401 388
402 currentView()->dirLister()->deleteImage( pa ); 389 currentView()->dirLister()->deleteImage( pa );
403 delete m_view->currentItem(); 390 delete m_view->currentItem();
404} 391}
405 392
406/* 393/*
407 * see what views are available 394 * see what views are available
408 */ 395 */
409void PIconView::loadViews() { 396void PIconView::loadViews() {
410 ViewMap::Iterator it; 397 ViewMap::Iterator it;
411 ViewMap* map = viewMap(); 398 ViewMap* map = viewMap();
412 for ( it = map->begin(); it != map->end(); ++it ) 399 for ( it = map->begin(); it != map->end(); ++it )
413 m_views->insertItem( it.key() ); 400 m_views->insertItem( it.key() );
414} 401}
415 402
416void PIconView::resetView() { 403void PIconView::resetView() {
417 m_internalReset = true; 404 m_internalReset = true;
418 // Also invalidate the cache. We can't cancel the operations anyway 405 // Also invalidate the cache. We can't cancel the operations anyway
419 g_stringPix.clear(); 406 g_stringPix.clear();
420 g_stringInf.clear(); 407 g_stringInf.clear();
421 if (m_mode>1) { 408 if (m_mode>1) {
422 int osize = m_iconsize; 409 int osize = m_iconsize;
423 m_iconsize = m_cfg->readNumEntry("iconsize", 32); 410 m_iconsize = m_cfg->readNumEntry("iconsize", 32);
424 if (m_iconsize<12)m_iconsize = 12; 411 if (m_iconsize<12)m_iconsize = 12;
425 if (m_iconsize>64)m_iconsize = 64; 412 if (m_iconsize>64)m_iconsize = 64;
426 if (osize != m_iconsize) { 413 if (osize != m_iconsize) {
427 if (_dirPix){ 414 if (_dirPix){
428 delete _dirPix; 415 delete _dirPix;
429 _dirPix = 0; 416 _dirPix = 0;
430 } 417 }
431 if (_cpyPix){ 418 if (_cpyPix){
432 delete _cpyPix; 419 delete _cpyPix;
433 _cpyPix = 0; 420 _cpyPix = 0;
434 } 421 }
435 calculateGrid(); 422 calculateGrid();
436 } 423 }
437 } else { 424 } else {
438 m_iconsize = 64; 425 m_iconsize = 64;
439 } 426 }
440 slotViewChanged(m_views->currentItem()); 427 slotViewChanged(m_views->currentItem());
441 m_internalReset = false; 428 m_internalReset = false;
442} 429}
443 430
431void PIconView::polish()
432{
433 odebug << "===\n"
434 << "PIconView::polish()\n"
435 << "====" << oendl;
436 QVBox::polish();
437
438 QString lastView = m_cfg->readEntry("LastView","");
439 int cc=0;
440 for (; cc<m_views->count();++cc) {
441 if (m_views->text(cc)==lastView) {
442 break;
443 }
444 }
445 if (cc<m_views->count()) {
446 m_views->setCurrentItem(cc);
447 slotViewChanged(cc);
448 } else {
449 slotViewChanged(m_views->currentItem());
450 }
451 connect( m_views, SIGNAL(activated(int)),
452 this, SLOT(slotViewChanged(int)) );
453}
454
444/* 455/*
445 *swicth view reloadDir and connect signals 456 *swicth view reloadDir and connect signals
446 */ 457 */
447void PIconView::slotViewChanged( int i) { 458void PIconView::slotViewChanged( int i) {
448 if (!m_views->count() ) { 459 if (!m_views->count() ) {
449 setCurrentView( 0l); 460 setCurrentView( 0l);
450 return; 461 return;
451 } 462 }
452 463
453 if (m_customWidget) { 464 if (m_customWidget) {
454 delete m_customWidget; 465 delete m_customWidget;
455 m_customWidget = 0; 466 m_customWidget = 0;
456 } 467 }
457 PDirView* cur = currentView(); 468 PDirView* cur = currentView();
458 if (cur) { 469 if (cur) {
459 delete cur; 470 delete cur;
460 } 471 }
461 QString str = m_views->text(i); 472 QString str = m_views->text(i);
462 ViewMap* map = viewMap(); 473 ViewMap* map = viewMap();
463 if (!map) { 474 if (!map) {
464 setCurrentView(0l); 475 setCurrentView(0l);
465 return; 476 return;
466 } 477 }
467 478
468 if (map->find(str) == map->end()) { 479 if (map->find(str) == map->end()) {
469 owarn << "Key not found" << oendl; 480 owarn << "Key not found" << oendl;
470 setCurrentView(0l); 481 setCurrentView(0l);
471 return; 482 return;
472 } 483 }
473 484
474 m_cfg->writeEntry("LastView",str); 485 m_cfg->writeEntry("LastView",str);
475 m_cfg->write(); 486 m_cfg->write();
476 cur = (*(*map)[str])(*m_cfg); 487 cur = (*(*map)[str])(*m_cfg);
477 setCurrentView( cur ); 488 setCurrentView( cur );
478 m_customWidget = cur->widget(m_hbox); 489 m_customWidget = cur->widget(m_hbox);
479 if (m_customWidget) { 490 if (m_customWidget) {
480 odebug << "Got a widget" << oendl; 491 odebug << "Got a widget" << oendl;
481 m_customWidget->show(); 492 m_customWidget->show();
482 } 493 }
483 494
484 /* connect to the signals of the lister */ 495 /* connect to the signals of the lister */
485 PDirLister* lis = cur->dirLister(); 496 PDirLister* lis = cur->dirLister();
486 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), 497 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )),
487 this, SLOT( slotThumbInfo(const QString&, const QString&))); 498 this, SLOT( slotThumbInfo(const QString&, const QString&)));
488 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), 499 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
489 this, SLOT(slotThumbNail(const QString&, const QPixmap&))); 500 this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
490 connect(lis, SIGNAL(sig_start()), 501 connect(lis, SIGNAL(sig_start()),
491 this, SLOT(slotStart())); 502 this, SLOT(slotStart()));
492 connect(lis, SIGNAL(sig_end()) , 503 connect(lis, SIGNAL(sig_end()) ,
493 this, SLOT(slotEnd()) ); 504 this, SLOT(slotEnd()) );
494 connect(lis,SIGNAL(sig_reloadDir()),this,SLOT(slotReloadDir())); 505 connect(lis,SIGNAL(sig_reloadDir()),this,SLOT(slotReloadDir()));
495 506
496 /* reload now with default Path 507 /* reload now with default Path
497 * but only if it isn't a reset like from setupdlg 508 * but only if it isn't a reset like from setupdlg
498 */ 509 */
499 if (!m_internalReset) { 510 if (!m_internalReset) {
500 m_path = lis->defaultPath(); 511 m_path = lis->defaultPath();
501 } 512 }
502 QTimer::singleShot( 0, this, SLOT(slotReloadDir())); 513 QTimer::singleShot( 0, this, SLOT(slotReloadDir()));
503} 514}
504 515
505 516
506void PIconView::slotReloadDir() { 517void PIconView::slotReloadDir() {
507 slotChangeDir( m_path ); 518 slotChangeDir( m_path );
508} 519}
509 520
510 521
511/* 522/*
512 * add files and folders 523 * add files and folders
513 */ 524 */
514void PIconView::addFolders( const QStringList& lst) { 525void PIconView::addFolders( const QStringList& lst) {
515 QStringList::ConstIterator it; 526 QStringList::ConstIterator it;
516 IconViewItem * _iv; 527 IconViewItem * _iv;
517 528
518 for(it=lst.begin(); it != lst.end(); ++it ) { 529 for(it=lst.begin(); it != lst.end(); ++it ) {
519 _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it),m_iconsize, true ); 530 _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it),m_iconsize, true );
520 if (m_mode==3) _iv->setTextOnly(true); 531 if (m_mode==3) _iv->setTextOnly(true);
521 } 532 }
522} 533}
523 534
524void PIconView::addFiles( const QStringList& lst) { 535void PIconView::addFiles( const QStringList& lst) {
525 QStringList::ConstIterator it; 536 QStringList::ConstIterator it;
526 IconViewItem * _iv; 537 IconViewItem * _iv;
527 QPixmap*m_pix = 0; 538 QPixmap*m_pix = 0;
528 QString pre = ""; 539 QString pre = "";
529 if (!m_path.isEmpty()) { 540 if (!m_path.isEmpty()) {
530 pre = m_path+"/"; 541 pre = m_path+"/";
531 } 542 }
543 QString s = "";
544 int pos;
532 for (it=lst.begin(); it!= lst.end(); ++it ) { 545 for (it=lst.begin(); it!= lst.end(); ++it ) {
533 m_pix = PPixmapCache::self()->cachedImage( pre+(*it), m_iconsize, m_iconsize ); 546 s = (*it);
534 _iv = new IconViewItem( m_view, pre+(*it), (*it),m_iconsize ); 547 pos = s.find(char(0));
548 m_pix = PPixmapCache::self()->cachedImage( pre+(*it), m_iconsize, m_iconsize );
549 if (pos>-1) {
550 _iv = new IconViewItem( m_view, s.mid(pos+1), s.left(pos),m_iconsize );
551 } else {
552 _iv = new IconViewItem( m_view, pre+(*it), (*it),m_iconsize );
553 }
535 if (m_mode==3) { 554 if (m_mode==3) {
536 _iv->setTextOnly(true); 555 _iv->setTextOnly(true);
537 _iv->setPixmap(QPixmap()); 556 _iv->setPixmap(QPixmap());
538
539
540
541 } else { 557 } else {
542 if (m_pix) _iv->setPixmap(*m_pix); 558 if (m_pix) _iv->setPixmap(*m_pix);
543 } 559 }
544 } 560 }
545 561
546} 562}
547 563
548/* 564/*
549 * user clicked on the item. Change dir or view 565 * user clicked on the item. Change dir or view
550 */ 566 */
551void PIconView::slotClicked(QIconViewItem* _it) { 567void PIconView::slotClicked(QIconViewItem* _it) {
552 if(!_it ) 568 if(!_it )
553 return; 569 return;
554 570
555 IconViewItem* it = static_cast<IconViewItem*>(_it); 571 IconViewItem* it = static_cast<IconViewItem*>(_it);
556 if( it->isDir() ) 572 if( it->isDir() )
557 slotChangeDir( it->path() ); 573 slotChangeDir( it->path() );
558 else // view image 574 else // view image
559 slotShowImage(); 575 slotShowImage();
560} 576}
561 577
562/* 578/*
563 * Return was pressed. which is triggered by the keydown 579 * Return was pressed. which is triggered by the keydown
564 * handler. The problem is that the key up will be handled 580 * handler. The problem is that the key up will be handled
565 * by the ImageDisplayer and goes to the next image 581 * by the ImageDisplayer and goes to the next image
566 */ 582 */
567void PIconView::slotRetrun( QIconViewItem *_it ) { 583void PIconView::slotRetrun( QIconViewItem *_it ) {
568 if(!_it ) 584 if(!_it )
569 return; 585 return;
570 586
571 IconViewItem* it = static_cast<IconViewItem*>(_it); 587 IconViewItem* it = static_cast<IconViewItem*>(_it);
572 if( it->isDir() ) 588 if( it->isDir() )
573 slotChangeDir( it->path() ); 589 slotChangeDir( it->path() );
574 else 590 else
575 QTimer::singleShot(0, this, SLOT(slotShowImage()) ); 591 QTimer::singleShot(0, this, SLOT(slotShowImage()) );
576} 592}
577 593
578/* 594/*
579 * got thumb info add to the cache if items is visible 595 * got thumb info add to the cache if items is visible
580 * we later need update after processing of slave is done 596 * we later need update after processing of slave is done
581 */ 597 */
582void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { 598void PIconView::slotThumbInfo( const QString& _path, const QString& str ) {
583 IconViewItem* item = g_stringInf[_path]; 599 IconViewItem* item = g_stringInf[_path];
584 if (!item ) 600 if (!item )
585 return; 601 return;
586 602
587 if (m_mode == 2) { 603 if (m_mode == 2) {
588 return; 604 return;
589 } 605 }
590 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), 606 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
591 m_view->contentsWidth(), m_view->contentsHeight() ) ) ) 607 m_view->contentsWidth(), m_view->contentsHeight() ) ) )
592 m_updatet = true; 608 m_updatet = true;
593 609
594 item->setText( str ); 610 item->setText( str );
595 g_stringInf.remove( _path ); 611 g_stringInf.remove( _path );
596} 612}
597 613
598/* 614/*
599 * got thumbnail and see if it is visible so we need to update later 615 * got thumbnail and see if it is visible so we need to update later
600 */ 616 */
601void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { 617void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) {
602 IconViewItem* item = g_stringPix[_path]; 618 IconViewItem* item = g_stringPix[_path];
603 if (!item ) 619 if (!item )
604 return; 620 return;
605 621
606 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), 622 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
607 m_view->contentsWidth(), m_view->contentsHeight() ) ) ) 623 m_view->contentsWidth(), m_view->contentsHeight() ) ) )
608 m_updatet = true; 624 m_updatet = true;
609 625
610 if (pix.width()>0) { 626 if (pix.width()>0) {
611 if (pix.width()<m_iconsize) { 627 if (pix.width()<m_iconsize) {
612 QPixmap p(m_iconsize,m_iconsize); 628 QPixmap p(m_iconsize,m_iconsize);
613 p.fill(); 629 p.fill();
614 QPainter pa(&p); 630 QPainter pa(&p);
615 int offset = (m_iconsize-pix.width())/2; 631 int offset = (m_iconsize-pix.width())/2;
616 int offy = (m_iconsize-pix.height())/2; 632 int offy = (m_iconsize-pix.height())/2;
617 if (offy<0) offy=0; 633 if (offy<0) offy=0;
618 pa.drawPixmap(offset,offy,pix); 634 pa.drawPixmap(offset,offy,pix);
619 pa.end(); 635 pa.end();
620 PPixmapCache::self()->insertImage( _path, p, m_iconsize, m_iconsize ); 636 PPixmapCache::self()->insertImage( _path, p, m_iconsize, m_iconsize );
621 item->setPixmap(p,true); 637 item->setPixmap(p,true);
622 } else { 638 } else {
623 PPixmapCache::self()->insertImage( _path, pix, m_iconsize, m_iconsize ); 639 PPixmapCache::self()->insertImage( _path, pix, m_iconsize, m_iconsize );
624 item->setPixmap(pix,true); 640 item->setPixmap(pix,true);
625 } 641 }
626 642
627 } else { 643 } else {
628 PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), m_iconsize, m_iconsize ); 644 PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), m_iconsize, m_iconsize );
629 } 645 }
630 g_stringPix.remove( _path ); 646 g_stringPix.remove( _path );
631 m_view->arrangeItemsInGrid(true); 647 m_view->arrangeItemsInGrid(true);
632} 648}
633 649
634 650
635/* 651/*
636 * FIXME rename 652 * FIXME rename
637 */ 653 */
638void PIconView::slotRename() { 654void PIconView::slotRename() {
639 655
640} 656}
641 657
642 658
643/* 659/*
644 * BEAM the current file 660 * BEAM the current file
645 */ 661 */
646void PIconView::slotBeam() { 662void PIconView::slotBeam() {
647 bool isDir; 663 bool isDir;
648 QString pa = currentFileName( isDir ); 664 QString pa = currentFileName( isDir );
649 if ( isDir && pa.isEmpty() ) 665 if ( isDir && pa.isEmpty() )
650 return; 666 return;
651 667
652 Ir* ir = new Ir( this ); 668 Ir* ir = new Ir( this );
653 connect( ir, SIGNAL(done(Ir*)), 669 connect( ir, SIGNAL(done(Ir*)),
654 this, SLOT(slotBeamDone(Ir*))); 670 this, SLOT(slotBeamDone(Ir*)));
655 ir->send(pa, tr( "Image" ) ); 671 ir->send(pa, tr( "Image" ) );
656} 672}
657 673
658/* 674/*
659 * BEAM done clean up 675 * BEAM done clean up
660 */ 676 */
661void PIconView::slotBeamDone( Ir* ir) { 677void PIconView::slotBeamDone( Ir* ir) {
662 delete ir; 678 delete ir;
663} 679}
664 680
665void PIconView::slotStart() { 681void PIconView::slotStart() {
666 m_view->viewport()->setUpdatesEnabled( false ); 682 m_view->viewport()->setUpdatesEnabled( false );
667} 683}
668 684
669void PIconView::slotEnd() { 685void PIconView::slotEnd() {
670 if ( m_updatet ) 686 if ( m_updatet )
671 m_view->arrangeItemsInGrid( ); 687 m_view->arrangeItemsInGrid( );
672 m_view->viewport()->setUpdatesEnabled( true ); 688 m_view->viewport()->setUpdatesEnabled( true );
673 m_updatet = false; 689 m_updatet = false;
674} 690}
675 691
676void PIconView::slotShowLast() 692void PIconView::slotShowLast()
677{ 693{
678 QIconViewItem* last_it = m_view->lastItem(); 694 QIconViewItem* last_it = m_view->lastItem();
679 if (!last_it) return; 695 if (!last_it) return;
680 m_view->setCurrentItem(last_it); 696 m_view->setCurrentItem(last_it);
681 IconViewItem* it = static_cast<IconViewItem*>( last_it ); 697 IconViewItem* it = static_cast<IconViewItem*>( last_it );
682 bool isDir = it->isDir(); 698 bool isDir = it->isDir();
683 QString name = it->path(); 699 QString name = it->path();
684 if (!isDir && !name.isEmpty()) { 700 if (!isDir && !name.isEmpty()) {
685 slotShowImage(name); 701 slotShowImage(name);
686 return; 702 return;
687 } 703 }
688 bool first_loop = true; 704 bool first_loop = true;
689 while(isDir==true) { 705 while(isDir==true) {
690 if (!first_loop) { 706 if (!first_loop) {
691 m_view->setCurrentItem(m_view->currentItem()->prevItem()); 707 m_view->setCurrentItem(m_view->currentItem()->prevItem());
692 } else { 708 } else {
693 first_loop = false; 709 first_loop = false;
694 } 710 }
695 name = prevFileName(isDir); 711 name = prevFileName(isDir);
696 } 712 }
697 713
698 if (name.isEmpty()) return; 714 if (name.isEmpty()) return;
699 /* if we got a name we have a prev item */ 715 /* if we got a name we have a prev item */
700 m_view->setCurrentItem(m_view->currentItem()->prevItem()); 716 m_view->setCurrentItem(m_view->currentItem()->prevItem());
701 slotShowImage(name); 717 slotShowImage(name);
702} 718}
703 719
704bool PIconView::slotShowFirst() 720bool PIconView::slotShowFirst()
705{ 721{
706 /* stop when reached - otherwise we may get an endless loop */ 722 /* stop when reached - otherwise we may get an endless loop */
707 QIconViewItem* first_it = m_view->firstItem(); 723 QIconViewItem* first_it = m_view->firstItem();
708 if (!first_it) return false; 724 if (!first_it) return false;
709 m_view->setCurrentItem(first_it); 725 m_view->setCurrentItem(first_it);
710 IconViewItem* it = static_cast<IconViewItem*>( first_it ); 726 IconViewItem* it = static_cast<IconViewItem*>( first_it );
711 bool isDir = it->isDir(); 727 bool isDir = it->isDir();
712 QString name = it->path(); 728 QString name = it->path();
713 if (!isDir && !name.isEmpty()) { 729 if (!isDir && !name.isEmpty()) {
714 slotShowImage(name); 730 slotShowImage(name);
715 return false; 731 return false;
716 } 732 }
717 bool first_loop = true; 733 bool first_loop = true;
718 while(isDir==true) { 734 while(isDir==true) {
719 /* if name is empty isDir is false, too. */ 735 /* if name is empty isDir is false, too. */
720 if (!first_loop) { 736 if (!first_loop) {
721 m_view->setCurrentItem(m_view->currentItem()->nextItem()); 737 m_view->setCurrentItem(m_view->currentItem()->nextItem());
722 } else { 738 } else {
723 first_loop = false; 739 first_loop = false;
724 } 740 }
725 name = nextFileName(isDir); 741 name = nextFileName(isDir);
726 } 742 }
727 if (name.isEmpty()) return false; 743 if (name.isEmpty()) return false;
728 /* if we got a name we have a next item */ 744 /* if we got a name we have a next item */
729 m_view->setCurrentItem(m_view->currentItem()->nextItem()); 745 m_view->setCurrentItem(m_view->currentItem()->nextItem());
730 slotShowImage(name); 746 slotShowImage(name);
731 return true; 747 return true;
732} 748}
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h
index 78dda58..6e08fd8 100644
--- a/noncore/graphics/opie-eye/gui/iconview.h
+++ b/noncore/graphics/opie-eye/gui/iconview.h
@@ -1,104 +1,108 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 * No WArranty... 3 * No WArranty...
4 */ 4 */
5 5
6#ifndef PHUNK_ICON_VIEW_H 6#ifndef PHUNK_ICON_VIEW_H
7#define PHUNK_ICON_VIEW_H 7#define PHUNK_ICON_VIEW_H
8 8
9#include <qvbox.h> 9#include <qvbox.h>
10 10
11 11
12class QIconView; 12class QIconView;
13class QIconViewItem; 13class QIconViewItem;
14class QComboBox; 14class QComboBox;
15class PIconViewItem; 15class PIconViewItem;
16class PDirLister; 16class PDirLister;
17class Ir; 17class Ir;
18 18
19namespace Opie { 19namespace Opie {
20namespace Core{ 20namespace Core{
21 class OConfig; 21 class OConfig;
22 class OKeyConfigManager; 22 class OKeyConfigManager;
23} 23}
24} 24}
25 25
26class PIconView : public QVBox { 26class PIconView : public QVBox {
27 Q_OBJECT 27 Q_OBJECT
28 friend class PIconViewItem; 28 friend class PIconViewItem;
29 enum ActionIds { 29 enum ActionIds {
30 BeamItem, DeleteItem, ViewItem, InfoItem,SlideItem 30 BeamItem, DeleteItem, ViewItem, InfoItem,SlideItem
31 }; 31 };
32public: 32public:
33 PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); 33 PIconView( QWidget* wid, Opie::Core::OConfig *cfg );
34 ~PIconView(); 34 ~PIconView();
35 void resetView(); 35 void resetView();
36 Opie::Core::OKeyConfigManager* manager(); 36 Opie::Core::OKeyConfigManager* manager();
37 37
38 void setDoccalled(bool);
39
38signals: 40signals:
39 void sig_showInfo( const QString& ); 41 void sig_showInfo( const QString& );
40 void sig_display(const QString&); 42 void sig_display(const QString&);
41 void sig_startslide(int timeout); 43 void sig_startslide(int timeout);
42 44
43public slots: 45public slots:
44 virtual void slotShowNext(); 46 virtual void slotShowNext();
45 virtual void slotShowPrev(); 47 virtual void slotShowPrev();
46 virtual void slotShowLast(); 48 virtual void slotShowLast();
47 virtual bool slotShowFirst(); 49 virtual bool slotShowFirst();
50 virtual void polish();
48 51
49protected: 52protected:
50 void resizeEvent( QResizeEvent* ); 53 void resizeEvent( QResizeEvent* );
51 54
52private: 55private:
53 void initKeys(); 56 void initKeys();
54 QString currentFileName(bool &isDir)const; 57 QString currentFileName(bool &isDir)const;
55 QString nextFileName(bool &isDir)const; 58 QString nextFileName(bool &isDir)const;
56 QString prevFileName(bool &isDir)const; 59 QString prevFileName(bool &isDir)const;
57 void loadViews(); 60 void loadViews();
58 void calculateGrid(QResizeEvent*e = 0); 61 void calculateGrid(QResizeEvent*e = 0);
62 bool m_setDocCalled:1;
59 63
60private slots: 64private slots:
61 void slotDirUp(); 65 void slotDirUp();
62 void slotChangeDir(const QString&); 66 void slotChangeDir(const QString&);
63 void slotTrash(); 67 void slotTrash();
64 void slotViewChanged( int ); 68 void slotViewChanged( int );
65 void slotReloadDir(); 69 void slotReloadDir();
66 void slotRename(); 70 void slotRename();
67 void slotBeam(); 71 void slotBeam();
68 void slotBeamDone( Ir* ); 72 void slotBeamDone( Ir* );
69 73
70 void slotShowImage(); 74 void slotShowImage();
71 void slotShowImage( const QString& ); 75 void slotShowImage( const QString& );
72 void slotImageInfo(); 76 void slotImageInfo();
73 void slotImageInfo( const QString& ); 77 void slotImageInfo( const QString& );
74 void slotStartSlide(); 78 void slotStartSlide();
75 79
76 void slotStart(); 80 void slotStart();
77 void slotEnd(); 81 void slotEnd();
78 82
79/* for performance reasons make it inline in the future */ 83/* for performance reasons make it inline in the future */
80 void addFolders( const QStringList& ); 84 void addFolders( const QStringList& );
81 void addFiles( const QStringList& ); 85 void addFiles( const QStringList& );
82 void slotClicked(QIconViewItem* ); 86 void slotClicked(QIconViewItem* );
83 void slotRetrun(QIconViewItem* ); 87 void slotRetrun(QIconViewItem* );
84 88
85/**/ 89/**/
86 void slotThumbInfo(const QString&, const QString&); 90 void slotThumbInfo(const QString&, const QString&);
87 void slotThumbNail(const QString&, const QPixmap&); 91 void slotThumbNail(const QString&, const QPixmap&);
88 92
89 void slotChangeMode( int ); 93 void slotChangeMode( int );
90private: 94private:
91 Opie::Core::OKeyConfigManager *m_viewManager; 95 Opie::Core::OKeyConfigManager *m_viewManager;
92 Opie::Core::OConfig *m_cfg; 96 Opie::Core::OConfig *m_cfg;
93 QComboBox* m_views; 97 QComboBox* m_views;
94 QIconView* m_view; 98 QIconView* m_view;
95 QString m_path; 99 QString m_path;
96 bool m_updatet : 1; 100 bool m_updatet : 1;
97 int m_mode; 101 int m_mode;
98 bool m_internalReset:1; 102 bool m_internalReset:1;
99 int m_iconsize; 103 int m_iconsize;
100 QHBox*m_hbox; 104 QHBox*m_hbox;
101 QWidget*m_customWidget; 105 QWidget*m_customWidget;
102}; 106};
103 107
104#endif 108#endif
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp
index ebdfc60..ac6474c 100644
--- a/noncore/graphics/opie-eye/gui/imageview.cpp
+++ b/noncore/graphics/opie-eye/gui/imageview.cpp
@@ -1,242 +1,255 @@
1#include "imageview.h" 1#include "imageview.h"
2 2
3#include <opie2/odebug.h> 3#include <opie2/odebug.h>
4#include <opie2/oconfig.h> 4#include <opie2/oconfig.h>
5#include <opie2/okeyconfigwidget.h> 5#include <opie2/okeyconfigwidget.h>
6 6
7#include <qpe/resource.h> 7#include <qpe/resource.h>
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9#include <qpopupmenu.h> 9#include <qpopupmenu.h>
10#include <qtimer.h> 10#include <qtimer.h>
11#include <qaction.h> 11#include <qaction.h>
12 12
13using namespace Opie::Core; 13using namespace Opie::Core;
14 14
15ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) 15ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl )
16 : Opie::MM::OImageScrollView(parent,name,fl) 16 : Opie::MM::OImageScrollView(parent,name,fl)
17{ 17{
18 m_viewManager = 0; 18 m_viewManager = 0;
19 focus_in_count = 0; 19 focus_in_count = 0;
20 m_cfg = cfg; 20 m_cfg = cfg;
21 m_isFullScreen = false; 21 m_isFullScreen = false;
22 m_ignore_next_in = false; 22 m_ignore_next_in = false;
23 m_slideTimer = 0; 23 m_slideTimer = 0;
24 QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold); 24 QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold);
25 initKeys(); 25 initKeys();
26 m_slideValue = 5; 26 m_slideValue = 5;
27 m_gDisplayType = 0; 27 m_gDisplayType = 0;
28 m_gPrevNext = 0; 28 m_gPrevNext = 0;
29 m_hGroup = 0; 29 m_hGroup = 0;
30 closeIfHide = false;
30} 31}
31 32
32void ImageView::setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup) 33void ImageView::setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup)
33{ 34{
34 m_gDisplayType = disptypeGroup; 35 m_gDisplayType = disptypeGroup;
35 m_gPrevNext = nextprevGroup; 36 m_gPrevNext = nextprevGroup;
36 m_hGroup = hGroup; 37 m_hGroup = hGroup;
37} 38}
38 39
39ImageView::~ImageView() 40ImageView::~ImageView()
40{ 41{
41 odebug << "Destructor imageview" << oendl; 42 odebug << "Destructor imageview" << oendl;
42 delete m_viewManager; 43 delete m_viewManager;
43} 44}
44 45
45Opie::Core::OKeyConfigManager* ImageView::manager() 46Opie::Core::OKeyConfigManager* ImageView::manager()
46{ 47{
47 if (!m_viewManager) { 48 if (!m_viewManager) {
48 initKeys(); 49 initKeys();
49 } 50 }
50 return m_viewManager; 51 return m_viewManager;
51} 52}
52 53
53void ImageView::startSlide(int value) 54void ImageView::startSlide(int value)
54{ 55{
55 if (!m_slideTimer) { 56 if (!m_slideTimer) {
56 m_slideTimer = new QTimer(this); 57 m_slideTimer = new QTimer(this);
57 } 58 }
58 m_slideValue=value; 59 m_slideValue=value;
59 connect(m_slideTimer,SIGNAL(timeout()),SLOT(nextSlide())); 60 connect(m_slideTimer,SIGNAL(timeout()),SLOT(nextSlide()));
60 /* this "+1" is one millisecond. with that we can setup a slideshowvalue 61 /* this "+1" is one millisecond. with that we can setup a slideshowvalue
61 of 0. eg "as fast as possible". 62 of 0. eg "as fast as possible".
62 */ 63 */
63 m_slideTimer->start(m_slideValue*1000+1,true); 64 m_slideTimer->start(m_slideValue*1000+1,true);
64} 65}
65 66
66void ImageView::stopSlide() 67void ImageView::stopSlide()
67{ 68{
68 if (!m_slideTimer) { 69 if (!m_slideTimer) {
69 return; 70 return;
70 } 71 }
71 m_slideTimer->stop(); 72 m_slideTimer->stop();
72 delete m_slideTimer; 73 delete m_slideTimer;
73 m_slideTimer = 0; 74 m_slideTimer = 0;
74} 75}
75 76
76void ImageView::nextSlide() 77void ImageView::nextSlide()
77{ 78{
78 if (!m_slideTimer) { 79 if (!m_slideTimer) {
79 return; 80 return;
80 } 81 }
81#if 0 82#if 0
82 if (isHidden()) { 83 if (isHidden()) {
83 delete m_slideTimer; 84 delete m_slideTimer;
84 m_slideTimer = 0; 85 m_slideTimer = 0;
85 return; 86 return;
86 } 87 }
87#endif 88#endif
88 emit dispNext(); 89 emit dispNext();
89 m_slideTimer->start(m_slideValue*1000,true); 90 m_slideTimer->start(m_slideValue*1000,true);
90} 91}
91void ImageView::initKeys() 92void ImageView::initKeys()
92{ 93{
93 odebug << "init imageview keys" << oendl; 94 odebug << "init imageview keys" << oendl;
94 if (!m_cfg) { 95 if (!m_cfg) {
95 m_cfg = new Opie::Core::OConfig("opie-eye"); 96 m_cfg = new Opie::Core::OConfig("opie-eye");
96 m_cfg->setGroup("image_view_keys" ); 97 m_cfg->setGroup("image_view_keys" );
97 } 98 }
98 Opie::Core::OKeyPair::List lst; 99 Opie::Core::OKeyPair::List lst;
99 lst.append( Opie::Core::OKeyPair::upArrowKey() ); 100 lst.append( Opie::Core::OKeyPair::upArrowKey() );
100 lst.append( Opie::Core::OKeyPair::downArrowKey() ); 101 lst.append( Opie::Core::OKeyPair::downArrowKey() );
101 lst.append( Opie::Core::OKeyPair::leftArrowKey() ); 102 lst.append( Opie::Core::OKeyPair::leftArrowKey() );
102 lst.append( Opie::Core::OKeyPair::rightArrowKey() ); 103 lst.append( Opie::Core::OKeyPair::rightArrowKey() );
103 lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); 104 lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0));
104 105
105 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", 106 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys",
106 lst, false,this, "image_view_keys" ); 107 lst, false,this, "image_view_keys" );
107 108
108 /** 109 /**
109 * Handle KeyEvents when they're pressed. This avoids problems 110 * Handle KeyEvents when they're pressed. This avoids problems
110 * with 'double next' on Return. 111 * with 'double next' on Return.
111 * The Return press would switch to this view and the return 112 * The Return press would switch to this view and the return
112 * release would emit the dispNext Signal. 113 * release would emit the dispNext Signal.
113 */ 114 */
114 m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed ); 115 m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed );
115 116
116 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", 117 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo",
117 Resource::loadPixmap("1to1"), ViewInfo, 118 Resource::loadPixmap("1to1"), ViewInfo,
118 Opie::Core::OKeyPair(Qt::Key_I,0), 119 Opie::Core::OKeyPair(Qt::Key_I,0),
119 this, SLOT(slotShowImageInfo()))); 120 this, SLOT(slotShowImageInfo())));
120 121
121 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", 122 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate",
122 Resource::loadPixmap("rotate"), Autorotate, 123 Resource::loadPixmap("rotate"), Autorotate,
123 Opie::Core::OKeyPair(Qt::Key_R,0), 124 Opie::Core::OKeyPair(Qt::Key_R,0),
124 this, SIGNAL(toggleAutorotate()))); 125 this, SIGNAL(toggleAutorotate())));
125 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", 126 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale",
126 Resource::loadPixmap("1to1"), Autoscale, 127 Resource::loadPixmap("1to1"), Autoscale,
127 Opie::Core::OKeyPair(Qt::Key_S,0), 128 Opie::Core::OKeyPair(Qt::Key_S,0),
128 this, SIGNAL(toggleAutoscale()))); 129 this, SIGNAL(toggleAutoscale())));
129 130
130 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", 131 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext",
131 Resource::loadPixmap("forward"), ShowNext, 132 Resource::loadPixmap("forward"), ShowNext,
132 Opie::Core::OKeyPair(Qt::Key_Return,0), 133 Opie::Core::OKeyPair(Qt::Key_Return,0),
133 this, SIGNAL(dispNext()))); 134 this, SIGNAL(dispNext())));
134 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", 135 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev",
135 Resource::loadPixmap("back"), ShowPrevious, 136 Resource::loadPixmap("back"), ShowPrevious,
136 Opie::Core::OKeyPair(Qt::Key_P,0), 137 Opie::Core::OKeyPair(Qt::Key_P,0),
137 this, SIGNAL(dispPrev()))); 138 this, SIGNAL(dispPrev())));
138 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", 139 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen",
139 Resource::loadPixmap("fullscreen"), FullScreen, 140 Resource::loadPixmap("fullscreen"), FullScreen,
140 Opie::Core::OKeyPair(Qt::Key_F,0), 141 Opie::Core::OKeyPair(Qt::Key_F,0),
141 this, SIGNAL(toggleFullScreen()))); 142 this, SIGNAL(toggleFullScreen())));
142 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", 143 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer",
143 Resource::loadPixmap("mag"), Zoomer, 144 Resource::loadPixmap("mag"), Zoomer,
144 Opie::Core::OKeyPair(Qt::Key_T,0), 145 Opie::Core::OKeyPair(Qt::Key_T,0),
145 this, SIGNAL(toggleZoomer()))); 146 this, SIGNAL(toggleZoomer())));
146 m_viewManager->handleWidget( this ); 147 m_viewManager->handleWidget( this );
147 m_viewManager->load(); 148 m_viewManager->load();
148} 149}
149 150
150void ImageView::keyReleaseEvent(QKeyEvent * e) 151void ImageView::keyReleaseEvent(QKeyEvent * e)
151{ 152{
152 if (!e || e->state()!=0) { 153 if (!e || e->state()!=0) {
153 return; 154 return;
154 } 155 }
155 if (e->key()==Qt::Key_Escape && fullScreen()) emit hideMe(); 156 if (e->key()==Qt::Key_Escape) {
157 if (fullScreen()) {
158 emit hideMe();
159 }
160 if (closeIfHide) {
161 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()));
162 }
163 }
164}
165
166void ImageView::setCloseIfHide(bool how)
167{
168 closeIfHide = how;
156} 169}
157 170
158void ImageView::slotShowImageInfo() 171void ImageView::slotShowImageInfo()
159{ 172{
160 emit dispImageInfo(m_lastName); 173 emit dispImageInfo(m_lastName);
161} 174}
162 175
163void ImageView::contentsMousePressEvent ( QMouseEvent * e) 176void ImageView::contentsMousePressEvent ( QMouseEvent * e)
164{ 177{
165 if (e->button()==1) { 178 if (e->button()==1) {
166 return OImageScrollView::contentsMousePressEvent(e); 179 return OImageScrollView::contentsMousePressEvent(e);
167 } 180 }
168 odebug << "Popup " << oendl; 181 odebug << "Popup " << oendl;
169 QPopupMenu *m = new QPopupMenu(0); 182 QPopupMenu *m = new QPopupMenu(0);
170 if (!m) return; 183 if (!m) return;
171 if (m_hGroup) { 184 if (m_hGroup) {
172 m_hGroup->addTo(m); 185 m_hGroup->addTo(m);
173 } 186 }
174 if (fullScreen()) { 187 if (fullScreen()) {
175 if (m_gPrevNext) { 188 if (m_gPrevNext) {
176 m->insertSeparator(); 189 m->insertSeparator();
177 m_gPrevNext->addTo(m); 190 m_gPrevNext->addTo(m);
178 } 191 }
179 if (m_gDisplayType) { 192 if (m_gDisplayType) {
180 m->insertSeparator(); 193 m->insertSeparator();
181 m_gDisplayType->addTo(m); 194 m_gDisplayType->addTo(m);
182 } 195 }
183 } 196 }
184 m->setFocus(); 197 m->setFocus();
185 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 198 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
186 if (m_hGroup) { 199 if (m_hGroup) {
187 m_hGroup->removeFrom(m); 200 m_hGroup->removeFrom(m);
188 } 201 }
189 if (m_gPrevNext) { 202 if (m_gPrevNext) {
190 m_gPrevNext->removeFrom(m); 203 m_gPrevNext->removeFrom(m);
191 } 204 }
192 if (m_gDisplayType) { 205 if (m_gDisplayType) {
193 m_gDisplayType->removeFrom(m); 206 m_gDisplayType->removeFrom(m);
194 } 207 }
195 delete m; 208 delete m;
196} 209}
197 210
198void ImageView::setFullScreen(bool how,bool force) 211void ImageView::setFullScreen(bool how,bool force)
199{ 212{
200 m_isFullScreen = how; 213 m_isFullScreen = how;
201 if (how) { 214 if (how) {
202 m_ignore_next_in = true; 215 m_ignore_next_in = true;
203 setFixedSize(qApp->desktop()->size()); 216 setFixedSize(qApp->desktop()->size());
204 if (force) showFullScreen(); 217 if (force) showFullScreen();
205 } else { 218 } else {
206 setMinimumSize(10,10); 219 setMinimumSize(10,10);
207 } 220 }
208} 221}
209 222
210void ImageView::focusInEvent(QFocusEvent *) 223void ImageView::focusInEvent(QFocusEvent *)
211{ 224{
212 // Always do it here, no matter the size. 225 // Always do it here, no matter the size.
213 odebug << "Focus in (view)" << oendl; 226 odebug << "Focus in (view)" << oendl;
214 //if (fullScreen()) parentWidget()->showNormal(); 227 //if (fullScreen()) parentWidget()->showNormal();
215 if (m_ignore_next_in){m_ignore_next_in=false;return;} 228 if (m_ignore_next_in){m_ignore_next_in=false;return;}
216 if (fullScreen()) enableFullscreen(); 229 if (fullScreen()) enableFullscreen();
217} 230}
218 231
219void ImageView::hide() 232void ImageView::hide()
220{ 233{
221 if (fullScreen()) { 234 if (fullScreen()) {
222 m_ignore_next_in = true; 235 m_ignore_next_in = true;
223 showNormal(); 236 showNormal();
224 } 237 }
225 QWidget::hide(); 238 QWidget::hide();
226} 239}
227void ImageView::enableFullscreen() 240void ImageView::enableFullscreen()
228{ 241{
229 if (!fullScreen()) return; 242 if (!fullScreen()) return;
230 if (m_ignore_next_in) {m_ignore_next_in = false;return;} 243 if (m_ignore_next_in) {m_ignore_next_in = false;return;}
231 244
232 setUpdatesEnabled(false); 245 setUpdatesEnabled(false);
233 // This is needed because showNormal() forcefully changes the window 246 // This is needed because showNormal() forcefully changes the window
234 // style to WSTyle_TopLevel. 247 // style to WSTyle_TopLevel.
235 reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); 248 reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0));
236 // Enable fullscreen. 249 // Enable fullscreen.
237 /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus 250 /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus
238 * so we must block it here! */ 251 * so we must block it here! */
239 m_ignore_next_in = true; 252 m_ignore_next_in = true;
240 showFullScreen(); 253 showFullScreen();
241 setUpdatesEnabled(true); 254 setUpdatesEnabled(true);
242} 255}
diff --git a/noncore/graphics/opie-eye/gui/imageview.h b/noncore/graphics/opie-eye/gui/imageview.h
index 2408211..f1067bb 100644
--- a/noncore/graphics/opie-eye/gui/imageview.h
+++ b/noncore/graphics/opie-eye/gui/imageview.h
@@ -1,76 +1,78 @@
1#ifndef _IMAGE_VIEW_H 1#ifndef _IMAGE_VIEW_H
2#define _IMAGE_VIEW_H 2#define _IMAGE_VIEW_H
3 3
4#include <opie2/oimagescrollview.h> 4#include <opie2/oimagescrollview.h>
5 5
6#include <qwidget.h> 6#include <qwidget.h>
7 7
8class QTimer; 8class QTimer;
9class QActionGroup; 9class QActionGroup;
10class QAction; 10class QAction;
11 11
12namespace Opie { 12namespace Opie {
13 namespace Core { 13 namespace Core {
14 class OConfig; 14 class OConfig;
15 class OKeyConfigManager; 15 class OKeyConfigManager;
16 } 16 }
17} 17}
18 18
19class ImageView:public Opie::MM::OImageScrollView 19class ImageView:public Opie::MM::OImageScrollView
20{ 20{
21 Q_OBJECT 21 Q_OBJECT
22 22
23 enum ActionIds { 23 enum ActionIds {
24 ViewInfo, 24 ViewInfo,
25 FullScreen, 25 FullScreen,
26 ShowNext, 26 ShowNext,
27 ShowPrevious, 27 ShowPrevious,
28 Zoomer, 28 Zoomer,
29 Autorotate, 29 Autorotate,
30 Autoscale 30 Autoscale
31 }; 31 };
32 32
33public: 33public:
34 ImageView(Opie::Core::OConfig *cfg,QWidget* parent,const char* name = 0, WFlags fl = 0 ); 34 ImageView(Opie::Core::OConfig *cfg,QWidget* parent,const char* name = 0, WFlags fl = 0 );
35 virtual ~ImageView(); 35 virtual ~ImageView();
36 Opie::Core::OKeyConfigManager* manager(); 36 Opie::Core::OKeyConfigManager* manager();
37 void setFullScreen(bool how,bool force=true); 37 void setFullScreen(bool how,bool force=true);
38 bool fullScreen(){return m_isFullScreen;} 38 bool fullScreen(){return m_isFullScreen;}
39 virtual void enableFullscreen(); 39 virtual void enableFullscreen();
40 void stopSlide(); 40 void stopSlide();
41 void setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup); 41 void setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup);
42 void setCloseIfHide(bool);
42 43
43signals: 44signals:
44 void dispImageInfo(const QString&); 45 void dispImageInfo(const QString&);
45 void dispNext(); 46 void dispNext();
46 void dispPrev(); 47 void dispPrev();
47 void toggleFullScreen(); 48 void toggleFullScreen();
48 void hideMe(); 49 void hideMe();
49 void toggleZoomer(); 50 void toggleZoomer();
50 void toggleAutoscale(); 51 void toggleAutoscale();
51 void toggleAutorotate(); 52 void toggleAutorotate();
52 53
53protected: 54protected:
54 Opie::Core::OConfig * m_cfg; 55 Opie::Core::OConfig * m_cfg;
55 Opie::Core::OKeyConfigManager*m_viewManager; 56 Opie::Core::OKeyConfigManager*m_viewManager;
56 void initKeys(); 57 void initKeys();
57 bool m_isFullScreen:1; 58 bool m_isFullScreen:1;
58 bool m_ignore_next_in:1; 59 bool m_ignore_next_in:1;
59 int focus_in_count; 60 int focus_in_count;
60 QTimer*m_slideTimer; 61 QTimer*m_slideTimer;
61 int m_slideValue; 62 int m_slideValue;
62 virtual void focusInEvent ( QFocusEvent * ); 63 virtual void focusInEvent ( QFocusEvent * );
63 QActionGroup *m_gDisplayType,*m_gPrevNext,*m_hGroup; 64 QActionGroup *m_gDisplayType,*m_gPrevNext,*m_hGroup;
65 bool closeIfHide:1;
64 66
65public slots: 67public slots:
66 virtual void hide(); 68 virtual void hide();
67 virtual void startSlide(int); 69 virtual void startSlide(int);
68 virtual void nextSlide(); 70 virtual void nextSlide();
69 71
70protected slots: 72protected slots:
71 virtual void slotShowImageInfo(); 73 virtual void slotShowImageInfo();
72 virtual void keyReleaseEvent(QKeyEvent * e); 74 virtual void keyReleaseEvent(QKeyEvent * e);
73 virtual void contentsMousePressEvent ( QMouseEvent * e); 75 virtual void contentsMousePressEvent ( QMouseEvent * e);
74}; 76};
75 77
76#endif 78#endif
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index f443ccb..295f93f 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -1,710 +1,733 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 * No WArranty... 3 * No WArranty...
4 */ 4 */
5#include "mainwindow.h" 5#include "mainwindow.h"
6#include "imageview.h" 6#include "imageview.h"
7 7
8#include "iconview.h" 8#include "iconview.h"
9#include "filesystem.h" 9#include "filesystem.h"
10#include "imageinfoui.h" 10#include "imageinfoui.h"
11#include "viewmodebutton.h" 11#include "viewmodebutton.h"
12#include "basesetup.h" 12#include "basesetup.h"
13 13
14#include <iface/ifaceinfo.h> 14#include <iface/ifaceinfo.h>
15#include <iface/dirview.h> 15#include <iface/dirview.h>
16 16
17#include <opie2/odebug.h> 17#include <opie2/odebug.h>
18#include <opie2/owidgetstack.h> 18#include <opie2/owidgetstack.h>
19#include <opie2/oapplicationfactory.h> 19#include <opie2/oapplicationfactory.h>
20#include <opie2/otabwidget.h> 20#include <opie2/otabwidget.h>
21#include <opie2/okeyconfigwidget.h> 21#include <opie2/okeyconfigwidget.h>
22 22
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qpe/ir.h> 25#include <qpe/ir.h>
26#include <qpe/storage.h> 26#include <qpe/storage.h>
27#include <qpe/applnk.h> 27#include <qpe/applnk.h>
28 28
29#include <qtoolbar.h> 29#include <qtoolbar.h>
30#include <qtoolbutton.h> 30#include <qtoolbutton.h>
31#include <qlayout.h> 31#include <qlayout.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qmap.h> 33#include <qmap.h>
34#include <qtimer.h> 34#include <qtimer.h>
35#include <qframe.h> 35#include <qframe.h>
36#include <qmenubar.h> 36#include <qmenubar.h>
37#include <qaction.h> 37#include <qaction.h>
38 38
39//OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) 39//OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" )
40OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) 40OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>)
41 41
42PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) 42PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
43 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) 43 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 )
44{ 44{
45 setCaption( QObject::tr("Opie Eye Caramba" ) ); 45 setCaption( QObject::tr("Opie Eye Caramba" ) );
46 m_cfg = new Opie::Core::OConfig("opie-eye"); 46 m_cfg = new Opie::Core::OConfig("opie-eye");
47 m_cfg->setGroup("main" ); 47 m_cfg->setGroup("main" );
48 readConfig(); 48 readConfig();
49 m_setDocCalled = false;
50 m_polishDone = false;
49 51
50 m_storage = new StorageInfo(); 52 m_storage = new StorageInfo();
51 connect(m_storage, SIGNAL(disksChanged() ), 53 connect(m_storage, SIGNAL(disksChanged() ),
52 this, SLOT( dirChanged() ) ); 54 this, SLOT( dirChanged() ) );
53 55
54 m_stack = new Opie::Ui::OWidgetStack( this ); 56 m_stack = new Opie::Ui::OWidgetStack( this );
55 setCentralWidget( m_stack ); 57 setCentralWidget( m_stack );
56 58
57 m_view = new PIconView( m_stack, m_cfg ); 59 m_view = new PIconView( m_stack, m_cfg );
58 m_stack->addWidget( m_view, IconView ); 60 m_stack->addWidget( m_view, IconView );
59 m_stack->raiseWidget( IconView ); 61 m_stack->raiseWidget( IconView );
60 62
61 connect(m_view, SIGNAL(sig_display(const QString&)), 63 connect(m_view, SIGNAL(sig_display(const QString&)),
62 this, SLOT(slotDisplay(const QString&))); 64 this, SLOT(slotDisplay(const QString&)));
63 connect(m_view, SIGNAL(sig_showInfo(const QString&)), 65 connect(m_view, SIGNAL(sig_showInfo(const QString&)),
64 this, SLOT(slotShowInfo(const QString&)) ); 66 this, SLOT(slotShowInfo(const QString&)) );
65 connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int))); 67 connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int)));
66 68
67 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); 69 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce);
68 70
69 listviewMenu = 0; 71 listviewMenu = 0;
70 /* setup menu and toolbar */ 72 /* setup menu and toolbar */
71 setupActions(); 73 setupActions();
72 setupToolbar(); 74 setupToolbar();
73 setupMenu(); 75 setupMenu();
74 m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true)); 76 m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true));
75 m_aAutoRotate->setEnabled(!m_aUnscaled->isOn()); 77 m_aAutoRotate->setEnabled(!m_aUnscaled->isOn());
76 odebug << "mainwindow constructor done" << oendl; 78 odebug << "mainwindow constructor done" << oendl;
77} 79}
78 80
79PMainWindow::~PMainWindow() { 81PMainWindow::~PMainWindow() {
80} 82}
81 83
82void PMainWindow::slotToggleZoomer() 84void PMainWindow::slotToggleZoomer()
83{ 85{
84 m_aZoomer->setOn(!m_aZoomer->isOn()); 86 m_aZoomer->setOn(!m_aZoomer->isOn());
85} 87}
86 88
87void PMainWindow::slotZoomerToggled(bool how) 89void PMainWindow::slotZoomerToggled(bool how)
88{ 90{
89 if (m_disp) { 91 if (m_disp) {
90 m_disp->setShowZoomer(how); 92 m_disp->setShowZoomer(how);
91 } 93 }
92 if (autoSave) { 94 if (autoSave) {
93 m_cfg->writeEntry("zoomeron",how); 95 m_cfg->writeEntry("zoomeron",how);
94 } 96 }
95} 97}
96 98
97void PMainWindow::slotToggleAutorotate() 99void PMainWindow::slotToggleAutorotate()
98{ 100{
99 if (!m_aAutoRotate->isEnabled()) return; 101 if (!m_aAutoRotate->isEnabled()) return;
100 m_aAutoRotate->setOn(!m_aAutoRotate->isOn()); 102 m_aAutoRotate->setOn(!m_aAutoRotate->isOn());
101} 103}
102 104
103void PMainWindow::slotToggleAutoscale() 105void PMainWindow::slotToggleAutoscale()
104{ 106{
105 m_aUnscaled->setOn(!m_aUnscaled->isOn()); 107 m_aUnscaled->setOn(!m_aUnscaled->isOn());
106} 108}
107 109
108void PMainWindow::slotRotateToggled(bool how) 110void PMainWindow::slotRotateToggled(bool how)
109{ 111{
110 if (autoSave) { 112 if (autoSave) {
111 m_cfg->writeEntry("autorotate",how); 113 m_cfg->writeEntry("autorotate",how);
112 } 114 }
113 if (m_disp) { 115 if (m_disp) {
114 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how); 116 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how);
115 } 117 }
116} 118}
117 119
118void PMainWindow::slotScaleToggled(bool how) 120void PMainWindow::slotScaleToggled(bool how)
119{ 121{
120 if (autoSave) { 122 if (autoSave) {
121 m_cfg->writeEntry("unscaled",how); 123 m_cfg->writeEntry("unscaled",how);
122 } 124 }
123 odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl; 125 odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl;
124 odebug << "How: " << how << oendl; 126 odebug << "How: " << how << oendl;
125 if (how) { 127 if (how) {
126 m_aAutoRotate->setOn(false); 128 m_aAutoRotate->setOn(false);
127 } 129 }
128 if (m_disp) { 130 if (m_disp) {
129 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),m_aAutoRotate->isOn()); 131 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),m_aAutoRotate->isOn());
130 } 132 }
131 m_aAutoRotate->setEnabled(!how); 133 m_aAutoRotate->setEnabled(!how);
132 odebug << "Autorotate: " << m_aAutoRotate->isOn() << oendl; 134 odebug << "Autorotate: " << m_aAutoRotate->isOn() << oendl;
133} 135}
134 136
135void PMainWindow::slotConfig() { 137void PMainWindow::slotConfig() {
136 /* 138 /*
137 * have a tab with the possible views 139 * have a tab with the possible views
138 * a tab for globals image cache size.. scaled loading 140 * a tab for globals image cache size.. scaled loading
139 * and one tab for the KeyConfigs 141 * and one tab for the KeyConfigs
140 */ 142 */
141 QDialog dlg(this, 0, true); 143 QDialog dlg(this, 0, true);
142 dlg.setCaption( tr("Opie Eye - Config" ) ); 144 dlg.setCaption( tr("Opie Eye - Config" ) );
143 145
144 QHBoxLayout *lay = new QHBoxLayout(&dlg); 146 QHBoxLayout *lay = new QHBoxLayout(&dlg);
145 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); 147 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg );
146 lay->addWidget( wid ); 148 lay->addWidget( wid );
147 149
148 BaseSetup*bSetup = new BaseSetup(m_cfg,wid); 150 BaseSetup*bSetup = new BaseSetup(m_cfg,wid);
149 wid->addTab(bSetup,"SettingsIcon","Basics setup"); 151 wid->addTab(bSetup,"SettingsIcon","Basics setup");
150 152
151 ViewMap *vM = viewMap(); 153 ViewMap *vM = viewMap();
152 ViewMap::Iterator _it = vM->begin(); 154 ViewMap::Iterator _it = vM->begin();
153 QMap<PDirView*, QWidget*> lst; 155 QMap<PDirView*, QWidget*> lst;
154 156
155 for( ; _it != vM->end(); ++_it ) { 157 for( ; _it != vM->end(); ++_it ) {
156 PDirView *view = (_it.data())(*m_cfg); 158 PDirView *view = (_it.data())(*m_cfg);
157 PInterfaceInfo *inf = view->interfaceInfo(); 159 PInterfaceInfo *inf = view->interfaceInfo();
158 QWidget *_wid = inf->configWidget( *m_cfg ); 160 QWidget *_wid = inf->configWidget( *m_cfg );
159 if (!_wid) continue; 161 if (!_wid) continue;
160 _wid->reparent(wid, QPoint() ); 162 _wid->reparent(wid, QPoint() );
161 lst.insert( view, _wid ); 163 lst.insert( view, _wid );
162 wid->addTab( _wid, "fileopen", inf->name() ); 164 wid->addTab( _wid, "fileopen", inf->name() );
163 } 165 }
164 166
165/* 167/*
166 * Add the KeyConfigWidget 168 * Add the KeyConfigWidget
167 */ 169 */
168 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); 170 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" );
169 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); 171 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue );
170 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); 172 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() );
171 QWidget*w = m_stack->visibleWidget(); 173 QWidget*w = m_stack->visibleWidget();
172 174
173 bool reminfo = false; 175 bool reminfo = false;
174 if ( !m_info ) { 176 if ( !m_info ) {
175 reminfo = true; 177 reminfo = true;
176 initInfo(); 178 initInfo();
177 m_info->hide(); 179 m_info->hide();
178 } 180 }
179 keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); 181 keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() );
180 182
181 bool remdisp = false; 183 bool remdisp = false;
182 if ( !m_disp ) { 184 if ( !m_disp ) {
183 remdisp = true; 185 remdisp = true;
184 initDisp(); 186 initDisp();
185 m_disp->hide(); 187 m_disp->hide();
186 } 188 }
187 keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); 189 keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() );
188 190
189 keyWid->load(); 191 keyWid->load();
190 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); 192 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") );
191 wid->setCurrentTab(0); 193 wid->setCurrentTab(0);
192 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); 194 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
193 195
194/* 196/*
195 * clean up 197 * clean up
196 *apply changes 198 *apply changes
197 */ 199 */
198 200
199 QMap<PDirView*, QWidget*>::Iterator it; 201 QMap<PDirView*, QWidget*>::Iterator it;
200 for ( it = lst.begin(); it != lst.end(); ++it ) { 202 for ( it = lst.begin(); it != lst.end(); ++it ) {
201 if ( act ) 203 if ( act )
202 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); 204 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg);
203 delete it.key(); 205 delete it.key();
204 } 206 }
205 207
206 208
207 if ( act ) { 209 if ( act ) {
208 keyWid->save(); 210 keyWid->save();
209 m_disp->manager()->save(); 211 m_disp->manager()->save();
210 m_info->manager()->save(); 212 m_info->manager()->save();
211 m_view->manager()->save(); 213 m_view->manager()->save();
212 bSetup->save_values(); 214 bSetup->save_values();
213 m_view->resetView(); 215 m_view->resetView();
214 readConfig(); 216 readConfig();
215 } 217 }
216 delete keyWid; 218 delete keyWid;
217 219
218 m_stack->raiseWidget(w); 220 m_stack->raiseWidget(w);
219 if (remdisp) { 221 if (remdisp) {
220 m_disp->hide(); 222 m_disp->hide();
221 } 223 }
222 if (reminfo) { 224 if (reminfo) {
223 m_info->hide(); 225 m_info->hide();
224 } 226 }
225} 227}
226 228
227/* 229/*
228 * create a new image info component 230 * create a new image info component
229 * and detach the current one 231 * and detach the current one
230 * we will make the other delete on exit 232 * we will make the other delete on exit
231 */ 233 */
232template<class T> 234template<class T>
233void PMainWindow::initT( const char* name, T** ptr, int id) { 235void PMainWindow::initT( const char* name, T** ptr, int id) {
234 if ( *ptr ) { 236 if ( *ptr ) {
235 (*ptr)->disconnect(this, SLOT(slotReturn())); 237 (*ptr)->disconnect(this, SLOT(slotReturn()));
236 (*ptr)->setDestructiveClose(); 238 (*ptr)->setDestructiveClose();
237 m_stack->removeWidget( *ptr ); 239 m_stack->removeWidget( *ptr );
238 } 240 }
239 *ptr = new T(m_cfg, m_stack, name ); 241 *ptr = new T(m_cfg, m_stack, name );
240 m_stack->addWidget( *ptr, id ); 242 m_stack->addWidget( *ptr, id );
241 243
242 connect(*ptr, SIGNAL(sig_return()), 244 connect(*ptr, SIGNAL(sig_return()),
243 this,SLOT(slotReturn())); 245 this,SLOT(slotReturn()));
244 246
245} 247}
246 248
247void PMainWindow::initInfo() { 249void PMainWindow::initInfo() {
248 initT<imageinfo>( "Image Info", &m_info, ImageInfo ); 250 initT<imageinfo>( "Image Info", &m_info, ImageInfo );
249 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); 251 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&)));
250} 252}
251 253
252void PMainWindow::initDisp() { 254void PMainWindow::initDisp() {
253 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); 255 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay );
254 if (m_disp) { 256 if (m_disp) {
255 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 257 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
256 m_disp->setMinimumSize(QApplication::desktop()->size()/2); 258 m_disp->setMinimumSize(QApplication::desktop()->size()/2);
257 } 259 }
258 m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType); 260 m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType);
259 m_disp->setAutoScale(!m_aUnscaled->isOn()); 261 m_disp->setAutoScale(!m_aUnscaled->isOn());
260 m_disp->setAutoRotate(m_aAutoRotate->isOn()); 262 m_disp->setAutoRotate(m_aAutoRotate->isOn());
261 m_disp->setShowZoomer(m_aZoomer->isOn()); 263 m_disp->setShowZoomer(m_aZoomer->isOn());
262 m_disp->setBackgroundColor(white); 264 m_disp->setBackgroundColor(white);
263 connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); 265 connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&)));
264 connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); 266 connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext()));
265 connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); 267 connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev()));
266 connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); 268 connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen()));
267 connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); 269 connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView()));
268 connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); 270 connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer()));
269 connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); 271 connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale()));
270 connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); 272 connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate()));
271 connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int))); 273 connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int)));
272 slotFullScreenToggled(m_aFullScreen->isOn()); 274 slotFullScreenToggled(m_aFullScreen->isOn());
273 } 275 }
274} 276}
275 277
276void PMainWindow::slotToggleFullScreen() 278void PMainWindow::slotToggleFullScreen()
277{ 279{
278 bool current = !m_aFullScreen->isOn(); 280 bool current = !m_aFullScreen->isOn();
279 m_aFullScreen->setOn(current); 281 m_aFullScreen->setOn(current);
280} 282}
281 283
282void PMainWindow::slotFullScreenButton(bool current) 284void PMainWindow::slotFullScreenButton(bool current)
283{ 285{
284 if (autoSave) { 286 if (autoSave) {
285 m_cfg->writeEntry("fullscreen",current); 287 m_cfg->writeEntry("fullscreen",current);
286 } 288 }
287 if (!m_disp) return; 289 if (!m_disp) return;
288 if (m_disp->isVisible()) { 290 if (m_disp->isVisible()) {
289 setupViewWindow(current, true); 291 setupViewWindow(current, true);
290 } 292 }
291} 293}
292 294
293void PMainWindow::setupViewWindow(bool current, bool forceDisplay) 295void PMainWindow::setupViewWindow(bool current, bool forceDisplay)
294{ 296{
295 if (!m_disp) return; 297 if (!m_disp) return;
296 if (current) { 298 if (current) {
297 m_disp->setBackgroundColor(black); 299 m_disp->setBackgroundColor(black);
298 m_disp->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); 300 m_disp->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0));
299 m_disp->setVScrollBarMode(QScrollView::AlwaysOff); 301 m_disp->setVScrollBarMode(QScrollView::AlwaysOff);
300 m_disp->setHScrollBarMode(QScrollView::AlwaysOff); 302 m_disp->setHScrollBarMode(QScrollView::AlwaysOff);
301 m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); 303 m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height());
302 } else { 304 } else {
303 setUpdatesEnabled(false); 305 setUpdatesEnabled(false);
304 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 306 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
305 m_disp->setMinimumSize(QApplication::desktop()->size()/2); 307 m_disp->setMinimumSize(QApplication::desktop()->size()/2);
306 } else { 308 } else {
307 m_disp->setMinimumSize(10,10); 309 m_disp->setMinimumSize(10,10);
308 } 310 }
309 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 311 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
310 m_disp->reparent(0,QPoint(50,50)); 312 m_disp->reparent(0,QPoint(50,50));
311 } else { 313 } else {
312 m_disp->reparent(0,QPoint(0,0)); 314 m_disp->reparent(0,QPoint(0,0));
313 } 315 }
314 m_disp->setBackgroundColor(white); 316 m_disp->setBackgroundColor(white);
315 m_stack->addWidget(m_disp,ImageDisplay); 317 m_stack->addWidget(m_disp,ImageDisplay);
316 m_disp->setVScrollBarMode(QScrollView::Auto); 318 m_disp->setVScrollBarMode(QScrollView::Auto);
317 m_disp->setHScrollBarMode(QScrollView::Auto); 319 m_disp->setHScrollBarMode(QScrollView::Auto);
318 if (forceDisplay || m_disp->isVisible()) 320 if (forceDisplay || m_disp->isVisible())
319 m_stack->raiseWidget(m_disp); 321 m_stack->raiseWidget(m_disp);
320 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 322 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
321 m_disp->resize(m_disp->minimumSize()); 323 m_disp->resize(m_disp->minimumSize());
322 } 324 }
323 setUpdatesEnabled(true); 325 setUpdatesEnabled(true);
324 } 326 }
325 m_disp->setFullScreen(current,forceDisplay); 327 m_disp->setFullScreen(current,forceDisplay);
326} 328}
327 329
328void PMainWindow::slotFullScreenToggled(bool current) 330void PMainWindow::slotFullScreenToggled(bool current)
329{ 331{
330 setupViewWindow(current,true); 332 setupViewWindow(current,true);
331} 333}
332 334
333/** 335/**
334 * With big Screen the plan could be to 'detach' the image 336 * With big Screen the plan could be to 'detach' the image
335 * window if visible and to create a ne wone 337 * window if visible and to create a ne wone
336 * init* already supports it but I make no use of it for 338 * init* already supports it but I make no use of it for
337 * now. We set filename and raise 339 * now. We set filename and raise
338 * 340 *
339 * ### FIXME and talk to alwin 341 * ### FIXME and talk to alwin
340 */ 342 */
341void PMainWindow::slotShowInfo( const QString& inf ) { 343void PMainWindow::slotShowInfo( const QString& inf ) {
342 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { 344 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) {
343 return; 345 return;
344 } 346 }
345 if ( !m_info ) { 347 if ( !m_info ) {
346 initInfo(); 348 initInfo();
347 } 349 }
348 m_info->setPath( inf ); 350 m_info->setPath( inf );
349 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 351 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
350 m_aNext->removeFrom(toolBar); 352 m_aNext->removeFrom(toolBar);
351 m_aPrevious->removeFrom(toolBar); 353 m_aPrevious->removeFrom(toolBar);
352 m_aNext->setEnabled(false); 354 m_aNext->setEnabled(false);
353 m_aPrevious->setEnabled(false); 355 m_aPrevious->setEnabled(false);
354 m_aDirUp->setEnabled(false); 356 m_aDirUp->setEnabled(false);
355 m_aShowInfo->setEnabled(false); 357 m_aShowInfo->setEnabled(false);
356 m_aViewfile->setEnabled(true); 358 m_aViewfile->setEnabled(true);
357 m_aStartSlide->setEnabled(false); 359 m_aStartSlide->setEnabled(false);
358 fsButton->hide(); 360 fsButton->hide();
359 } 361 }
360 m_stack->raiseWidget( ImageInfo ); 362 m_stack->raiseWidget( ImageInfo );
361} 363}
362 364
363void PMainWindow::slotDisplay( const QString& inf ) { 365void PMainWindow::slotDisplay( const QString& inf ) {
364 bool nwindow = false; 366 bool nwindow = false;
365 if ( !m_disp ) { 367 if ( !m_disp ) {
366 nwindow = true; 368 nwindow = true;
367 initDisp(); 369 initDisp();
368 } 370 }
369 m_disp->setImage( inf ); 371 m_disp->setImage( inf );
370 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 372 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
371 if (m_gPrevNext->isEnabled()==false) { 373 if (m_gPrevNext->isEnabled()==false) {
372 m_gPrevNext->addTo(toolBar); 374 m_gPrevNext->addTo(toolBar);
373 m_gPrevNext->setEnabled(true); 375 m_gPrevNext->setEnabled(true);
374 376
375 m_aDirUp->setEnabled(false); 377 m_aDirUp->setEnabled(false);
376 m_aShowInfo->setEnabled(true); 378 m_aShowInfo->setEnabled(true);
377 m_aViewfile->setEnabled(false); 379 m_aViewfile->setEnabled(false);
378 m_aStartSlide->setEnabled(false); 380 m_aStartSlide->setEnabled(false);
379 fsButton->hide(); 381 fsButton->hide();
380 } 382 }
381 } 383 }
382 if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) { 384 if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) {
383 slotFullScreenToggled(m_aFullScreen->isOn()); 385 slotFullScreenToggled(m_aFullScreen->isOn());
384 } 386 }
385 if (m_disp->fullScreen()) { 387 if (m_disp->fullScreen()) {
386 qwsDisplay()->requestFocus( m_disp->winId(), TRUE); 388 qwsDisplay()->requestFocus( m_disp->winId(), TRUE);
387 } else { 389 } else {
388 m_stack->raiseWidget( ImageDisplay ); 390 m_stack->raiseWidget( ImageDisplay );
389 } 391 }
390} 392}
391 393
392void PMainWindow::raiseIconView() { 394void PMainWindow::raiseIconView() {
393 setUpdatesEnabled(false); 395 setUpdatesEnabled(false);
394 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 396 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
395 m_gPrevNext->removeFrom(toolBar); 397 m_gPrevNext->removeFrom(toolBar);
396 m_gPrevNext->setEnabled(false); 398 m_gPrevNext->setEnabled(false);
397 m_aDirUp->setEnabled(true); 399 m_aDirUp->setEnabled(true);
398 m_aShowInfo->setEnabled(true); 400 m_aShowInfo->setEnabled(true);
399 m_aViewfile->setEnabled(true); 401 m_aViewfile->setEnabled(true);
400 m_aStartSlide->setEnabled(true); 402 m_aStartSlide->setEnabled(true);
401 fsButton->show(); 403 fsButton->show();
402 } 404 }
403 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { 405 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) {
404 m_disp->stopSlide(); 406 m_disp->stopSlide();
405 m_disp->hide(); 407 m_disp->hide();
406 } 408 }
407 m_stack->raiseWidget( IconView ); 409 m_stack->raiseWidget( IconView );
408 setUpdatesEnabled(true); 410 setUpdatesEnabled(true);
409 repaint(); 411 repaint();
410} 412}
411 413
412void PMainWindow::slotReturn() { 414void PMainWindow::slotReturn() {
413 raiseIconView(); 415 raiseIconView();
414} 416}
415 417
416 418
417void PMainWindow::closeEvent( QCloseEvent* ev ) { 419void PMainWindow::closeEvent( QCloseEvent* ev ) {
418 /* 420 /*
419 * return from view 421 * return from view
420 * or properly quit 422 * or properly quit
421 */ 423 */
422 if ( m_stack->visibleWidget() == m_info || 424 if (!m_setDocCalled) {
423 m_stack->visibleWidget() == m_disp ) { 425 if ( m_stack->visibleWidget() == m_info ||
424 ev->ignore(); 426 m_stack->visibleWidget() == m_disp ) {
425 raiseIconView(); 427 ev->ignore();
426 return; 428 raiseIconView();
429 return;
430 }
427 } 431 }
428 if (m_disp && m_disp->fullScreen()) { 432 if (m_disp && m_disp->fullScreen()) {
429 /* otherwise opie-eye crashes in bigscreen mode! */ 433 /* otherwise opie-eye crashes in bigscreen mode! */
430 m_disp->reparent(0,QPoint(0,0)); 434 m_disp->reparent(0,QPoint(0,0));
431 m_stack->addWidget(m_disp,ImageDisplay); 435 m_stack->addWidget(m_disp,ImageDisplay);
432 } 436 }
433 ev->accept(); 437 ev->accept();
434 QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); 438 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()));
435} 439}
436 440
437void PMainWindow::setDocument( const QString& showImg ) 441void PMainWindow::setDocument( const QString& showImg )
438{ 442{
439 bool first_start = m_disp==0;
440
441 QString file = showImg; 443 QString file = showImg;
442 DocLnk lnk(showImg); 444 DocLnk lnk(showImg);
443 if (lnk.isValid() ) 445 if (lnk.isValid() )
444 file = lnk.file(); 446 file = lnk.file();
445 slotDisplay( file ); 447 slotDisplay( file );
446 if (first_start && m_aFullScreen->isOn()) { 448#if 0
449 if (!m_polishDone) {
447 QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); 450 QTimer::singleShot(0,this,SLOT(check_view_fullscreen()));
448 } 451 }
452#endif
449} 453}
450 454
451void PMainWindow::check_view_fullscreen() 455void PMainWindow::check_view_fullscreen()
452{ 456{
453 if (!m_view) return; 457 if (!m_view) return;
454 if (!m_view->hasFocus()&&m_aFullScreen->isOn()) { 458 if (!m_view->hasFocus()&&m_aFullScreen->isOn()) {
455 qwsDisplay()->requestFocus( m_disp->winId(), TRUE); 459 qwsDisplay()->requestFocus( m_disp->winId(), TRUE);
456 } 460 }
457} 461}
458 462
459void PMainWindow::slotSelectDir(int id) 463void PMainWindow::slotSelectDir(int id)
460{ 464{
461 emit changeDir( m_dev[fsMenu->text(id )] ); 465 emit changeDir( m_dev[fsMenu->text(id )] );
462} 466}
463 467
464void PMainWindow::dirChanged() 468void PMainWindow::dirChanged()
465{ 469{
466 fsMenu->clear(); 470 fsMenu->clear();
467 m_dev.clear(); 471 m_dev.clear();
468 472
469 /* home dir, too */ 473 /* home dir, too */
470 QString f = getenv( "HOME" ); 474 QString f = getenv( "HOME" );
471 if (!f.isEmpty()) { 475 if (!f.isEmpty()) {
472 m_dev.insert("Home directory",f); 476 m_dev.insert("Home directory",f);
473 fsMenu->insertItem("Home directory"); 477 fsMenu->insertItem("Home directory");
474 } 478 }
475 const QList<FileSystem> &fs = m_storage->fileSystems(); 479 const QList<FileSystem> &fs = m_storage->fileSystems();
476 QListIterator<FileSystem> it(fs ); 480 QListIterator<FileSystem> it(fs );
477 for ( ; it.current(); ++it ) { 481 for ( ; it.current(); ++it ) {
478 const QString disk = (*it)->name(); 482 const QString disk = (*it)->name();
479 const QString path = (*it)->path(); 483 const QString path = (*it)->path();
480 m_dev.insert( disk, path ); 484 m_dev.insert( disk, path );
481 fsMenu->insertItem( disk ); 485 fsMenu->insertItem( disk );
482 } 486 }
483} 487}
484 488
485void PMainWindow::showToolbar(bool how) 489void PMainWindow::showToolbar(bool how)
486{ 490{
487 if (!how) toolBar->hide(); 491 if (!how) toolBar->hide();
488 else toolBar->show(); 492 else toolBar->show();
489 if (autoSave) { 493 if (autoSave) {
490 m_cfg->writeEntry("showtoolbar",how); 494 m_cfg->writeEntry("showtoolbar",how);
491 } 495 }
492} 496}
493 497
494void PMainWindow::setupActions() 498void PMainWindow::setupActions()
495{ 499{
496 m_aDirUp = new QAction( tr( "Go dir up" ), Resource::loadIconSet( "up" ), 0, 0, this, 0, true ); 500 m_aDirUp = new QAction( tr( "Go dir up" ), Resource::loadIconSet( "up" ), 0, 0, this, 0, true );
497 m_aDirUp->setToggleAction(false); 501 m_aDirUp->setToggleAction(false);
498 connect(m_aDirUp,SIGNAL(activated()),m_view,SLOT(slotDirUp())); 502 connect(m_aDirUp,SIGNAL(activated()),m_view,SLOT(slotDirUp()));
499 503
500 if ( Ir::supported() ) { 504 if ( Ir::supported() ) {
501 m_aBeam = new QAction( tr( "Beam file" ), Resource::loadIconSet( "beam" ),0, 0, this, 0, true ); 505 m_aBeam = new QAction( tr( "Beam file" ), Resource::loadIconSet( "beam" ),0, 0, this, 0, true );
502 m_aBeam->setToggleAction(false); 506 m_aBeam->setToggleAction(false);
503 connect(m_aBeam,SIGNAL(activated()),m_view,SLOT(slotBeam())); 507 connect(m_aBeam,SIGNAL(activated()),m_view,SLOT(slotBeam()));
504 } else { 508 } else {
505 m_aBeam = 0; 509 m_aBeam = 0;
506 } 510 }
507 511
508 m_aShowInfo = new QAction( tr( "Show imageinfo" ), Resource::loadIconSet( "edit" ), 0, 0, this, 0, true ); 512 m_aShowInfo = new QAction( tr( "Show imageinfo" ), Resource::loadIconSet( "edit" ), 0, 0, this, 0, true );
509 m_aShowInfo->setToggleAction(false); 513 m_aShowInfo->setToggleAction(false);
510 connect(m_aShowInfo,SIGNAL(activated()),m_view,SLOT(slotImageInfo())); 514 connect(m_aShowInfo,SIGNAL(activated()),m_view,SLOT(slotImageInfo()));
511 515
512 m_aTrash = new QAction( tr( "Delete file" ), Resource::loadIconSet("trash"), 0, 0, this, 0, true ); 516 m_aTrash = new QAction( tr( "Delete file" ), Resource::loadIconSet("trash"), 0, 0, this, 0, true );
513 m_aTrash->setToggleAction(false); 517 m_aTrash->setToggleAction(false);
514 connect(m_aTrash,SIGNAL(activated()),m_view,SLOT(slotTrash())); 518 connect(m_aTrash,SIGNAL(activated()),m_view,SLOT(slotTrash()));
515 519
516 m_aViewfile = new QAction( tr( "Display image" ), Resource::loadIconSet("mag"), 0, 0, this, 0, true ); 520 m_aViewfile = new QAction( tr( "Display image" ), Resource::loadIconSet("mag"), 0, 0, this, 0, true );
517 m_aViewfile->setToggleAction(false); 521 m_aViewfile->setToggleAction(false);
518 connect(m_aViewfile,SIGNAL(activated()),m_view,SLOT(slotShowImage())); 522 connect(m_aViewfile,SIGNAL(activated()),m_view,SLOT(slotShowImage()));
519 523
520 m_aStartSlide = new QAction( tr( "Start slideshow" ), Resource::loadIconSet("play"),0, 0, this, 0, true ); 524 m_aStartSlide = new QAction( tr( "Start slideshow" ), Resource::loadIconSet("play"),0, 0, this, 0, true );
521 m_aStartSlide->setToggleAction(false); 525 m_aStartSlide->setToggleAction(false);
522 connect(m_aStartSlide,SIGNAL(activated()),m_view,SLOT(slotStartSlide())); 526 connect(m_aStartSlide,SIGNAL(activated()),m_view,SLOT(slotStartSlide()));
523 527
524 m_aHideToolbar = new QAction( tr( "Show toolbar" ), Resource::loadIconSet( "UtilsIcon" ), 0, 0, this, 0, true ); 528 m_aHideToolbar = new QAction( tr( "Show toolbar" ), Resource::loadIconSet( "UtilsIcon" ), 0, 0, this, 0, true );
525 m_aHideToolbar->setOn (true); 529 m_aHideToolbar->setOn (true);
526 connect(m_aHideToolbar,SIGNAL(toggled(bool)),this,SLOT(showToolbar(bool))); 530 connect(m_aHideToolbar,SIGNAL(toggled(bool)),this,SLOT(showToolbar(bool)));
527 531
528 m_aSetup = new QAction( tr( "Settings" ), Resource::loadIconSet("SettingsIcon"), 0, 0, this, 0, true ); 532 m_aSetup = new QAction( tr( "Settings" ), Resource::loadIconSet("SettingsIcon"), 0, 0, this, 0, true );
529 m_aSetup->setToggleAction(false); 533 m_aSetup->setToggleAction(false);
530 connect(m_aSetup,SIGNAL(activated()),this,SLOT(slotConfig())); 534 connect(m_aSetup,SIGNAL(activated()),this,SLOT(slotConfig()));
531 535
532 m_gListViewMode = new QActionGroup(this,"Select listmode",true); 536 m_gListViewMode = new QActionGroup(this,"Select listmode",true);
533 connect(m_gListViewMode,SIGNAL(selected(QAction*)),this,SLOT(listviewselected(QAction*))); 537 connect(m_gListViewMode,SIGNAL(selected(QAction*)),this,SLOT(listviewselected(QAction*)));
534 538
535 m_aDirLong = new QAction( tr( "Thumbnail and Imageinfo" ),Resource::loadIconSet("opie-eye/opie-eye-thumb"), 0, 0, this, 0, true ); 539 m_aDirLong = new QAction( tr( "Thumbnail and Imageinfo" ),Resource::loadIconSet("opie-eye/opie-eye-thumb"), 0, 0, this, 0, true );
536 m_aDirLong->setToggleAction(true); 540 m_aDirLong->setToggleAction(true);
537 m_aDirShort = new QAction( tr( "Thumbnail and name" ),Resource::loadIconSet("opie-eye/opie-eye-thumbonly"), 0, 0, this, 0, true ); 541 m_aDirShort = new QAction( tr( "Thumbnail and name" ),Resource::loadIconSet("opie-eye/opie-eye-thumbonly"), 0, 0, this, 0, true );
538 m_aDirShort->setToggleAction(true); 542 m_aDirShort->setToggleAction(true);
539 m_aDirName = new QAction( tr( "Name only" ), Resource::loadIconSet("opie-eye/opie-eye-textview"),0, 0, this, 0, true ); 543 m_aDirName = new QAction( tr( "Name only" ), Resource::loadIconSet("opie-eye/opie-eye-textview"),0, 0, this, 0, true );
540 m_aDirName->setToggleAction(true); 544 m_aDirName->setToggleAction(true);
541 int mode = m_cfg->readNumEntry("ListViewMode", 1); 545 int mode = m_cfg->readNumEntry("ListViewMode", 1);
542 if (mode < 1 || mode>3) mode = 1; 546 if (mode < 1 || mode>3) mode = 1;
543 switch (mode) { 547 switch (mode) {
544 case 3: 548 case 3:
545 m_aDirName->setOn(true); 549 m_aDirName->setOn(true);
546 break; 550 break;
547 case 2: 551 case 2:
548 m_aDirShort->setOn(true); 552 m_aDirShort->setOn(true);
549 break; 553 break;
550 case 1: 554 case 1:
551 default: 555 default:
552 m_aDirLong->setOn(true); 556 m_aDirLong->setOn(true);
553 } 557 }
554 m_gListViewMode->insert(m_aDirLong); 558 m_gListViewMode->insert(m_aDirLong);
555 m_gListViewMode->insert(m_aDirShort); 559 m_gListViewMode->insert(m_aDirShort);
556 m_gListViewMode->insert(m_aDirName); 560 m_gListViewMode->insert(m_aDirName);
557 561
558 m_gPrevNext = new QActionGroup(this,"imageprevnext",false); 562 m_gPrevNext = new QActionGroup(this,"imageprevnext",false);
559 m_aNext = new QAction( tr( "Next image" ), Resource::loadIconSet("forward"), 0, 0, this, 0, true ); 563 m_aNext = new QAction( tr( "Next image" ), Resource::loadIconSet("forward"), 0, 0, this, 0, true );
560 m_aNext->setToggleAction(false); 564 m_aNext->setToggleAction(false);
561 connect(m_aNext,SIGNAL(activated()),m_view,SLOT(slotShowNext())); 565 connect(m_aNext,SIGNAL(activated()),m_view,SLOT(slotShowNext()));
562 m_aPrevious = new QAction( tr( "Previous image" ), Resource::loadIconSet("back"), 0, 0, this, 0, true ); 566 m_aPrevious = new QAction( tr( "Previous image" ), Resource::loadIconSet("back"), 0, 0, this, 0, true );
563 m_aPrevious->setToggleAction(false); 567 m_aPrevious->setToggleAction(false);
564 connect(m_aPrevious,SIGNAL(activated()),m_view,SLOT(slotShowPrev())); 568 connect(m_aPrevious,SIGNAL(activated()),m_view,SLOT(slotShowPrev()));
565 m_gPrevNext->insert(m_aPrevious); 569 m_gPrevNext->insert(m_aPrevious);
566 m_gPrevNext->insert(m_aNext); 570 m_gPrevNext->insert(m_aNext);
567 571
568 m_aFullScreen = new QAction( tr( "Show images fullscreen" ), 572 m_aFullScreen = new QAction( tr( "Show images fullscreen" ),
569 Resource::loadIconSet("fullscreen"), 0, 0, this, 0, true ); 573 Resource::loadIconSet("fullscreen"), 0, 0, this, 0, true );
570 m_aFullScreen->setToggleAction(true); 574 m_aFullScreen->setToggleAction(true);
571 if (autoSave) { 575 if (autoSave) {
572 m_aFullScreen->setOn(m_cfg->readBoolEntry("fullscreen",false)); 576 m_aFullScreen->setOn(m_cfg->readBoolEntry("fullscreen",false));
573 } else { 577 } else {
574 m_aFullScreen->setOn(false); 578 m_aFullScreen->setOn(false);
575 } 579 }
576 connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool))); 580 connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool)));
577 581
578 m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false); 582 m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false);
579 m_aAutoRotate = new QAction( tr( "Auto rotate images" ), Resource::loadIconSet( "rotate" ), 0, 0, this, 0, true ); 583 m_aAutoRotate = new QAction( tr( "Auto rotate images" ), Resource::loadIconSet( "rotate" ), 0, 0, this, 0, true );
580 m_aAutoRotate->setToggleAction(true); 584 m_aAutoRotate->setToggleAction(true);
581 585
582 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 586 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
583 m_aAutoRotate->setOn(true); 587 m_aAutoRotate->setOn(true);
584 } else { 588 } else {
585 m_aAutoRotate->setOn(false); 589 m_aAutoRotate->setOn(false);
586 } 590 }
587 if (autoSave) { 591 if (autoSave) {
588 m_aAutoRotate->setOn(m_cfg->readBoolEntry("autorotate",m_aAutoRotate->isOn())); 592 m_aAutoRotate->setOn(m_cfg->readBoolEntry("autorotate",m_aAutoRotate->isOn()));
589 } 593 }
590 connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); 594 connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool)));
591 595
592 m_aUnscaled = new QAction( tr( "Show images unscaled" ), Resource::loadIconSet( "1to1" ), 0, 0, this, 0, true ); 596 m_aUnscaled = new QAction( tr( "Show images unscaled" ), Resource::loadIconSet( "1to1" ), 0, 0, this, 0, true );
593 m_aUnscaled->setToggleAction(true); 597 m_aUnscaled->setToggleAction(true);
594 connect(m_aUnscaled,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); 598 connect(m_aUnscaled,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool)));
595 if (autoSave) { 599 if (autoSave) {
596 m_aUnscaled->setOn(m_cfg->readBoolEntry("unscaled",false)); 600 m_aUnscaled->setOn(m_cfg->readBoolEntry("unscaled",false));
597 } else { 601 } else {
598 m_aUnscaled->setOn(false); 602 m_aUnscaled->setOn(false);
599 } 603 }
600 604
601 m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), Resource::loadIconSet( "mag" ), 0, 0, this, 0, true ); 605 m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), Resource::loadIconSet( "mag" ), 0, 0, this, 0, true );
602 m_aZoomer->setToggleAction(true); 606 m_aZoomer->setToggleAction(true);
603 if (autoSave) { 607 if (autoSave) {
604 m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true)); 608 m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true));
605 } else { 609 } else {
606 m_aZoomer->setOn (true); 610 m_aZoomer->setOn (true);
607 } 611 }
608 connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); 612 connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool)));
609 m_gDisplayType->insert(m_aAutoRotate); 613 m_gDisplayType->insert(m_aAutoRotate);
610 m_gDisplayType->insert(m_aUnscaled); 614 m_gDisplayType->insert(m_aUnscaled);
611 m_gDisplayType->insert(m_aZoomer); 615 m_gDisplayType->insert(m_aZoomer);
612 616
613 m_hGroup = new QActionGroup(this,"actioncollection",false); 617 m_hGroup = new QActionGroup(this,"actioncollection",false);
614 m_hGroup->insert(m_aFullScreen); 618 m_hGroup->insert(m_aFullScreen);
615} 619}
616 620
617void PMainWindow::setupToolbar() 621void PMainWindow::setupToolbar()
618{ 622{
619 toolBar = new QToolBar( this ); 623 toolBar = new QToolBar( this );
620 addToolBar(toolBar); 624 addToolBar(toolBar);
621 toolBar->setHorizontalStretchable( true ); 625 toolBar->setHorizontalStretchable( true );
622 setToolBarsMovable( false ); 626 setToolBarsMovable( false );
623 m_aDirUp->addTo( toolBar ); 627 m_aDirUp->addTo( toolBar );
624 628
625 fsButton = new PFileSystem( toolBar ); 629 fsButton = new PFileSystem( toolBar );
626 connect( fsButton, SIGNAL( changeDir( const QString& ) ), 630 connect( fsButton, SIGNAL( changeDir( const QString& ) ),
627 m_view, SLOT(slotChangeDir( const QString& ) ) ); 631 m_view, SLOT(slotChangeDir( const QString& ) ) );
628 connect( this, SIGNAL( changeDir( const QString& ) ), 632 connect( this, SIGNAL( changeDir( const QString& ) ),
629 m_view, SLOT(slotChangeDir( const QString& ) ) ); 633 m_view, SLOT(slotChangeDir( const QString& ) ) );
630 634
631 if (m_aBeam) { 635 if (m_aBeam) {
632 m_aBeam->addTo( toolBar ); 636 m_aBeam->addTo( toolBar );
633 } 637 }
634 m_aShowInfo->addTo(toolBar); 638 m_aShowInfo->addTo(toolBar);
635 m_aTrash->addTo(toolBar); 639 m_aTrash->addTo(toolBar);
636// m_aSetup->addTo(toolBar); 640// m_aSetup->addTo(toolBar);
637 641
638 m_gDisplayType->addTo(toolBar); 642 m_gDisplayType->addTo(toolBar);
639 643
640 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 644 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
641 m_gPrevNext->addTo(toolBar); 645 m_gPrevNext->addTo(toolBar);
642 } else { 646 } else {
643 m_gPrevNext->setEnabled(false); 647 m_gPrevNext->setEnabled(false);
644 } 648 }
645} 649}
646 650
647void PMainWindow::setupMenu() 651void PMainWindow::setupMenu()
648{ 652{
649 fileMenu = new QPopupMenu( menuBar() ); 653 fileMenu = new QPopupMenu( menuBar() );
650 menuBar()->insertItem( tr( "File" ), fileMenu ); 654 menuBar()->insertItem( tr( "File" ), fileMenu );
651 dispMenu = new QPopupMenu( menuBar() ); 655 dispMenu = new QPopupMenu( menuBar() );
652 menuBar()->insertItem( tr( "Show" ), dispMenu ); 656 menuBar()->insertItem( tr( "Show" ), dispMenu );
653 settingsMenu = new QPopupMenu( menuBar() ); 657 settingsMenu = new QPopupMenu( menuBar() );
654 menuBar()->insertItem( tr( "Settings" ), settingsMenu ); 658 menuBar()->insertItem( tr( "Settings" ), settingsMenu );
655 659
656 m_aViewfile->addTo(fileMenu); 660 m_aViewfile->addTo(fileMenu);
657 m_aShowInfo->addTo(fileMenu); 661 m_aShowInfo->addTo(fileMenu);
658 m_aStartSlide->addTo(fileMenu); 662 m_aStartSlide->addTo(fileMenu);
659 663
660 fileMenu->insertSeparator(); 664 fileMenu->insertSeparator();
661 m_aDirUp->addTo( fileMenu ); 665 m_aDirUp->addTo( fileMenu );
662 666
663 fsMenu = new QPopupMenu(fileMenu); 667 fsMenu = new QPopupMenu(fileMenu);
664 fileMenu->insertItem(Resource::loadIconSet( "cardmon/pcmcia" ),tr("Select filesystem"),fsMenu); 668 fileMenu->insertItem(Resource::loadIconSet( "cardmon/pcmcia" ),tr("Select filesystem"),fsMenu);
665 connect( fsMenu, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) ); 669 connect( fsMenu, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) );
666 dirChanged(); 670 dirChanged();
667 671
668 if ( m_aBeam ) { 672 if ( m_aBeam ) {
669 fileMenu->insertSeparator(); 673 fileMenu->insertSeparator();
670 m_aBeam->addTo( fileMenu ); 674 m_aBeam->addTo( fileMenu );
671 } 675 }
672 fileMenu->insertSeparator(); 676 fileMenu->insertSeparator();
673 m_aTrash->addTo(fileMenu); 677 m_aTrash->addTo(fileMenu);
674 678
675 listviewMenu = new QPopupMenu(dispMenu); 679 listviewMenu = new QPopupMenu(dispMenu);
676 dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu); 680 dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu);
677 m_gListViewMode->addTo(listviewMenu); 681 m_gListViewMode->addTo(listviewMenu);
678 dispMenu->insertSeparator(); 682 dispMenu->insertSeparator();
679 m_aFullScreen->addTo(dispMenu); 683 m_aFullScreen->addTo(dispMenu);
680 m_gDisplayType->addTo(dispMenu); 684 m_gDisplayType->addTo(dispMenu);
681 dispMenu->insertSeparator(); 685 dispMenu->insertSeparator();
682 m_gPrevNext->addTo(dispMenu); 686 m_gPrevNext->addTo(dispMenu);
683 687
684 m_aSetup->addTo(settingsMenu); 688 m_aSetup->addTo(settingsMenu);
685 m_aHideToolbar->addTo(settingsMenu); 689 m_aHideToolbar->addTo(settingsMenu);
686} 690}
687 691
688void PMainWindow::listviewselected(QAction*which) 692void PMainWindow::listviewselected(QAction*which)
689{ 693{
690 if (!which || which->isOn()==false) return; 694 if (!which || which->isOn()==false) return;
691 int val = 1; 695 int val = 1;
692// QString name;
693 696
694 if (which==m_aDirName) { 697 if (which==m_aDirName) {
695 val = 3; 698 val = 3;
696// name = "opie-eye/opie-eye-textview";
697 } else if (which==m_aDirShort) { 699 } else if (which==m_aDirShort) {
698 val = 2; 700 val = 2;
699// name = "opie-eye/opie-eye-thumbonly";
700 } else if (which==m_aDirLong) { 701 } else if (which==m_aDirLong) {
701 val = 1; 702 val = 1;
702// name = "opie-eye/opie-eye-thumb";
703 } 703 }
704 emit changeListMode(val); 704 emit changeListMode(val);
705} 705}
706 706
707void PMainWindow::readConfig() 707void PMainWindow::readConfig()
708{ 708{
709 autoSave =m_cfg->readBoolEntry("savestatus",true); 709 autoSave =m_cfg->readBoolEntry("savestatus",true);
710} 710}
711
712void PMainWindow::polish()
713{
714 if (m_disp) {
715 odebug << "======================\n"
716 << "Called via setdocument\n"
717 << "======================" << oendl;
718 m_setDocCalled = true;
719 m_view->setDoccalled(true);
720 m_disp->setCloseIfHide(true);
721 } else {
722 m_setDocCalled = false;
723 m_view->setDoccalled(false);
724 }
725 m_polishDone = true;
726 QMainWindow::polish();
727 if (m_setDocCalled) {
728 if (m_aFullScreen->isOn()) {
729 QTimer::singleShot(0,this,SLOT(check_view_fullscreen()));
730 } else if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
731 }
732 }
733}
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h
index 465e352..2f54090 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.h
+++ b/noncore/graphics/opie-eye/gui/mainwindow.h
@@ -1,107 +1,110 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 * No WArranty... 3 * No WArranty...
4 */ 4 */
5 5
6#ifndef PHUNK_MAIN_WINDOW_H 6#ifndef PHUNK_MAIN_WINDOW_H
7#define PHUNK_MAIN_WINDOW_H 7#define PHUNK_MAIN_WINDOW_H
8 8
9#include <opie2/oconfig.h> 9#include <opie2/oconfig.h>
10 10
11#include <qmainwindow.h> 11#include <qmainwindow.h>
12 12
13 13
14 14
15namespace Opie { 15namespace Opie {
16namespace Ui{ 16namespace Ui{
17 class OWidgetStack; 17 class OWidgetStack;
18} 18}
19namespace Core{ 19namespace Core{
20 class OKeyConfigManager; 20 class OKeyConfigManager;
21} 21}
22} 22}
23 23
24class ImageView; 24class ImageView;
25class ImageWidget; 25class ImageWidget;
26class PIconView; 26class PIconView;
27class imageinfo; 27class imageinfo;
28class QMenuBar; 28class QMenuBar;
29class QToolBar; 29class QToolBar;
30class QPopupMenu; 30class QPopupMenu;
31class QAction; 31class QAction;
32class QActionGroup; 32class QActionGroup;
33class StorageInfo; 33class StorageInfo;
34 34
35class PMainWindow : public QMainWindow { 35class PMainWindow : public QMainWindow {
36 Q_OBJECT 36 Q_OBJECT
37 enum Views { IconView, ImageInfo, ImageDisplay }; 37 enum Views { IconView, ImageInfo, ImageDisplay };
38public: 38public:
39 static QString appName() { return QString::fromLatin1("opie-eye" ); } 39 static QString appName() { return QString::fromLatin1("opie-eye" ); }
40 PMainWindow(QWidget*, const char*, WFlags ); 40 PMainWindow(QWidget*, const char*, WFlags );
41 ~PMainWindow(); 41 ~PMainWindow();
42 42
43signals: 43signals:
44 void configChanged(); 44 void configChanged();
45 void changeDir( const QString& ); 45 void changeDir( const QString& );
46 void changeListMode(int); 46 void changeListMode(int);
47 47
48public slots: 48public slots:
49 void slotShowInfo( const QString& inf ); 49 void slotShowInfo( const QString& inf );
50 void slotDisplay( const QString& inf ); 50 void slotDisplay( const QString& inf );
51 void slotReturn(); 51 void slotReturn();
52 void slotRotateToggled(bool); 52 void slotRotateToggled(bool);
53 void slotScaleToggled(bool); 53 void slotScaleToggled(bool);
54 void slotZoomerToggled(bool); 54 void slotZoomerToggled(bool);
55 void slotToggleZoomer(); 55 void slotToggleZoomer();
56 void slotToggleAutorotate(); 56 void slotToggleAutorotate();
57 void slotToggleAutoscale(); 57 void slotToggleAutoscale();
58 void setDocument( const QString& ); 58 void setDocument( const QString& );
59 virtual void slotToggleFullScreen(); 59 virtual void slotToggleFullScreen();
60 virtual void slotFullScreenToggled(bool); 60 virtual void slotFullScreenToggled(bool);
61 virtual void polish();
61 62
62protected slots: 63protected slots:
63 void raiseIconView(); 64 void raiseIconView();
64 void closeEvent( QCloseEvent* ); 65 void closeEvent( QCloseEvent* );
65 void showToolbar(bool); 66 void showToolbar(bool);
66 void listviewselected(QAction*); 67 void listviewselected(QAction*);
67 void slotFullScreenButton(bool); 68 void slotFullScreenButton(bool);
68 void check_view_fullscreen(); 69 void check_view_fullscreen();
69 70
70private: 71private:
71 template<class T> void initT( const char* name, T**, int ); 72 template<class T> void initT( const char* name, T**, int );
72 void initInfo(); 73 void initInfo();
73 void initDisp(); 74 void initDisp();
74 void setupViewWindow(bool full, bool forceDisplay); 75 void setupViewWindow(bool full, bool forceDisplay);
75 76
76private: 77private:
77 Opie::Core::OConfig *m_cfg; 78 Opie::Core::OConfig *m_cfg;
78 Opie::Ui::OWidgetStack *m_stack; 79 Opie::Ui::OWidgetStack *m_stack;
79 PIconView* m_view; 80 PIconView* m_view;
80 imageinfo *m_info; 81 imageinfo *m_info;
81 ImageView *m_disp; 82 ImageView *m_disp;
82 bool autoSave; 83 bool autoSave;
84 bool m_setDocCalled:1;
85 bool m_polishDone:1;
83 QToolButton*fsButton; 86 QToolButton*fsButton;
84 QToolBar *toolBar; 87 QToolBar *toolBar;
85 QPopupMenu *fileMenu,*dispMenu,*fsMenu,*listviewMenu,*settingsMenu; 88 QPopupMenu *fileMenu,*dispMenu,*fsMenu,*listviewMenu,*settingsMenu;
86 QAction*m_aShowInfo,*m_aBeam,*m_aTrash,*m_aViewfile,*m_aDirUp,*m_aStartSlide; 89 QAction*m_aShowInfo,*m_aBeam,*m_aTrash,*m_aViewfile,*m_aDirUp,*m_aStartSlide;
87 QAction*m_aHideToolbar,*m_aSetup,*m_aDirName,*m_aDirShort,*m_aDirLong; 90 QAction*m_aHideToolbar,*m_aSetup,*m_aDirName,*m_aDirShort,*m_aDirLong;
88 QActionGroup *m_gListViewMode,*m_gDisplayType,*m_gPrevNext,*m_hGroup; 91 QActionGroup *m_gListViewMode,*m_gDisplayType,*m_gPrevNext,*m_hGroup;
89 QAction *m_aNext,*m_aPrevious,*m_aFullScreen; 92 QAction *m_aNext,*m_aPrevious,*m_aFullScreen;
90 QAction *m_aAutoRotate,*m_aUnscaled,*m_aZoomer; 93 QAction *m_aAutoRotate,*m_aUnscaled,*m_aZoomer;
91 94
92 /* init funs */ 95 /* init funs */
93 void readConfig(); 96 void readConfig();
94 void setupActions(); 97 void setupActions();
95 void setupToolbar(); 98 void setupToolbar();
96 void setupMenu(); 99 void setupMenu();
97 /* for the device submenu - ToDo: Merge with the special button */ 100 /* for the device submenu - ToDo: Merge with the special button */
98 StorageInfo *m_storage; 101 StorageInfo *m_storage;
99 QMap<QString, QString> m_dev; 102 QMap<QString, QString> m_dev;
100 103
101private slots: 104private slots:
102 void slotConfig(); 105 void slotConfig();
103 void slotSelectDir(int); 106 void slotSelectDir(int);
104 void dirChanged(); 107 void dirChanged();
105}; 108};
106 109
107#endif 110#endif
diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp
index f5c711a..8bcf01d 100644
--- a/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp
+++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp
@@ -1,188 +1,201 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 */ 3 */
4 4
5#include "doc_lister.h" 5#include "doc_lister.h"
6 6
7#include <lib/slavemaster.h> 7#include <lib/slavemaster.h>
8 8
9/* OPIE */ 9/* OPIE */
10#include <opie2/odebug.h> 10#include <opie2/odebug.h>
11#include <qpe/config.h> 11#include <qpe/config.h>
12#include <qpe/qpeapplication.h> 12#include <qpe/qpeapplication.h>
13#include <qpe/applnk.h> 13#include <qpe/applnk.h>
14#include <opie2/oglobal.h>
14 15
15#include <qtopia/private/categories.h> 16#include <qtopia/private/categories.h>
16#include <qtopia/categoryselect.h> 17#include <qtopia/categoryselect.h>
17 18
18using namespace Opie::Core; 19using namespace Opie::Core;
19 20
20/* QT */ 21/* QT */
21#include <qdir.h> 22#include <qdir.h>
22#include <qfileinfo.h> 23#include <qfileinfo.h>
24#include <qtopia/qcopenvelope_qws.h>
23 25
24Doc_DirLister::Doc_DirLister() 26Doc_DirLister::Doc_DirLister()
25 : PDirLister( "doc_dir_lister" ) 27 : PDirLister( "doc_dir_lister" )
26{ 28{
27 /* connect the signals */ 29 /* connect the signals */
28 m_catFilter = 0; 30 m_catFilter = 0;
29 SlaveMaster* master = SlaveMaster::self(); 31 SlaveMaster* master = SlaveMaster::self();
30 connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) ); 32 connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) );
31 connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) ); 33 connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) );
32 connect( master, SIGNAL(sig_thumbInfo(const QString&, const QString&)), 34 connect( master, SIGNAL(sig_thumbInfo(const QString&, const QString&)),
33 this, SLOT(slotThumbInfo(const QString&, const QString&)) ); 35 this, SLOT(slotThumbInfo(const QString&, const QString&)) );
34 connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), 36 connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)),
35 this, SLOT(slotFullInfo(const QString&, const QString&)) ); 37 this, SLOT(slotFullInfo(const QString&, const QString&)) );
36 connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)), 38 connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)),
37 this, SLOT(slotThumbNail(const QString&, const QPixmap&)) ); 39 this, SLOT(slotThumbNail(const QString&, const QPixmap&)) );
38
39 m_namemap.clear();
40 m_filemap.clear();
41 m_docreads = false; 40 m_docreads = false;
41 syschannel = new QCopChannel("QPE/System", this);
42 connect(syschannel, SIGNAL(received(const QCString&,const QByteArray&)),
43 this, SLOT(systemMsg(const QCString&,const QByteArray&)) );
44}
45
46Doc_DirLister::~Doc_DirLister()
47{
42} 48}
43 49
44QString Doc_DirLister::defaultPath()const { 50QString Doc_DirLister::defaultPath()const {
45 return QString::null; 51 return QString::null;
46} 52}
47 53
48bool Doc_DirLister::matchCat(const AppLnk* app) 54bool Doc_DirLister::matchCat(const AppLnk* app)const
49{ 55{
50 if (!app) return false; 56 if (!app) return false;
51 if (m_catFilter==0 || app->categories().contains(m_catFilter) || m_catFilter == -1 && app->categories().count() == 0 ) { 57 if (m_catFilter==0 || app->categories().contains(m_catFilter) || m_catFilter == -1 && app->categories().count() == 0 ) {
52 return true; 58 return true;
53 } 59 }
54 return false; 60 return false;
55} 61}
56 62
57QString Doc_DirLister::setStartPath(const QString&) { 63QString Doc_DirLister::setStartPath(const QString&) {
58 static const QString Mtype_str("image/jpeg;image/gif;image/bmp;image/png"); 64 static const QString Mtype_str("image/jpeg;image/gif;image/bmp;image/png");
59 if (m_namemap.isEmpty()) { 65 if (!m_docreads) {
60 if (!m_docreads) { 66 Global::findDocuments(&m_ds,Mtype_str);
61 Global::findDocuments(&m_ds,Mtype_str); 67 m_docreads = true;
62 m_docreads = true;
63 }
64 QListIterator<DocLnk> dit(m_ds.children());
65 for( ; dit.current(); ++dit) {
66 if (!matchCat((*dit))) continue;
67 m_namemap[(*dit)->name()]=(*dit)->file();
68 m_filemap[(*dit)->file()]=(*dit)->name();
69 }
70 } 68 }
71 return QString::null; 69 return QString::null;
72} 70}
73 71
74QString Doc_DirLister::currentPath()const { 72QString Doc_DirLister::currentPath()const
75 return QString::null; 73{
74 return QString::null;
76} 75}
77 76
78 77
79QStringList Doc_DirLister::folders()const { 78QStringList Doc_DirLister::folders()const {
80 return QStringList(); 79 return QStringList();
81} 80}
82 81
83QStringList Doc_DirLister::files()const { 82QStringList Doc_DirLister::files()const {
84 QStringList out; 83 QStringList out;
85 QMap<QString,QString>::ConstIterator it; 84 QListIterator<DocLnk> dit(m_ds.children());
86 for (it = m_namemap.begin();it != m_namemap.end();++it) { 85 for( ; dit.current(); ++dit) {
87 out.append(it.key()); 86 if (!matchCat((*dit))) continue;
87 QString s = (*dit)->name();
88 s+=char(0);
89 s+=(*dit)->file();
90 out.append(s);
88 } 91 }
89 return out; 92 return out;
90} 93}
91 94
92void Doc_DirLister::deleteImage( const QString& ) 95void Doc_DirLister::deleteImage( const QString& )
93{ 96{
94} 97}
95 98
96void Doc_DirLister::thumbNail( const QString& str, int w, int h) { 99void Doc_DirLister::thumbNail( const QString& str, int w, int h)
97 if (m_namemap.find(str)==m_namemap.end()) { 100{
98 return; 101 SlaveMaster::self()->thumbNail( str, w, h );
99 }
100 QString fname = m_namemap[str];
101 SlaveMaster::self()->thumbNail( fname, w, h );
102} 102}
103 103
104QImage Doc_DirLister::image( const QString& str, Factor f, int m) { 104QImage Doc_DirLister::image( const QString& str, Factor f, int m)
105 if (m_namemap.find(str)==m_namemap.end()) { 105{
106 return QImage(); 106 return SlaveMaster::self()->image(str, f, m );
107 }
108 QString fname = m_namemap[str];
109 return SlaveMaster::self()->image( fname, f, m );
110} 107}
111 108
112void Doc_DirLister::imageInfo( const QString& str) { 109void Doc_DirLister::imageInfo( const QString& str) {
113 if (m_namemap.find(str)==m_namemap.end()) { 110 SlaveMaster::self()->thumbInfo( str );
114 return;
115 }
116 QString fname = m_namemap[str];
117 SlaveMaster::self()->thumbInfo( fname );
118} 111}
119 112
120void Doc_DirLister::fullImageInfo( const QString& str) { 113void Doc_DirLister::fullImageInfo( const QString& str) {
121 if (m_namemap.find(str)==m_namemap.end()) { 114 SlaveMaster::self()->imageInfo(str);
122 return;
123 }
124 QString fname = m_namemap[str];
125 SlaveMaster::self()->imageInfo( fname );
126} 115}
127 116
128void Doc_DirLister::slotFullInfo(const QString&f, const QString&t) 117void Doc_DirLister::slotFullInfo(const QString&f, const QString&t)
129{ 118{
130 if (m_filemap.find(f)==m_filemap.end()) { 119 emit sig_fullInfo(f, t);
131 return;
132 }
133 QString name = m_filemap[f];
134 emit sig_fullInfo(name, t);
135} 120}
136 121
137void Doc_DirLister::slotThumbInfo(const QString&f, const QString&t) 122void Doc_DirLister::slotThumbInfo(const QString&f, const QString&t)
138{ 123{
139 if (m_filemap.find(f)==m_filemap.end()) { 124 emit sig_thumbInfo(f, t);
140 return;
141 }
142 QString name = m_filemap[f];
143 emit sig_thumbInfo(name, t);
144} 125}
145 126
146void Doc_DirLister::slotThumbNail(const QString&f, const QPixmap&p) 127void Doc_DirLister::slotThumbNail(const QString&f, const QPixmap&p)
147{ 128{
148 if (m_filemap.find(f)==m_filemap.end()) { 129 emit sig_thumbNail(f, p);
149 return;
150 }
151 QString name = m_filemap[f];
152 emit sig_thumbNail(name, p);
153} 130}
154 131
155QString Doc_DirLister::nameToFname(const QString&name)const 132QString Doc_DirLister::nameToFname(const QString&name)const
156{ 133{
157 if (m_namemap.find(name)==m_namemap.end()) { 134 return name;
158 return QString::null;
159 }
160 return m_namemap[name];
161} 135}
162 136
163QString Doc_DirLister::dirUp( const QString& p ) const{ 137QString Doc_DirLister::dirUp( const QString& p ) const{
164 return p; 138 return p;
165} 139}
166 140
167QWidget* Doc_DirLister::widget(QWidget*parent) 141QWidget* Doc_DirLister::widget(QWidget*parent)
168{ 142{
169 CategorySelect * catmb = new CategorySelect(parent); 143 CategorySelect * catmb = new CategorySelect(parent);
170 Categories cats( 0 ); 144 Categories cats( 0 );
171 cats.load( categoryFileName() ); 145 cats.load( categoryFileName() );
172 QArray<int> vl( 0 ); 146 QArray<int> vl( 0 );
173 catmb->setCategories( vl, "Document View", // No tr 147 catmb->setCategories( vl, "Document View", // No tr
174 "Document View" ); 148 "Document View" );
175 catmb->setRemoveCategoryEdit( TRUE ); 149 catmb->setRemoveCategoryEdit( TRUE );
176 catmb->setAllCategories( TRUE ); 150 catmb->setAllCategories( TRUE );
177 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); 151 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
178 catmb->setCurrentCategory(-2); 152 catmb->setCurrentCategory(-2);
179 return catmb; 153 return catmb;
180} 154}
181 155
182void Doc_DirLister::showCategory(int which) 156void Doc_DirLister::showCategory(int which)
183{ 157{
184 m_catFilter = which==-2?0:which; 158 m_catFilter = which==-2?0:which;
185 m_namemap.clear();
186 setStartPath(""); 159 setStartPath("");
187 emit sig_reloadDir(); 160 emit sig_reloadDir();
188} 161}
162
163void Doc_DirLister::systemMsg(const QCString &msg, const QByteArray &data)
164{
165 if ( msg != "linkChanged(QString)"||!m_docreads) {
166 return;
167 }
168 QString link;
169 QDataStream stream( data, IO_ReadOnly );
170 stream >> link;
171 odebug << "Doc_DirLister systemMsg -> linkchanged( " << link << " )" << oendl;
172 if ( link.isNull() || OGlobal::isAppLnkFileName(link) ) {
173 return;
174 }
175 QListIterator<DocLnk> dit(m_ds.children());
176 bool must_reload = false;
177 bool found = false;
178 while ( dit.current() ) {
179 DocLnk *doc = dit.current();
180 ++dit;
181 if (doc->linkFile() == link) {
182 found = true;
183 DocLnk* dl = new DocLnk(link);
184 if (dl->fileKnown()) {
185 // changing
186 m_ds.add(dl);
187 } else {
188 delete dl;
189 }
190 if (matchCat(doc) || matchCat(dl)) {
191 must_reload = true;
192 }
193 m_ds.remove( doc ); // remove old link from docLnkSet
194 delete doc;
195 }
196 }
197 if (must_reload) {
198 setStartPath("");
199 emit sig_reloadDir();
200 }
201}
diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.h b/noncore/graphics/opie-eye/impl/doc/doc_lister.h
index 403241c..3f8825f 100644
--- a/noncore/graphics/opie-eye/impl/doc/doc_lister.h
+++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.h
@@ -1,53 +1,55 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 */ 3 */
4 4
5#ifndef DOC_LISTER_INTERFACE_LISTER_H 5#ifndef DOC_LISTER_INTERFACE_LISTER_H
6#define DOC_LISTER_INTERFACE_LISTER_H 6#define DOC_LISTER_INTERFACE_LISTER_H
7 7
8#include <iface/dirlister.h> 8#include <iface/dirlister.h>
9 9
10#include <qpe/applnk.h> 10#include <qpe/applnk.h>
11 11
12#include <qstring.h> 12#include <qstring.h>
13#include <qmap.h> 13#include <qmap.h>
14 14
15class Config; 15class Config;
16class AppLnk; 16class AppLnk;
17class QCopChannel;
17 18
18class Doc_DirLister : public PDirLister { 19class Doc_DirLister : public PDirLister {
19 Q_OBJECT 20 Q_OBJECT
20public: 21public:
21 Doc_DirLister(); 22 Doc_DirLister();
22 virtual ~Doc_DirLister(){} 23 virtual ~Doc_DirLister();
23 24
24 QString defaultPath()const; 25 QString defaultPath()const;
25 QString setStartPath( const QString& ); 26 QString setStartPath( const QString& );
26 QString currentPath()const; 27 QString currentPath()const;
27 QStringList folders()const; 28 QStringList folders()const;
28 QStringList files()const; 29 QStringList files()const;
29 30
30 void deleteImage( const QString& ); 31 void deleteImage( const QString& );
31 void thumbNail( const QString&, int, int ); 32 void thumbNail( const QString&, int, int );
32 QImage image( const QString&, Factor, int ); 33 QImage image( const QString&, Factor, int );
33 void imageInfo( const QString& ); 34 void imageInfo( const QString& );
34 void fullImageInfo( const QString& ); 35 void fullImageInfo( const QString& );
35 virtual QString nameToFname(const QString&name)const; 36 virtual QString nameToFname(const QString&name)const;
36 QString dirUp( const QString& )const; 37 QString dirUp( const QString& )const;
37 QWidget* widget(QWidget*parent); 38 QWidget* widget(QWidget*parent);
38 39
39private: 40private:
40 QMap<QString,QString> m_namemap,m_filemap;
41 int m_catFilter; 41 int m_catFilter;
42 bool matchCat(const AppLnk* app); 42 bool matchCat(const AppLnk* app)const;
43 bool m_docreads; 43 bool m_docreads;
44 DocLnkSet m_ds; 44 DocLnkSet m_ds;
45 45
46protected slots: 46protected slots:
47 virtual void slotFullInfo(const QString&, const QString&); 47 virtual void slotFullInfo(const QString&, const QString&);
48 virtual void slotThumbInfo(const QString&, const QString&); 48 virtual void slotThumbInfo(const QString&, const QString&);
49 virtual void slotThumbNail(const QString&, const QPixmap&); 49 virtual void slotThumbNail(const QString&, const QPixmap&);
50 virtual void showCategory(int); 50 virtual void showCategory(int);
51 void systemMsg(const QCString &, const QByteArray &);
52 QCopChannel *syschannel;
51}; 53};
52 54
53#endif 55#endif