summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp10
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.h1
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp2
-rw-r--r--noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp14
-rw-r--r--noncore/graphics/opie-eye/impl/dir/dir_dirview.h2
-rw-r--r--noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp32
-rw-r--r--noncore/graphics/opie-eye/impl/dir/dir_lister.cpp53
-rw-r--r--noncore/graphics/opie-eye/impl/dir/dir_lister.h12
8 files changed, 96 insertions, 30 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index 7c8c88d..eafff1d 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -1,758 +1,764 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 * No WArranty... 3 * No WArranty...
4 */ 4 */
5 5
6#include "iconview.h" 6#include "iconview.h"
7 7
8#include <lib/imagecache.h> 8#include <lib/imagecache.h>
9#include <gui/imageinfoui.h> 9#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* _emptyPix = 0; 44 static QPixmap* _emptyPix = 0;
45 class IconViewItem : public QIconViewItem { 45 class IconViewItem : public QIconViewItem {
46 public: 46 public:
47 IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); 47 IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false);
48 QPixmap* pixmap()const; 48 QPixmap* pixmap()const;
49 QString path()const { return m_path; } 49 QString path()const { return m_path; }
50 bool isDir()const { return m_isDir; } 50 bool isDir()const { return m_isDir; }
51 void setText( const QString& ); 51 void setText( const QString& );
52 bool textOnly()const{return m_textOnly;} 52 bool textOnly()const{return m_textOnly;}
53 void setTextOnly(bool how){m_textOnly=how;} 53 void setTextOnly(bool how){m_textOnly=how;}
54 /* just for starting recalc of item rect! */ 54 /* just for starting recalc of item rect! */
55 virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); 55 virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE );
56 /* just for starting recalc of item rect! */ 56 /* just for starting recalc of item rect! */
57 virtual void setPixmap( const QPixmap & icon); 57 virtual void setPixmap( const QPixmap & icon);
58 58
59 protected: 59 protected:
60 mutable QPixmap* m_pix; 60 mutable QPixmap* m_pix;
61 61
62 private: 62 private:
63 QString m_path; 63 QString m_path;
64 bool m_isDir : 1; 64 bool m_isDir : 1;
65 bool m_noInfo :1; 65 bool m_noInfo :1;
66 bool m_textOnly:1; 66 bool m_textOnly:1;
67 bool m_NameOnly:1; 67 bool m_NameOnly:1;
68 bool m_Pixset:1; 68 bool m_Pixset:1;
69 }; 69 };
70 class TextViewItem : public IconViewItem { 70 class TextViewItem : public IconViewItem {
71 TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); 71 TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false );
72 QPixmap *pixmap()const; 72 QPixmap *pixmap()const;
73 void setText( const QString& ); 73 void setText( const QString& );
74 }; 74 };
75 class ThumbViewItem : public IconViewItem { 75 class ThumbViewItem : public IconViewItem {
76 ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); 76 ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false );
77 QPixmap *pixmap()const; 77 QPixmap *pixmap()const;
78 void setText( const QString& ); 78 void setText( const QString& );
79 }; 79 };
80 80
81 81
82/* 82/*
83 * If we request an Image or String 83 * If we request an Image or String
84 * we add it to the map 84 * we add it to the map
85 */ 85 */
86 static QMap<QString, IconViewItem*> g_stringInf; 86 static QMap<QString, IconViewItem*> g_stringInf;
87 static QMap<QString, IconViewItem*> g_stringPix; 87 static QMap<QString, IconViewItem*> g_stringPix;
88 88
89 IconViewItem::IconViewItem( QIconView* view,const QString& path, 89 IconViewItem::IconViewItem( QIconView* view,const QString& path,
90 const QString& name, bool isDir ) 90 const QString& name, bool isDir )
91 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), 91 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ),
92 m_noInfo( false ),m_textOnly(false),m_Pixset(false) 92 m_noInfo( false ),m_textOnly(false),m_Pixset(false)
93 { 93 {
94 if ( isDir && !_dirPix ) 94 if ( isDir && !_dirPix )
95 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); 95 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser"));
96 else if ( !isDir && !_unkPix ) 96 else if ( !isDir && !_unkPix )
97 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); 97 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) );
98 } 98 }
99 99
100 inline void IconViewItem::setPixmap( const QPixmap & , bool, bool ) 100 inline void IconViewItem::setPixmap( const QPixmap & , bool, bool )
101 { 101 {
102 m_Pixset = true; 102 m_Pixset = true;
103 calcRect(text()); 103 calcRect(text());
104 } 104 }
105 inline void IconViewItem::setPixmap( const QPixmap & ) 105 inline void IconViewItem::setPixmap( const QPixmap & )
106 { 106 {
107 m_Pixset = true; 107 m_Pixset = true;
108 calcRect(text()); 108 calcRect(text());
109 } 109 }
110 110
111 inline QPixmap* IconViewItem::pixmap()const { 111 inline QPixmap* IconViewItem::pixmap()const {
112// owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y() 112// owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y()
113// << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX() 113// << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX()
114// << " " << iconView()->contentsY() << oendl; 114// << " " << iconView()->contentsY() << oendl;
115 115
116 if (textOnly()&&!m_isDir) { 116 if (textOnly()&&!m_isDir) {
117 if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); 117 if (!_emptyPix) _emptyPix = new QPixmap(0,0,1);
118 return _emptyPix; 118 return _emptyPix;
119 } 119 }
120 if ( m_isDir ) 120 if ( m_isDir )
121 return _dirPix; 121 return _dirPix;
122 else{ 122 else{
123 if (!m_noInfo && !g_stringInf.contains( m_path ) ) { 123 if (!m_noInfo && !g_stringInf.contains( m_path ) ) {
124 currentView()->dirLister()->imageInfo( m_path ); 124 currentView()->dirLister()->imageInfo( m_path );
125 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); 125 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this));
126 } 126 }
127 127
128 m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); 128 m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 );
129 if (!m_pix && !g_stringPix.contains( m_path )) { 129 if (!m_pix && !g_stringPix.contains( m_path )) {
130 currentView()->dirLister()->thumbNail( m_path, 64, 64 ); 130 currentView()->dirLister()->thumbNail( m_path, 64, 64 );
131 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); 131 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
132 } 132 }
133 return m_pix ? m_pix : _unkPix; 133 return m_pix ? m_pix : _unkPix;
134 } 134 }
135 } 135 }
136 inline void IconViewItem::setText( const QString& str ) { 136 inline void IconViewItem::setText( const QString& str ) {
137 QString text = QIconViewItem::text()+"\n"+str; 137 QString text = QIconViewItem::text()+"\n"+str;
138 m_noInfo = true; 138 m_noInfo = true;
139 QIconViewItem::setText( text ); 139 QIconViewItem::setText( text );
140 } 140 }
141} 141}
142 142
143 143
144/* 144/*
145 * Set up the GUI.. initialize the slave set up gui 145 * Set up the GUI.. initialize the slave set up gui
146 * and also load a dir 146 * and also load a dir
147 */ 147 */
148PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) 148PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg )
149 : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) 149 : QVBox( wid ), m_cfg( cfg ), m_updatet( false )
150{ 150{
151 { 151 {
152 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 152 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
153 } 153 }
154 m_path = QDir::homeDirPath(); 154 m_path = QDir::homeDirPath();
155 m_mode = 0; 155 m_mode = 0;
156 m_internalReset = false;
156 157
157 QHBox *hbox = new QHBox( this ); 158 QHBox *hbox = new QHBox( this );
158 QLabel* lbl = new QLabel( hbox ); 159 QLabel* lbl = new QLabel( hbox );
159 lbl->setText( tr("View as" ) ); 160 lbl->setText( tr("View as" ) );
160 161
161 m_views = new QComboBox( hbox, "View As" ); 162 m_views = new QComboBox( hbox, "View As" );
162 163
163 m_view= new QIconView( this ); 164 m_view= new QIconView( this );
164 connect(m_view, SIGNAL(clicked(QIconViewItem*) ), 165 connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
165 this, SLOT(slotClicked(QIconViewItem*)) ); 166 this, SLOT(slotClicked(QIconViewItem*)) );
166 connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), 167 connect(m_view, SIGNAL(returnPressed(QIconViewItem*)),
167 this, SLOT(slotClicked(QIconViewItem*)) ); 168 this, SLOT(slotClicked(QIconViewItem*)) );
168 169
169 m_view->setArrangement( QIconView::LeftToRight ); 170 m_view->setArrangement( QIconView::LeftToRight );
170 171
171 m_mode = m_cfg->readNumEntry("ListViewMode", 1); 172 m_mode = m_cfg->readNumEntry("ListViewMode", 1);
172 QString lastView = m_cfg->readEntry("LastView",""); 173 QString lastView = m_cfg->readEntry("LastView","");
173 174
174 if (m_mode < 1 || m_mode>3) m_mode = 1; 175 if (m_mode < 1 || m_mode>3) m_mode = 1;
175 176
176 m_view->setItemTextPos( QIconView::Right ); 177 m_view->setItemTextPos( QIconView::Right );
177 178
178 calculateGrid(); 179 calculateGrid();
179 180
180 initKeys(); 181 initKeys();
181 182
182 loadViews(); 183 loadViews();
183 int cc=0; 184 int cc=0;
184 for (; cc<m_views->count();++cc) { 185 for (; cc<m_views->count();++cc) {
185 if (m_views->text(cc)==lastView) { 186 if (m_views->text(cc)==lastView) {
186 break; 187 break;
187 } 188 }
188 } 189 }
189 if (cc<m_views->count()) { 190 if (cc<m_views->count()) {
190 m_views->setCurrentItem(cc); 191 m_views->setCurrentItem(cc);
191 slotViewChanged(cc); 192 slotViewChanged(cc);
192 } else { 193 } else {
193 slotViewChanged(m_views->currentItem()); 194 slotViewChanged(m_views->currentItem());
194 } 195 }
195 connect( m_views, SIGNAL(activated(int)), 196 connect( m_views, SIGNAL(activated(int)),
196 this, SLOT(slotViewChanged(int)) ); 197 this, SLOT(slotViewChanged(int)) );
197} 198}
198 199
199/* 200/*
200 * Unref the slave and save the keyboard manager 201 * Unref the slave and save the keyboard manager
201 */ 202 */
202PIconView::~PIconView() { 203PIconView::~PIconView() {
203 { 204 {
204 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 205 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
205 } 206 }
206 m_viewManager->save(); 207 m_viewManager->save();
207 delete m_viewManager; 208 delete m_viewManager;
208} 209}
209 210
210Opie::Core::OKeyConfigManager* PIconView::manager() { 211Opie::Core::OKeyConfigManager* PIconView::manager() {
211 return m_viewManager; 212 return m_viewManager;
212} 213}
213 214
214 215
215/* 216/*
216 * init the KeyBoard Shortcuts 217 * init the KeyBoard Shortcuts
217 * called from the c'tor 218 * called from the c'tor
218 */ 219 */
219void PIconView::initKeys() { 220void PIconView::initKeys() {
220 Opie::Core::OKeyPair::List lst; 221 Opie::Core::OKeyPair::List lst;
221 lst.append( Opie::Core::OKeyPair::upArrowKey() ); 222 lst.append( Opie::Core::OKeyPair::upArrowKey() );
222 lst.append( Opie::Core::OKeyPair::downArrowKey() ); 223 lst.append( Opie::Core::OKeyPair::downArrowKey() );
223 lst.append( Opie::Core::OKeyPair::leftArrowKey() ); 224 lst.append( Opie::Core::OKeyPair::leftArrowKey() );
224 lst.append( Opie::Core::OKeyPair::rightArrowKey() ); 225 lst.append( Opie::Core::OKeyPair::rightArrowKey() );
225 lst.append( Opie::Core::OKeyPair::returnKey() ); 226 lst.append( Opie::Core::OKeyPair::returnKey() );
226 227
227 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", 228 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config",
228 lst, false,this, "keyconfig name" ); 229 lst, false,this, "keyconfig name" );
229 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", 230 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam",
230 Resource::loadPixmap("beam"), BeamItem, 231 Resource::loadPixmap("beam"), BeamItem,
231 Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), 232 Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton),
232 this, SLOT(slotBeam())) ); 233 this, SLOT(slotBeam())) );
233 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", 234 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete",
234 Resource::loadPixmap("trash"), DeleteItem, 235 Resource::loadPixmap("trash"), DeleteItem,
235 Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), 236 Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton),
236 this, SLOT(slotTrash())) ); 237 this, SLOT(slotTrash())) );
237 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", 238 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view",
238 Resource::loadPixmap("1to1"), ViewItem, 239 Resource::loadPixmap("1to1"), ViewItem,
239 Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), 240 Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton),
240 this, SLOT(slotShowImage()))); 241 this, SLOT(slotShowImage())));
241 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", 242 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info",
242 Resource::loadPixmap("DocumentTypeWord"), InfoItem, 243 Resource::loadPixmap("DocumentTypeWord"), InfoItem,
243 Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), 244 Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ),
244 this, SLOT(slotImageInfo()) ) ); 245 this, SLOT(slotImageInfo()) ) );
245 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow", 246 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow",
246 Resource::loadPixmap("1to1"), SlideItem, 247 Resource::loadPixmap("1to1"), SlideItem,
247 Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton), 248 Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton),
248 this, SLOT(slotStartSlide()))); 249 this, SLOT(slotStartSlide())));
249 m_viewManager->load(); 250 m_viewManager->load();
250 m_viewManager->handleWidget( m_view ); 251 m_viewManager->handleWidget( m_view );
251} 252}
252 253
253 254
254/* 255/*
255 * change one dir up 256 * change one dir up
256 */ 257 */
257void PIconView::slotDirUp() 258void PIconView::slotDirUp()
258{ 259{
259 slotChangeDir( currentView()->dirLister()->dirUp( m_path ) ); 260 slotChangeDir( currentView()->dirLister()->dirUp( m_path ) );
260} 261}
261 262
262/* 263/*
263 * change the dir 264 * change the dir
264 */ 265 */
265void PIconView::slotChangeDir(const QString& path) { 266void PIconView::slotChangeDir(const QString& path) {
266 if ( !currentView() ) 267 if ( !currentView() )
267 return; 268 return;
268 269
269 PDirLister *lister = currentView()->dirLister(); 270 PDirLister *lister = currentView()->dirLister();
270 if (!lister ) 271 if (!lister )
271 return; 272 return;
272 273
273 /* 274 /*
274 * Say what we want and take what we get 275 * Say what we want and take what we get
275 */ 276 */
276 lister->setStartPath( path ); 277 lister->setStartPath( path );
277 m_path = lister->currentPath(); 278 m_path = lister->currentPath();
278 279
279 m_view->viewport()->setUpdatesEnabled( false ); 280 m_view->viewport()->setUpdatesEnabled( false );
280 m_view->clear(); 281 m_view->clear();
281 282
282 /* 283 /*
283 * add files and folders 284 * add files and folders
284 */ 285 */
285 addFolders( lister->folders() ); 286 addFolders( lister->folders() );
286 addFiles( lister->files() ); 287 addFiles( lister->files() );
287 m_view->viewport()->setUpdatesEnabled( true ); 288 m_view->viewport()->setUpdatesEnabled( true );
288 289
289 // Also invalidate the cache. We can't cancel the operations anyway 290 // Also invalidate the cache. We can't cancel the operations anyway
290 g_stringPix.clear(); 291 g_stringPix.clear();
291 g_stringInf.clear(); 292 g_stringInf.clear();
292 293
293 // looks ugly 294 // looks ugly
294 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); 295 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
295} 296}
296 297
297/** 298/**
298 * get the current file name 299 * get the current file name
299 * @param isDir see if this is a dir or real file 300 * @param isDir see if this is a dir or real file
300 */ 301 */
301QString PIconView::currentFileName(bool &isDir)const { 302QString PIconView::currentFileName(bool &isDir)const {
302 isDir = false; 303 isDir = false;
303 QIconViewItem* _it = m_view->currentItem(); 304 QIconViewItem* _it = m_view->currentItem();
304 if ( !_it ) 305 if ( !_it )
305 return QString::null; 306 return QString::null;
306 307
307 IconViewItem* it = static_cast<IconViewItem*>( _it ); 308 IconViewItem* it = static_cast<IconViewItem*>( _it );
308 isDir = it->isDir(); 309 isDir = it->isDir();
309 return it->path(); 310 return it->path();
310} 311}
311 312
312QString PIconView::nextFileName(bool &isDir)const 313QString PIconView::nextFileName(bool &isDir)const
313{ 314{
314 isDir = false; 315 isDir = false;
315 QIconViewItem* _it1 = m_view->currentItem(); 316 QIconViewItem* _it1 = m_view->currentItem();
316 if ( !_it1 ) 317 if ( !_it1 )
317 return QString::null; 318 return QString::null;
318 QIconViewItem* _it = _it1->nextItem(); 319 QIconViewItem* _it = _it1->nextItem();
319 if ( !_it ) 320 if ( !_it )
320 return QString::null; 321 return QString::null;
321 IconViewItem* it = static_cast<IconViewItem*>( _it ); 322 IconViewItem* it = static_cast<IconViewItem*>( _it );
322 isDir = it->isDir(); 323 isDir = it->isDir();
323 return it->path(); 324 return it->path();
324} 325}
325 326
326QString PIconView::prevFileName(bool &isDir)const{ 327QString PIconView::prevFileName(bool &isDir)const{
327 isDir = false; 328 isDir = false;
328 QIconViewItem* _it = m_view->currentItem(); 329 QIconViewItem* _it = m_view->currentItem();
329 if ( !_it ) 330 if ( !_it )
330 return QString::null; 331 return QString::null;
331 _it = _it->prevItem(); 332 _it = _it->prevItem();
332 if ( !_it ) 333 if ( !_it )
333 return QString::null; 334 return QString::null;
334 IconViewItem* it = static_cast<IconViewItem*>( _it ); 335 IconViewItem* it = static_cast<IconViewItem*>( _it );
335 isDir = it->isDir(); 336 isDir = it->isDir();
336 return it->path(); 337 return it->path();
337} 338}
338 339
339void PIconView::slotTrash() { 340void PIconView::slotTrash() {
340 bool isDir; 341 bool isDir;
341 QString pa = currentFileName( isDir ); 342 QString pa = currentFileName( isDir );
342 if ( isDir && pa.isEmpty() ) 343 if ( isDir && pa.isEmpty() )
343 return; 344 return;
344 345
345 if (!QPEMessageBox::confirmDelete( this, 346 if (!QPEMessageBox::confirmDelete( this,
346 tr("Delete Image" ), 347 tr("Delete Image" ),
347 tr("the Image %1" ).arg(pa))) 348 tr("the Image %1" ).arg(pa)))
348 return 349 return
349 350
350 351
351 currentView()->dirLister()->deleteImage( pa ); 352 currentView()->dirLister()->deleteImage( pa );
352 delete m_view->currentItem(); 353 delete m_view->currentItem();
353} 354}
354 355
355/* 356/*
356 * see what views are available 357 * see what views are available
357 */ 358 */
358void PIconView::loadViews() { 359void PIconView::loadViews() {
359 ViewMap::Iterator it; 360 ViewMap::Iterator it;
360 ViewMap* map = viewMap(); 361 ViewMap* map = viewMap();
361 for ( it = map->begin(); it != map->end(); ++it ) 362 for ( it = map->begin(); it != map->end(); ++it )
362 m_views->insertItem( it.key() ); 363 m_views->insertItem( it.key() );
363} 364}
364 365
365void PIconView::resetView() { 366void PIconView::resetView() {
367 m_internalReset = true;
366 slotViewChanged(m_views->currentItem()); 368 slotViewChanged(m_views->currentItem());
369 m_internalReset = false;
367} 370}
368 371
369/* 372/*
370 *swicth view reloadDir and connect signals 373 *swicth view reloadDir and connect signals
371 */ 374 */
372void PIconView::slotViewChanged( int i) { 375void PIconView::slotViewChanged( int i) {
373 if (!m_views->count() ) { 376 if (!m_views->count() ) {
374 setCurrentView( 0l); 377 setCurrentView( 0l);
375 return; 378 return;
376 } 379 }
377 380
378 PDirView* cur = currentView(); 381 PDirView* cur = currentView();
379 if (cur) delete cur; 382 if (cur) delete cur;
380 QString str = m_views->text(i); 383 QString str = m_views->text(i);
381 ViewMap* map = viewMap(); 384 ViewMap* map = viewMap();
382 if (!map) { 385 if (!map) {
383 setCurrentView(0l); 386 setCurrentView(0l);
384 return; 387 return;
385 } 388 }
386 389
387 if (map->find(str) == map->end()) { 390 if (map->find(str) == map->end()) {
388 owarn << "Key not found" << oendl; 391 owarn << "Key not found" << oendl;
389 setCurrentView(0l); 392 setCurrentView(0l);
390 return; 393 return;
391 } 394 }
392 395
393 m_cfg->writeEntry("LastView",str); 396 m_cfg->writeEntry("LastView",str);
394 m_cfg->write(); 397 m_cfg->write();
395 cur = (*(*map)[str])(*m_cfg); 398 cur = (*(*map)[str])(*m_cfg);
396 setCurrentView( cur ); 399 setCurrentView( cur );
397 400
398 /* connect to the signals of the lister */ 401 /* connect to the signals of the lister */
399 PDirLister* lis = cur->dirLister(); 402 PDirLister* lis = cur->dirLister();
400 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), 403 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )),
401 this, SLOT( slotThumbInfo(const QString&, const QString&))); 404 this, SLOT( slotThumbInfo(const QString&, const QString&)));
402 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), 405 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
403 this, SLOT(slotThumbNail(const QString&, const QPixmap&))); 406 this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
404 connect(lis, SIGNAL(sig_start()), 407 connect(lis, SIGNAL(sig_start()),
405 this, SLOT(slotStart())); 408 this, SLOT(slotStart()));
406 connect(lis, SIGNAL(sig_end()) , 409 connect(lis, SIGNAL(sig_end()) ,
407 this, SLOT(slotEnd()) ); 410 this, SLOT(slotEnd()) );
408 411
409 412
410 /* reload now with default Path*/ 413 /* reload now with default Path
411 m_path = lis->defaultPath(); 414 * but only if it isn't a reset like from setupdlg
415 */
416 if (!m_internalReset)
417 m_path = lis->defaultPath();
412 QTimer::singleShot( 0, this, SLOT(slotReloadDir())); 418 QTimer::singleShot( 0, this, SLOT(slotReloadDir()));
413} 419}
414 420
415 421
416void PIconView::slotReloadDir() { 422void PIconView::slotReloadDir() {
417 slotChangeDir( m_path ); 423 slotChangeDir( m_path );
418} 424}
419 425
420 426
421/* 427/*
422 * add files and folders 428 * add files and folders
423 */ 429 */
424void PIconView::addFolders( const QStringList& lst) { 430void PIconView::addFolders( const QStringList& lst) {
425 QStringList::ConstIterator it; 431 QStringList::ConstIterator it;
426 IconViewItem * _iv; 432 IconViewItem * _iv;
427 433
428 for(it=lst.begin(); it != lst.end(); ++it ) { 434 for(it=lst.begin(); it != lst.end(); ++it ) {
429 _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); 435 _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true );
430 if (m_mode==3) _iv->setTextOnly(true); 436 if (m_mode==3) _iv->setTextOnly(true);
431 } 437 }
432} 438}
433 439
434void PIconView::addFiles( const QStringList& lst) { 440void PIconView::addFiles( const QStringList& lst) {
435 QStringList::ConstIterator it; 441 QStringList::ConstIterator it;
436 IconViewItem * _iv; 442 IconViewItem * _iv;
437 QPixmap*m_pix = 0; 443 QPixmap*m_pix = 0;
438 QString pre = ""; 444 QString pre = "";
439 if (!m_path.isEmpty()) { 445 if (!m_path.isEmpty()) {
440 pre = m_path+"/"; 446 pre = m_path+"/";
441 } 447 }
442 for (it=lst.begin(); it!= lst.end(); ++it ) { 448 for (it=lst.begin(); it!= lst.end(); ++it ) {
443 m_pix = PPixmapCache::self()->cachedImage( pre+(*it), 64, 64 ); 449 m_pix = PPixmapCache::self()->cachedImage( pre+(*it), 64, 64 );
444 _iv = new IconViewItem( m_view, pre+(*it), (*it) ); 450 _iv = new IconViewItem( m_view, pre+(*it), (*it) );
445 if (m_mode==3) { 451 if (m_mode==3) {
446 _iv->setTextOnly(true); 452 _iv->setTextOnly(true);
447 _iv->setPixmap(QPixmap()); 453 _iv->setPixmap(QPixmap());
448 454
449 455
450 456
451 } else { 457 } else {
452 if (m_pix) _iv->setPixmap(*m_pix); 458 if (m_pix) _iv->setPixmap(*m_pix);
453 } 459 }
454 } 460 }
455 461
456} 462}
457 463
458/* 464/*
459 * user clicked on the item. Change dir or view 465 * user clicked on the item. Change dir or view
460 */ 466 */
461void PIconView::slotClicked(QIconViewItem* _it) { 467void PIconView::slotClicked(QIconViewItem* _it) {
462 if(!_it ) 468 if(!_it )
463 return; 469 return;
464 470
465 IconViewItem* it = static_cast<IconViewItem*>(_it); 471 IconViewItem* it = static_cast<IconViewItem*>(_it);
466 if( it->isDir() ) 472 if( it->isDir() )
467 slotChangeDir( it->path() ); 473 slotChangeDir( it->path() );
468 else // view image 474 else // view image
469 slotShowImage(); 475 slotShowImage();
470} 476}
471 477
472/* 478/*
473 * Return was pressed. which is triggered by the keydown 479 * Return was pressed. which is triggered by the keydown
474 * handler. The problem is that the key up will be handled 480 * handler. The problem is that the key up will be handled
475 * by the ImageDisplayer and goes to the next image 481 * by the ImageDisplayer and goes to the next image
476 */ 482 */
477void PIconView::slotRetrun( QIconViewItem *_it ) { 483void PIconView::slotRetrun( QIconViewItem *_it ) {
478 if(!_it ) 484 if(!_it )
479 return; 485 return;
480 486
481 IconViewItem* it = static_cast<IconViewItem*>(_it); 487 IconViewItem* it = static_cast<IconViewItem*>(_it);
482 if( it->isDir() ) 488 if( it->isDir() )
483 slotChangeDir( it->path() ); 489 slotChangeDir( it->path() );
484 else 490 else
485 QTimer::singleShot(0, this, SLOT(slotShowImage()) ); 491 QTimer::singleShot(0, this, SLOT(slotShowImage()) );
486} 492}
487 493
488/* 494/*
489 * got thumb info add to the cache if items is visible 495 * got thumb info add to the cache if items is visible
490 * we later need update after processing of slave is done 496 * we later need update after processing of slave is done
491 */ 497 */
492void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { 498void PIconView::slotThumbInfo( const QString& _path, const QString& str ) {
493 IconViewItem* item = g_stringInf[_path]; 499 IconViewItem* item = g_stringInf[_path];
494 if (!item ) 500 if (!item )
495 return; 501 return;
496 502
497 if (m_mode == 2) { 503 if (m_mode == 2) {
498 return; 504 return;
499 } 505 }
500 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), 506 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
501 m_view->contentsWidth(), m_view->contentsHeight() ) ) ) 507 m_view->contentsWidth(), m_view->contentsHeight() ) ) )
502 m_updatet = true; 508 m_updatet = true;
503 509
504 item->setText( str ); 510 item->setText( str );
505 g_stringInf.remove( _path ); 511 g_stringInf.remove( _path );
506} 512}
507 513
508/* 514/*
509 * got thumbnail and see if it is visible so we need to update later 515 * got thumbnail and see if it is visible so we need to update later
510 */ 516 */
511void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { 517void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) {
512 IconViewItem* item = g_stringPix[_path]; 518 IconViewItem* item = g_stringPix[_path];
513 if (!item ) 519 if (!item )
514 return; 520 return;
515 521
516 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), 522 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
517 m_view->contentsWidth(), m_view->contentsHeight() ) ) ) 523 m_view->contentsWidth(), m_view->contentsHeight() ) ) )
518 m_updatet = true; 524 m_updatet = true;
519 525
520 if (pix.width()>0) { 526 if (pix.width()>0) {
521 PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); 527 PPixmapCache::self()->insertImage( _path, pix, 64, 64 );
522 item->setPixmap(pix,true); 528 item->setPixmap(pix,true);
523 } else { 529 } else {
524 PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), 64, 64 ); 530 PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), 64, 64 );
525 } 531 }
526 g_stringPix.remove( _path ); 532 g_stringPix.remove( _path );
527} 533}
528 534
529 535
530/* 536/*
531 * FIXME rename 537 * FIXME rename
532 */ 538 */
533void PIconView::slotRename() { 539void PIconView::slotRename() {
534 540
535} 541}
536 542
537 543
538/* 544/*
539 * BEAM the current file 545 * BEAM the current file
540 */ 546 */
541void PIconView::slotBeam() { 547void PIconView::slotBeam() {
542 bool isDir; 548 bool isDir;
543 QString pa = currentFileName( isDir ); 549 QString pa = currentFileName( isDir );
544 if ( isDir && pa.isEmpty() ) 550 if ( isDir && pa.isEmpty() )
545 return; 551 return;
546 552
547 Ir* ir = new Ir( this ); 553 Ir* ir = new Ir( this );
548 connect( ir, SIGNAL(done(Ir*)), 554 connect( ir, SIGNAL(done(Ir*)),
549 this, SLOT(slotBeamDone(Ir*))); 555 this, SLOT(slotBeamDone(Ir*)));
550 ir->send(pa, tr( "Image" ) ); 556 ir->send(pa, tr( "Image" ) );
551} 557}
552 558
553/* 559/*
554 * BEAM done clean up 560 * BEAM done clean up
555 */ 561 */
556void PIconView::slotBeamDone( Ir* ir) { 562void PIconView::slotBeamDone( Ir* ir) {
557 delete ir; 563 delete ir;
558} 564}
559 565
560void PIconView::slotStart() { 566void PIconView::slotStart() {
561 m_view->viewport()->setUpdatesEnabled( false ); 567 m_view->viewport()->setUpdatesEnabled( false );
562} 568}
563 569
564void PIconView::slotEnd() { 570void PIconView::slotEnd() {
565 if ( m_updatet ) 571 if ( m_updatet )
566 m_view->arrangeItemsInGrid( ); 572 m_view->arrangeItemsInGrid( );
567 m_view->viewport()->setUpdatesEnabled( true ); 573 m_view->viewport()->setUpdatesEnabled( true );
568 m_updatet = false; 574 m_updatet = false;
569} 575}
570 576
571void PIconView::slotShowLast() 577void PIconView::slotShowLast()
572{ 578{
573 QIconViewItem* last_it = m_view->lastItem(); 579 QIconViewItem* last_it = m_view->lastItem();
574 if (!last_it) return; 580 if (!last_it) return;
575 m_view->setCurrentItem(last_it); 581 m_view->setCurrentItem(last_it);
576 IconViewItem* it = static_cast<IconViewItem*>( last_it ); 582 IconViewItem* it = static_cast<IconViewItem*>( last_it );
577 bool isDir = it->isDir(); 583 bool isDir = it->isDir();
578 QString name = it->path(); 584 QString name = it->path();
579 if (!isDir && !name.isEmpty()) { 585 if (!isDir && !name.isEmpty()) {
580 slotShowImage(name); 586 slotShowImage(name);
581 return; 587 return;
582 } 588 }
583 bool first_loop = true; 589 bool first_loop = true;
584 while(isDir==true) { 590 while(isDir==true) {
585 if (!first_loop) { 591 if (!first_loop) {
586 m_view->setCurrentItem(m_view->currentItem()->prevItem()); 592 m_view->setCurrentItem(m_view->currentItem()->prevItem());
587 } else { 593 } else {
588 first_loop = false; 594 first_loop = false;
589 } 595 }
590 name = prevFileName(isDir); 596 name = prevFileName(isDir);
591 } 597 }
592 598
593 if (name.isEmpty()) return; 599 if (name.isEmpty()) return;
594 /* if we got a name we have a prev item */ 600 /* if we got a name we have a prev item */
595 m_view->setCurrentItem(m_view->currentItem()->prevItem()); 601 m_view->setCurrentItem(m_view->currentItem()->prevItem());
596 slotShowImage(name); 602 slotShowImage(name);
597} 603}
598 604
599bool PIconView::slotShowFirst() 605bool PIconView::slotShowFirst()
600{ 606{
601 /* stop when reached - otherwise we may get an endless loop */ 607 /* stop when reached - otherwise we may get an endless loop */
602 QIconViewItem* first_it = m_view->firstItem(); 608 QIconViewItem* first_it = m_view->firstItem();
603 if (!first_it) return false; 609 if (!first_it) return false;
604 m_view->setCurrentItem(first_it); 610 m_view->setCurrentItem(first_it);
605 IconViewItem* it = static_cast<IconViewItem*>( first_it ); 611 IconViewItem* it = static_cast<IconViewItem*>( first_it );
606 bool isDir = it->isDir(); 612 bool isDir = it->isDir();
607 QString name = it->path(); 613 QString name = it->path();
608 if (!isDir && !name.isEmpty()) { 614 if (!isDir && !name.isEmpty()) {
609 slotShowImage(name); 615 slotShowImage(name);
610 return false; 616 return false;
611 } 617 }
612 bool first_loop = true; 618 bool first_loop = true;
613 while(isDir==true) { 619 while(isDir==true) {
614 /* if name is empty isDir is false, too. */ 620 /* if name is empty isDir is false, too. */
615 if (!first_loop) { 621 if (!first_loop) {
616 m_view->setCurrentItem(m_view->currentItem()->nextItem()); 622 m_view->setCurrentItem(m_view->currentItem()->nextItem());
617 } else { 623 } else {
618 first_loop = false; 624 first_loop = false;
619 } 625 }
620 name = nextFileName(isDir); 626 name = nextFileName(isDir);
621 } 627 }
622 if (name.isEmpty()) return false; 628 if (name.isEmpty()) return false;
623 /* if we got a name we have a next item */ 629 /* if we got a name we have a next item */
624 m_view->setCurrentItem(m_view->currentItem()->nextItem()); 630 m_view->setCurrentItem(m_view->currentItem()->nextItem());
625 slotShowImage(name); 631 slotShowImage(name);
626 return true; 632 return true;
627} 633}
628 634
629void PIconView::slotShowNext() 635void PIconView::slotShowNext()
630{ 636{
631 bool isDir = false; 637 bool isDir = false;
632 QString name = nextFileName(isDir); 638 QString name = nextFileName(isDir);
633 while (isDir==true) { 639 while (isDir==true) {
634 m_view->setCurrentItem(m_view->currentItem()->nextItem()); 640 m_view->setCurrentItem(m_view->currentItem()->nextItem());
635 name = nextFileName(isDir); 641 name = nextFileName(isDir);
636 } 642 }
637 if (name.isEmpty()) { 643 if (name.isEmpty()) {
638 slotShowFirst(); 644 slotShowFirst();
639 return; 645 return;
640 } 646 }
641 if (isDir) return; 647 if (isDir) return;
642 /* if we got a name we have a next item */ 648 /* if we got a name we have a next item */
643 m_view->setCurrentItem(m_view->currentItem()->nextItem()); 649 m_view->setCurrentItem(m_view->currentItem()->nextItem());
644 slotShowImage(name); 650 slotShowImage(name);
645} 651}
646 652
647void PIconView::slotShowPrev() 653void PIconView::slotShowPrev()
648{ 654{
649 bool isDir = false; 655 bool isDir = false;
650 QString name = prevFileName(isDir); 656 QString name = prevFileName(isDir);
651 while (isDir==true) { 657 while (isDir==true) {
652 /* if name is empty isDir is false, too. */ 658 /* if name is empty isDir is false, too. */
653 m_view->setCurrentItem(m_view->currentItem()->prevItem()); 659 m_view->setCurrentItem(m_view->currentItem()->prevItem());
654 name = prevFileName(isDir); 660 name = prevFileName(isDir);
655 } 661 }
656 if (name.isEmpty()) { 662 if (name.isEmpty()) {
657 slotShowLast(); 663 slotShowLast();
658 return; 664 return;
659 } 665 }
660 if (isDir) return; 666 if (isDir) return;
661 /* if we got a name we have a prev item */ 667 /* if we got a name we have a prev item */
662 m_view->setCurrentItem(m_view->currentItem()->prevItem()); 668 m_view->setCurrentItem(m_view->currentItem()->prevItem());
663 slotShowImage(name); 669 slotShowImage(name);
664} 670}
665 671
666void PIconView::slotShowImage() 672void PIconView::slotShowImage()
667{ 673{
668 bool isDir = false; 674 bool isDir = false;
669 QString name = currentFileName(isDir); 675 QString name = currentFileName(isDir);
670 if (isDir) return; 676 if (isDir) return;
671 slotShowImage( name ); 677 slotShowImage( name );
672} 678}
673void PIconView::slotShowImage( const QString& name) { 679void PIconView::slotShowImage( const QString& name) {
674 PDirLister *lister = currentView()->dirLister(); 680 PDirLister *lister = currentView()->dirLister();
675 QString r_name = lister->nameToFname(name); 681 QString r_name = lister->nameToFname(name);
676 emit sig_display(r_name); 682 emit sig_display(r_name);
677} 683}
678 684
679void PIconView::slotStartSlide() { 685void PIconView::slotStartSlide() {
680 bool isDir = false; 686 bool isDir = false;
681 QString name = currentFileName(isDir); 687 QString name = currentFileName(isDir);
682 if (isDir) { 688 if (isDir) {
683 if (!slotShowFirst()) 689 if (!slotShowFirst())
684 return; 690 return;
685 } else { 691 } else {
686 slotShowImage( name ); 692 slotShowImage( name );
687 } 693 }
688 int t = m_cfg->readNumEntry("base_slideshowtimeout", 2); 694 int t = m_cfg->readNumEntry("base_slideshowtimeout", 2);
689 emit sig_startslide(t); 695 emit sig_startslide(t);
690} 696}
691 697
692void PIconView::slotImageInfo() { 698void PIconView::slotImageInfo() {
693 bool isDir = false; 699 bool isDir = false;
694 QString name = currentFileName(isDir); 700 QString name = currentFileName(isDir);
695 if (isDir) return; 701 if (isDir) return;
696 slotImageInfo( name ); 702 slotImageInfo( name );
697} 703}
698 704
699void PIconView::slotImageInfo( const QString& name) { 705void PIconView::slotImageInfo( const QString& name) {
700 PDirLister *lister = currentView()->dirLister(); 706 PDirLister *lister = currentView()->dirLister();
701 QString r_name = lister->nameToFname(name); 707 QString r_name = lister->nameToFname(name);
702 emit sig_showInfo(r_name ); 708 emit sig_showInfo(r_name );
703} 709}
704 710
705 711
706void PIconView::slotChangeMode( int mode ) { 712void PIconView::slotChangeMode( int mode ) {
707 if ( mode >= 1 && mode <= 3 ) 713 if ( mode >= 1 && mode <= 3 )
708 m_mode = mode; 714 m_mode = mode;
709 715
710 m_cfg->writeEntry("ListViewMode", m_mode); 716 m_cfg->writeEntry("ListViewMode", m_mode);
711 /* performance! */ 717 /* performance! */
712 m_view->clear(); 718 m_view->clear();
713 calculateGrid(); 719 calculateGrid();
714 slotReloadDir(); 720 slotReloadDir();
715} 721}
716 722
717 723
718void PIconView::resizeEvent( QResizeEvent* re ) { 724void PIconView::resizeEvent( QResizeEvent* re ) {
719 QVBox::resizeEvent( re ); 725 QVBox::resizeEvent( re );
720 calculateGrid(); 726 calculateGrid();
721} 727}
722 728
723 729
724void PIconView::calculateGrid() { 730void PIconView::calculateGrid() {
725 int dw = QApplication::desktop()->width(); 731 int dw = QApplication::desktop()->width();
726 int viewerWidth = dw-style().scrollBarExtent().width(); 732 int viewerWidth = dw-style().scrollBarExtent().width();
727 733
728 QIconView::ItemTextPos pos; 734 QIconView::ItemTextPos pos;
729 switch( m_mode ) { 735 switch( m_mode ) {
730 case 2: 736 case 2:
731 pos = QIconView::Bottom; 737 pos = QIconView::Bottom;
732 break; 738 break;
733 case 3: 739 case 3:
734 case 1: 740 case 1:
735 default: 741 default:
736 pos = QIconView::Right; 742 pos = QIconView::Right;
737 break; 743 break;
738 } 744 }
739 m_view->setItemTextPos( pos ); 745 m_view->setItemTextPos( pos );
740 switch (m_mode) { 746 switch (m_mode) {
741 case 2: 747 case 2:
742 m_view->setGridX(50); 748 m_view->setGridX(50);
743 m_view->setGridY(20); 749 m_view->setGridY(20);
744 PPixmapCache::self()->setMaxImages(40); 750 PPixmapCache::self()->setMaxImages(40);
745 break; 751 break;
746 case 3: 752 case 3:
747 m_view->setGridX( fontMetrics().width("testimage.jpg")+20); 753 m_view->setGridX( fontMetrics().width("testimage.jpg")+20);
748 m_view->setGridY(8); 754 m_view->setGridY(8);
749 PPixmapCache::self()->setMaxImages(2); 755 PPixmapCache::self()->setMaxImages(2);
750 break; 756 break;
751 case 1: 757 case 1:
752 default: 758 default:
753 m_view->setGridX( viewerWidth-3*m_view->spacing()); 759 m_view->setGridX( viewerWidth-3*m_view->spacing());
754 m_view->setGridY( fontMetrics().height()*2+40 ); 760 m_view->setGridY( fontMetrics().height()*2+40 );
755 PPixmapCache::self()->setMaxImages(20); 761 PPixmapCache::self()->setMaxImages(20);
756 break; 762 break;
757 } 763 }
758} 764}
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h
index dff55ed..bea35c2 100644
--- a/noncore/graphics/opie-eye/gui/iconview.h
+++ b/noncore/graphics/opie-eye/gui/iconview.h
@@ -1,100 +1,101 @@
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
38signals: 38signals:
39 void sig_showInfo( const QString& ); 39 void sig_showInfo( const QString& );
40 void sig_display(const QString&); 40 void sig_display(const QString&);
41 void sig_startslide(int timeout); 41 void sig_startslide(int timeout);
42 42
43public slots: 43public slots:
44 virtual void slotShowNext(); 44 virtual void slotShowNext();
45 virtual void slotShowPrev(); 45 virtual void slotShowPrev();
46 virtual void slotShowLast(); 46 virtual void slotShowLast();
47 virtual bool slotShowFirst(); 47 virtual bool slotShowFirst();
48 48
49protected: 49protected:
50 void resizeEvent( QResizeEvent* ); 50 void resizeEvent( QResizeEvent* );
51 51
52private: 52private:
53 void initKeys(); 53 void initKeys();
54 QString currentFileName(bool &isDir)const; 54 QString currentFileName(bool &isDir)const;
55 QString nextFileName(bool &isDir)const; 55 QString nextFileName(bool &isDir)const;
56 QString prevFileName(bool &isDir)const; 56 QString prevFileName(bool &isDir)const;
57 void loadViews(); 57 void loadViews();
58 void calculateGrid(); 58 void calculateGrid();
59 59
60private slots: 60private slots:
61 void slotDirUp(); 61 void slotDirUp();
62 void slotChangeDir(const QString&); 62 void slotChangeDir(const QString&);
63 void slotTrash(); 63 void slotTrash();
64 void slotViewChanged( int ); 64 void slotViewChanged( int );
65 void slotReloadDir(); 65 void slotReloadDir();
66 void slotRename(); 66 void slotRename();
67 void slotBeam(); 67 void slotBeam();
68 void slotBeamDone( Ir* ); 68 void slotBeamDone( Ir* );
69 69
70 void slotShowImage(); 70 void slotShowImage();
71 void slotShowImage( const QString& ); 71 void slotShowImage( const QString& );
72 void slotImageInfo(); 72 void slotImageInfo();
73 void slotImageInfo( const QString& ); 73 void slotImageInfo( const QString& );
74 void slotStartSlide(); 74 void slotStartSlide();
75 75
76 void slotStart(); 76 void slotStart();
77 void slotEnd(); 77 void slotEnd();
78 78
79/* for performance reasons make it inline in the future */ 79/* for performance reasons make it inline in the future */
80 void addFolders( const QStringList& ); 80 void addFolders( const QStringList& );
81 void addFiles( const QStringList& ); 81 void addFiles( const QStringList& );
82 void slotClicked(QIconViewItem* ); 82 void slotClicked(QIconViewItem* );
83 void slotRetrun(QIconViewItem* ); 83 void slotRetrun(QIconViewItem* );
84 84
85/**/ 85/**/
86 void slotThumbInfo(const QString&, const QString&); 86 void slotThumbInfo(const QString&, const QString&);
87 void slotThumbNail(const QString&, const QPixmap&); 87 void slotThumbNail(const QString&, const QPixmap&);
88 88
89 void slotChangeMode( int ); 89 void slotChangeMode( int );
90private: 90private:
91 Opie::Core::OKeyConfigManager *m_viewManager; 91 Opie::Core::OKeyConfigManager *m_viewManager;
92 Opie::Core::OConfig *m_cfg; 92 Opie::Core::OConfig *m_cfg;
93 QComboBox* m_views; 93 QComboBox* m_views;
94 QIconView* m_view; 94 QIconView* m_view;
95 QString m_path; 95 QString m_path;
96 bool m_updatet : 1; 96 bool m_updatet : 1;
97 int m_mode; 97 int m_mode;
98 bool m_internalReset:1;
98}; 99};
99 100
100#endif 101#endif
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index 6660eb2..30c9bf1 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -1,694 +1,696 @@
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 49
50 m_storage = new StorageInfo(); 50 m_storage = new StorageInfo();
51 connect(m_storage, SIGNAL(disksChanged() ), 51 connect(m_storage, SIGNAL(disksChanged() ),
52 this, SLOT( dirChanged() ) ); 52 this, SLOT( dirChanged() ) );
53 53
54 m_stack = new Opie::Ui::OWidgetStack( this ); 54 m_stack = new Opie::Ui::OWidgetStack( this );
55 setCentralWidget( m_stack ); 55 setCentralWidget( m_stack );
56 56
57 m_view = new PIconView( m_stack, m_cfg ); 57 m_view = new PIconView( m_stack, m_cfg );
58 m_stack->addWidget( m_view, IconView ); 58 m_stack->addWidget( m_view, IconView );
59 m_stack->raiseWidget( IconView ); 59 m_stack->raiseWidget( IconView );
60 60
61 connect(m_view, SIGNAL(sig_display(const QString&)), 61 connect(m_view, SIGNAL(sig_display(const QString&)),
62 this, SLOT(slotDisplay(const QString&))); 62 this, SLOT(slotDisplay(const QString&)));
63 connect(m_view, SIGNAL(sig_showInfo(const QString&)), 63 connect(m_view, SIGNAL(sig_showInfo(const QString&)),
64 this, SLOT(slotShowInfo(const QString&)) ); 64 this, SLOT(slotShowInfo(const QString&)) );
65 connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int))); 65 connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int)));
66 66
67 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); 67 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce);
68 68
69 listviewMenu = 0; 69 listviewMenu = 0;
70 /* setup menu and toolbar */ 70 /* setup menu and toolbar */
71 setupActions(); 71 setupActions();
72 setupToolbar(); 72 setupToolbar();
73 setupMenu(); 73 setupMenu();
74 m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true)); 74 m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true));
75 m_aAutoRotate->setEnabled(!m_aUnscaled->isOn()); 75 m_aAutoRotate->setEnabled(!m_aUnscaled->isOn());
76} 76}
77 77
78PMainWindow::~PMainWindow() { 78PMainWindow::~PMainWindow() {
79} 79}
80 80
81void PMainWindow::slotToggleZoomer() 81void PMainWindow::slotToggleZoomer()
82{ 82{
83 m_aZoomer->setOn(!m_aZoomer->isOn()); 83 m_aZoomer->setOn(!m_aZoomer->isOn());
84} 84}
85 85
86void PMainWindow::slotZoomerToggled(bool how) 86void PMainWindow::slotZoomerToggled(bool how)
87{ 87{
88 if (m_disp) { 88 if (m_disp) {
89 m_disp->setShowZoomer(how); 89 m_disp->setShowZoomer(how);
90 } 90 }
91 if (autoSave) { 91 if (autoSave) {
92 m_cfg->writeEntry("zoomeron",how); 92 m_cfg->writeEntry("zoomeron",how);
93 } 93 }
94} 94}
95 95
96void PMainWindow::slotToggleAutorotate() 96void PMainWindow::slotToggleAutorotate()
97{ 97{
98 if (!m_aAutoRotate->isEnabled()) return; 98 if (!m_aAutoRotate->isEnabled()) return;
99 m_aAutoRotate->setOn(!m_aAutoRotate->isOn()); 99 m_aAutoRotate->setOn(!m_aAutoRotate->isOn());
100} 100}
101 101
102void PMainWindow::slotToggleAutoscale() 102void PMainWindow::slotToggleAutoscale()
103{ 103{
104 m_aUnscaled->setOn(!m_aUnscaled->isOn()); 104 m_aUnscaled->setOn(!m_aUnscaled->isOn());
105} 105}
106 106
107void PMainWindow::slotRotateToggled(bool how) 107void PMainWindow::slotRotateToggled(bool how)
108{ 108{
109 if (autoSave) { 109 if (autoSave) {
110 m_cfg->writeEntry("autorotate",how); 110 m_cfg->writeEntry("autorotate",how);
111 } 111 }
112 if (m_disp) { 112 if (m_disp) {
113 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how); 113 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how);
114 } 114 }
115} 115}
116 116
117void PMainWindow::slotScaleToggled(bool how) 117void PMainWindow::slotScaleToggled(bool how)
118{ 118{
119 if (autoSave) { 119 if (autoSave) {
120 m_cfg->writeEntry("unscaled",how); 120 m_cfg->writeEntry("unscaled",how);
121 } 121 }
122 odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl; 122 odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl;
123 odebug << "How: " << how << oendl; 123 odebug << "How: " << how << oendl;
124 if (how) { 124 if (how) {
125 m_aAutoRotate->setOn(false); 125 m_aAutoRotate->setOn(false);
126 } 126 }
127 if (m_disp) { 127 if (m_disp) {
128 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),m_aAutoRotate->isOn()); 128 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),m_aAutoRotate->isOn());
129 } 129 }
130 m_aAutoRotate->setEnabled(!how); 130 m_aAutoRotate->setEnabled(!how);
131 odebug << "Autorotate: " << m_aAutoRotate->isOn() << oendl; 131 odebug << "Autorotate: " << m_aAutoRotate->isOn() << oendl;
132} 132}
133 133
134void PMainWindow::slotConfig() { 134void PMainWindow::slotConfig() {
135 /* 135 /*
136 * have a tab with the possible views 136 * have a tab with the possible views
137 * a tab for globals image cache size.. scaled loading 137 * a tab for globals image cache size.. scaled loading
138 * and one tab for the KeyConfigs 138 * and one tab for the KeyConfigs
139 */ 139 */
140 QDialog dlg(this, 0, true); 140 QDialog dlg(this, 0, true);
141 dlg.setCaption( tr("Opie Eye - Config" ) ); 141 dlg.setCaption( tr("Opie Eye - Config" ) );
142 142
143 QHBoxLayout *lay = new QHBoxLayout(&dlg); 143 QHBoxLayout *lay = new QHBoxLayout(&dlg);
144 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); 144 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg );
145 lay->addWidget( wid ); 145 lay->addWidget( wid );
146 146
147 BaseSetup*bSetup = new BaseSetup(m_cfg,wid); 147 BaseSetup*bSetup = new BaseSetup(m_cfg,wid);
148 wid->addTab(bSetup,"SettingsIcon","Basics setup"); 148 wid->addTab(bSetup,"SettingsIcon","Basics setup");
149 149
150 ViewMap *vM = viewMap(); 150 ViewMap *vM = viewMap();
151 ViewMap::Iterator _it = vM->begin(); 151 ViewMap::Iterator _it = vM->begin();
152 QMap<PDirView*, QWidget*> lst; 152 QMap<PDirView*, QWidget*> lst;
153 153
154 for( ; _it != vM->end(); ++_it ) { 154 for( ; _it != vM->end(); ++_it ) {
155 PDirView *view = (_it.data())(*m_cfg); 155 PDirView *view = (_it.data())(*m_cfg);
156 PInterfaceInfo *inf = view->interfaceInfo(); 156 PInterfaceInfo *inf = view->interfaceInfo();
157 QWidget *_wid = inf->configWidget( *m_cfg ); 157 QWidget *_wid = inf->configWidget( *m_cfg );
158 if (!_wid) continue; 158 if (!_wid) continue;
159 _wid->reparent(wid, QPoint() ); 159 _wid->reparent(wid, QPoint() );
160 lst.insert( view, _wid ); 160 lst.insert( view, _wid );
161 wid->addTab( _wid, "fileopen", inf->name() ); 161 wid->addTab( _wid, "fileopen", inf->name() );
162 } 162 }
163 163
164/* 164/*
165 * Add the KeyConfigWidget 165 * Add the KeyConfigWidget
166 */ 166 */
167 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); 167 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" );
168 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); 168 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue );
169 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); 169 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() );
170 QWidget*w = m_stack->visibleWidget(); 170 QWidget*w = m_stack->visibleWidget();
171 171
172 bool reminfo = false; 172 bool reminfo = false;
173 if ( !m_info ) { 173 if ( !m_info ) {
174 reminfo = true; 174 reminfo = true;
175 initInfo(); 175 initInfo();
176 m_info->hide();
176 } 177 }
177 keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); 178 keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() );
178 179
179 bool remdisp = false; 180 bool remdisp = false;
180 if ( !m_disp ) { 181 if ( !m_disp ) {
181 remdisp = true; 182 remdisp = true;
182 initDisp(); 183 initDisp();
184 m_disp->hide();
183 } 185 }
184 keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); 186 keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() );
185 187
186 keyWid->load(); 188 keyWid->load();
187 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); 189 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") );
188 wid->setCurrentTab(0); 190 wid->setCurrentTab(0);
189 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); 191 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
190 192
191/* 193/*
192 * clean up 194 * clean up
193 *apply changes 195 *apply changes
194 */ 196 */
195 197
196 QMap<PDirView*, QWidget*>::Iterator it; 198 QMap<PDirView*, QWidget*>::Iterator it;
197 for ( it = lst.begin(); it != lst.end(); ++it ) { 199 for ( it = lst.begin(); it != lst.end(); ++it ) {
198 if ( act ) 200 if ( act )
199 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); 201 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg);
200 delete it.key(); 202 delete it.key();
201 } 203 }
202 204
203 205
204 if ( act ) { 206 if ( act ) {
205 m_view->resetView(); 207 m_view->resetView();
206 keyWid->save(); 208 keyWid->save();
207 m_disp->manager()->save(); 209 m_disp->manager()->save();
208 m_info->manager()->save(); 210 m_info->manager()->save();
209 m_view->manager()->save(); 211 m_view->manager()->save();
210 bSetup->save_values(); 212 bSetup->save_values();
211 readConfig(); 213 readConfig();
212 } 214 }
213 delete keyWid; 215 delete keyWid;
214 216
215 m_stack->raiseWidget(w); 217 m_stack->raiseWidget(w);
216 if (remdisp) { 218 if (remdisp) {
217 m_disp->hide(); 219 m_disp->hide();
218 } 220 }
219 if (reminfo) { 221 if (reminfo) {
220 m_info->hide(); 222 m_info->hide();
221 } 223 }
222} 224}
223 225
224/* 226/*
225 * create a new image info component 227 * create a new image info component
226 * and detach the current one 228 * and detach the current one
227 * we will make the other delete on exit 229 * we will make the other delete on exit
228 */ 230 */
229template<class T> 231template<class T>
230void PMainWindow::initT( const char* name, T** ptr, int id) { 232void PMainWindow::initT( const char* name, T** ptr, int id) {
231 if ( *ptr ) { 233 if ( *ptr ) {
232 (*ptr)->disconnect(this, SLOT(slotReturn())); 234 (*ptr)->disconnect(this, SLOT(slotReturn()));
233 (*ptr)->setDestructiveClose(); 235 (*ptr)->setDestructiveClose();
234 m_stack->removeWidget( *ptr ); 236 m_stack->removeWidget( *ptr );
235 } 237 }
236 *ptr = new T(m_cfg, m_stack, name ); 238 *ptr = new T(m_cfg, m_stack, name );
237 m_stack->addWidget( *ptr, id ); 239 m_stack->addWidget( *ptr, id );
238 240
239 connect(*ptr, SIGNAL(sig_return()), 241 connect(*ptr, SIGNAL(sig_return()),
240 this,SLOT(slotReturn())); 242 this,SLOT(slotReturn()));
241 243
242} 244}
243 245
244void PMainWindow::initInfo() { 246void PMainWindow::initInfo() {
245 initT<imageinfo>( "Image Info", &m_info, ImageInfo ); 247 initT<imageinfo>( "Image Info", &m_info, ImageInfo );
246 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); 248 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&)));
247} 249}
248 250
249void PMainWindow::initDisp() { 251void PMainWindow::initDisp() {
250 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); 252 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay );
251 if (m_disp) { 253 if (m_disp) {
252 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 254 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
253 m_disp->setMinimumSize(QApplication::desktop()->size()/2); 255 m_disp->setMinimumSize(QApplication::desktop()->size()/2);
254 } 256 }
255 m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType); 257 m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType);
256 m_disp->setAutoScale(!m_aUnscaled->isOn()); 258 m_disp->setAutoScale(!m_aUnscaled->isOn());
257 m_disp->setAutoRotate(m_aAutoRotate->isOn()); 259 m_disp->setAutoRotate(m_aAutoRotate->isOn());
258 m_disp->setShowZoomer(m_aZoomer->isOn()); 260 m_disp->setShowZoomer(m_aZoomer->isOn());
259 m_disp->setBackgroundColor(white); 261 m_disp->setBackgroundColor(white);
260 connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); 262 connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&)));
261 connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); 263 connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext()));
262 connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); 264 connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev()));
263 connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); 265 connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen()));
264 connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); 266 connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView()));
265 connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); 267 connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer()));
266 connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); 268 connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale()));
267 connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); 269 connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate()));
268 connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int))); 270 connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int)));
269 slotFullScreenToggled(m_aFullScreen->isOn()); 271 slotFullScreenToggled(m_aFullScreen->isOn());
270 } 272 }
271} 273}
272 274
273void PMainWindow::slotToggleFullScreen() 275void PMainWindow::slotToggleFullScreen()
274{ 276{
275 bool current = !m_aFullScreen->isOn(); 277 bool current = !m_aFullScreen->isOn();
276 m_aFullScreen->setOn(current); 278 m_aFullScreen->setOn(current);
277} 279}
278 280
279void PMainWindow::slotFullScreenButton(bool current) 281void PMainWindow::slotFullScreenButton(bool current)
280{ 282{
281 if (autoSave) { 283 if (autoSave) {
282 m_cfg->writeEntry("fullscreen",current); 284 m_cfg->writeEntry("fullscreen",current);
283 } 285 }
284 if (!m_disp) return; 286 if (!m_disp) return;
285 if (m_disp->isVisible()) { 287 if (m_disp->isVisible()) {
286 setupViewWindow(current, true); 288 setupViewWindow(current, true);
287 } 289 }
288} 290}
289 291
290void PMainWindow::setupViewWindow(bool current, bool forceDisplay) 292void PMainWindow::setupViewWindow(bool current, bool forceDisplay)
291{ 293{
292 if (!m_disp) return; 294 if (!m_disp) return;
293 if (current) { 295 if (current) {
294 m_disp->setBackgroundColor(black); 296 m_disp->setBackgroundColor(black);
295 m_disp->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); 297 m_disp->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0));
296 m_disp->setVScrollBarMode(QScrollView::AlwaysOff); 298 m_disp->setVScrollBarMode(QScrollView::AlwaysOff);
297 m_disp->setHScrollBarMode(QScrollView::AlwaysOff); 299 m_disp->setHScrollBarMode(QScrollView::AlwaysOff);
298 m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); 300 m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height());
299 } else { 301 } else {
300 setUpdatesEnabled(false); 302 setUpdatesEnabled(false);
301 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 303 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
302 m_disp->setMinimumSize(QApplication::desktop()->size()/2); 304 m_disp->setMinimumSize(QApplication::desktop()->size()/2);
303 } else { 305 } else {
304 m_disp->setMinimumSize(10,10); 306 m_disp->setMinimumSize(10,10);
305 } 307 }
306 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 308 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
307 m_disp->reparent(0,QPoint(50,50)); 309 m_disp->reparent(0,QPoint(50,50));
308 } else { 310 } else {
309 m_disp->reparent(0,QPoint(0,0)); 311 m_disp->reparent(0,QPoint(0,0));
310 } 312 }
311 m_disp->setBackgroundColor(white); 313 m_disp->setBackgroundColor(white);
312 m_stack->addWidget(m_disp,ImageDisplay); 314 m_stack->addWidget(m_disp,ImageDisplay);
313 m_disp->setVScrollBarMode(QScrollView::Auto); 315 m_disp->setVScrollBarMode(QScrollView::Auto);
314 m_disp->setHScrollBarMode(QScrollView::Auto); 316 m_disp->setHScrollBarMode(QScrollView::Auto);
315 if (forceDisplay || m_disp->isVisible()) 317 if (forceDisplay || m_disp->isVisible())
316 m_stack->raiseWidget(m_disp); 318 m_stack->raiseWidget(m_disp);
317 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 319 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
318 m_disp->resize(m_disp->minimumSize()); 320 m_disp->resize(m_disp->minimumSize());
319 } 321 }
320 setUpdatesEnabled(true); 322 setUpdatesEnabled(true);
321 } 323 }
322 m_disp->setFullScreen(current,forceDisplay); 324 m_disp->setFullScreen(current,forceDisplay);
323} 325}
324 326
325void PMainWindow::slotFullScreenToggled(bool current) 327void PMainWindow::slotFullScreenToggled(bool current)
326{ 328{
327 setupViewWindow(current,true); 329 setupViewWindow(current,true);
328} 330}
329 331
330/** 332/**
331 * With big Screen the plan could be to 'detach' the image 333 * With big Screen the plan could be to 'detach' the image
332 * window if visible and to create a ne wone 334 * window if visible and to create a ne wone
333 * init* already supports it but I make no use of it for 335 * init* already supports it but I make no use of it for
334 * now. We set filename and raise 336 * now. We set filename and raise
335 * 337 *
336 * ### FIXME and talk to alwin 338 * ### FIXME and talk to alwin
337 */ 339 */
338void PMainWindow::slotShowInfo( const QString& inf ) { 340void PMainWindow::slotShowInfo( const QString& inf ) {
339 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { 341 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) {
340 return; 342 return;
341 } 343 }
342 if ( !m_info ) { 344 if ( !m_info ) {
343 initInfo(); 345 initInfo();
344 } 346 }
345 m_info->setPath( inf ); 347 m_info->setPath( inf );
346 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 348 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
347 m_aNext->removeFrom(toolBar); 349 m_aNext->removeFrom(toolBar);
348 m_aPrevious->removeFrom(toolBar); 350 m_aPrevious->removeFrom(toolBar);
349 m_aNext->setEnabled(false); 351 m_aNext->setEnabled(false);
350 m_aPrevious->setEnabled(false); 352 m_aPrevious->setEnabled(false);
351 m_aDirUp->setEnabled(false); 353 m_aDirUp->setEnabled(false);
352 m_aShowInfo->setEnabled(false); 354 m_aShowInfo->setEnabled(false);
353 m_aViewfile->setEnabled(true); 355 m_aViewfile->setEnabled(true);
354 m_aStartSlide->setEnabled(false); 356 m_aStartSlide->setEnabled(false);
355 fsButton->hide(); 357 fsButton->hide();
356 } 358 }
357 m_stack->raiseWidget( ImageInfo ); 359 m_stack->raiseWidget( ImageInfo );
358} 360}
359 361
360void PMainWindow::slotDisplay( const QString& inf ) { 362void PMainWindow::slotDisplay( const QString& inf ) {
361 bool nwindow = false; 363 bool nwindow = false;
362 if ( !m_disp ) { 364 if ( !m_disp ) {
363 nwindow = true; 365 nwindow = true;
364 initDisp(); 366 initDisp();
365 } 367 }
366 m_disp->setImage( inf ); 368 m_disp->setImage( inf );
367 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 369 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
368 if (m_gPrevNext->isEnabled()==false) { 370 if (m_gPrevNext->isEnabled()==false) {
369 m_gPrevNext->addTo(toolBar); 371 m_gPrevNext->addTo(toolBar);
370 m_gPrevNext->setEnabled(true); 372 m_gPrevNext->setEnabled(true);
371 373
372 m_aDirUp->setEnabled(false); 374 m_aDirUp->setEnabled(false);
373 m_aShowInfo->setEnabled(true); 375 m_aShowInfo->setEnabled(true);
374 m_aViewfile->setEnabled(false); 376 m_aViewfile->setEnabled(false);
375 m_aStartSlide->setEnabled(false); 377 m_aStartSlide->setEnabled(false);
376 fsButton->hide(); 378 fsButton->hide();
377 } 379 }
378 } 380 }
379 if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) { 381 if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) {
380 slotFullScreenToggled(m_aFullScreen->isOn()); 382 slotFullScreenToggled(m_aFullScreen->isOn());
381 } 383 }
382 if (m_disp->fullScreen()) { 384 if (m_disp->fullScreen()) {
383 qwsDisplay()->requestFocus( m_disp->winId(), TRUE); 385 qwsDisplay()->requestFocus( m_disp->winId(), TRUE);
384 } else { 386 } else {
385 m_stack->raiseWidget( ImageDisplay ); 387 m_stack->raiseWidget( ImageDisplay );
386 } 388 }
387} 389}
388 390
389void PMainWindow::raiseIconView() { 391void PMainWindow::raiseIconView() {
390 setUpdatesEnabled(false); 392 setUpdatesEnabled(false);
391 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 393 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
392 m_gPrevNext->removeFrom(toolBar); 394 m_gPrevNext->removeFrom(toolBar);
393 m_gPrevNext->setEnabled(false); 395 m_gPrevNext->setEnabled(false);
394 m_aDirUp->setEnabled(true); 396 m_aDirUp->setEnabled(true);
395 m_aShowInfo->setEnabled(true); 397 m_aShowInfo->setEnabled(true);
396 m_aViewfile->setEnabled(true); 398 m_aViewfile->setEnabled(true);
397 m_aStartSlide->setEnabled(true); 399 m_aStartSlide->setEnabled(true);
398 fsButton->show(); 400 fsButton->show();
399 } 401 }
400 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { 402 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) {
401 m_disp->stopSlide(); 403 m_disp->stopSlide();
402 m_disp->hide(); 404 m_disp->hide();
403 } 405 }
404 m_stack->raiseWidget( IconView ); 406 m_stack->raiseWidget( IconView );
405 setUpdatesEnabled(true); 407 setUpdatesEnabled(true);
406 repaint(); 408 repaint();
407} 409}
408 410
409void PMainWindow::slotReturn() { 411void PMainWindow::slotReturn() {
410 raiseIconView(); 412 raiseIconView();
411} 413}
412 414
413 415
414void PMainWindow::closeEvent( QCloseEvent* ev ) { 416void PMainWindow::closeEvent( QCloseEvent* ev ) {
415 /* 417 /*
416 * return from view 418 * return from view
417 * or properly quit 419 * or properly quit
418 */ 420 */
419 if ( m_stack->visibleWidget() == m_info || 421 if ( m_stack->visibleWidget() == m_info ||
420 m_stack->visibleWidget() == m_disp ) { 422 m_stack->visibleWidget() == m_disp ) {
421 ev->ignore(); 423 ev->ignore();
422 raiseIconView(); 424 raiseIconView();
423 return; 425 return;
424 } 426 }
425 if (m_disp && m_disp->fullScreen()) { 427 if (m_disp && m_disp->fullScreen()) {
426 /* otherwise opie-eye crashes in bigscreen mode! */ 428 /* otherwise opie-eye crashes in bigscreen mode! */
427 m_disp->reparent(0,QPoint(0,0)); 429 m_disp->reparent(0,QPoint(0,0));
428 m_stack->addWidget(m_disp,ImageDisplay); 430 m_stack->addWidget(m_disp,ImageDisplay);
429 } 431 }
430 ev->accept(); 432 ev->accept();
431 QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); 433 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()));
432} 434}
433 435
434void PMainWindow::setDocument( const QString& showImg ) { 436void PMainWindow::setDocument( const QString& showImg ) {
435 QString file = showImg; 437 QString file = showImg;
436 DocLnk lnk(showImg); 438 DocLnk lnk(showImg);
437 if (lnk.isValid() ) 439 if (lnk.isValid() )
438 file = lnk.file(); 440 file = lnk.file();
439 441
440 slotDisplay( file ); 442 slotDisplay( file );
441} 443}
442 444
443void PMainWindow::slotSelectDir(int id) 445void PMainWindow::slotSelectDir(int id)
444{ 446{
445 emit changeDir( m_dev[fsMenu->text(id )] ); 447 emit changeDir( m_dev[fsMenu->text(id )] );
446} 448}
447 449
448void PMainWindow::dirChanged() 450void PMainWindow::dirChanged()
449{ 451{
450 fsMenu->clear(); 452 fsMenu->clear();
451 m_dev.clear(); 453 m_dev.clear();
452 454
453 /* home dir, too */ 455 /* home dir, too */
454 QString f = getenv( "HOME" ); 456 QString f = getenv( "HOME" );
455 if (!f.isEmpty()) { 457 if (!f.isEmpty()) {
456 m_dev.insert("Home directory",f); 458 m_dev.insert("Home directory",f);
457 fsMenu->insertItem("Home directory"); 459 fsMenu->insertItem("Home directory");
458 } 460 }
459 const QList<FileSystem> &fs = m_storage->fileSystems(); 461 const QList<FileSystem> &fs = m_storage->fileSystems();
460 QListIterator<FileSystem> it(fs ); 462 QListIterator<FileSystem> it(fs );
461 for ( ; it.current(); ++it ) { 463 for ( ; it.current(); ++it ) {
462 const QString disk = (*it)->name(); 464 const QString disk = (*it)->name();
463 const QString path = (*it)->path(); 465 const QString path = (*it)->path();
464 m_dev.insert( disk, path ); 466 m_dev.insert( disk, path );
465 fsMenu->insertItem( disk ); 467 fsMenu->insertItem( disk );
466 } 468 }
467} 469}
468 470
469void PMainWindow::showToolbar(bool how) 471void PMainWindow::showToolbar(bool how)
470{ 472{
471 if (!how) toolBar->hide(); 473 if (!how) toolBar->hide();
472 else toolBar->show(); 474 else toolBar->show();
473 if (autoSave) { 475 if (autoSave) {
474 m_cfg->writeEntry("showtoolbar",how); 476 m_cfg->writeEntry("showtoolbar",how);
475 } 477 }
476} 478}
477 479
478void PMainWindow::setupActions() 480void PMainWindow::setupActions()
479{ 481{
480 m_aDirUp = new QAction( tr( "Go dir up" ), Resource::loadIconSet( "up" ), 0, 0, this, 0, true ); 482 m_aDirUp = new QAction( tr( "Go dir up" ), Resource::loadIconSet( "up" ), 0, 0, this, 0, true );
481 m_aDirUp->setToggleAction(false); 483 m_aDirUp->setToggleAction(false);
482 connect(m_aDirUp,SIGNAL(activated()),m_view,SLOT(slotDirUp())); 484 connect(m_aDirUp,SIGNAL(activated()),m_view,SLOT(slotDirUp()));
483 485
484 if ( Ir::supported() ) { 486 if ( Ir::supported() ) {
485 m_aBeam = new QAction( tr( "Beam file" ), Resource::loadIconSet( "beam" ),0, 0, this, 0, true ); 487 m_aBeam = new QAction( tr( "Beam file" ), Resource::loadIconSet( "beam" ),0, 0, this, 0, true );
486 m_aBeam->setToggleAction(false); 488 m_aBeam->setToggleAction(false);
487 connect(m_aBeam,SIGNAL(activated()),m_view,SLOT(slotBeam())); 489 connect(m_aBeam,SIGNAL(activated()),m_view,SLOT(slotBeam()));
488 } else { 490 } else {
489 m_aBeam = 0; 491 m_aBeam = 0;
490 } 492 }
491 493
492 m_aShowInfo = new QAction( tr( "Show imageinfo" ), Resource::loadIconSet( "edit" ), 0, 0, this, 0, true ); 494 m_aShowInfo = new QAction( tr( "Show imageinfo" ), Resource::loadIconSet( "edit" ), 0, 0, this, 0, true );
493 m_aShowInfo->setToggleAction(false); 495 m_aShowInfo->setToggleAction(false);
494 connect(m_aShowInfo,SIGNAL(activated()),m_view,SLOT(slotImageInfo())); 496 connect(m_aShowInfo,SIGNAL(activated()),m_view,SLOT(slotImageInfo()));
495 497
496 m_aTrash = new QAction( tr( "Delete file" ), Resource::loadIconSet("trash"), 0, 0, this, 0, true ); 498 m_aTrash = new QAction( tr( "Delete file" ), Resource::loadIconSet("trash"), 0, 0, this, 0, true );
497 m_aTrash->setToggleAction(false); 499 m_aTrash->setToggleAction(false);
498 connect(m_aTrash,SIGNAL(activated()),m_view,SLOT(slotTrash())); 500 connect(m_aTrash,SIGNAL(activated()),m_view,SLOT(slotTrash()));
499 501
500 m_aViewfile = new QAction( tr( "Display image" ), Resource::loadIconSet("mag"), 0, 0, this, 0, true ); 502 m_aViewfile = new QAction( tr( "Display image" ), Resource::loadIconSet("mag"), 0, 0, this, 0, true );
501 m_aViewfile->setToggleAction(false); 503 m_aViewfile->setToggleAction(false);
502 connect(m_aViewfile,SIGNAL(activated()),m_view,SLOT(slotShowImage())); 504 connect(m_aViewfile,SIGNAL(activated()),m_view,SLOT(slotShowImage()));
503 505
504 m_aStartSlide = new QAction( tr( "Start slideshow" ), Resource::loadIconSet("play"),0, 0, this, 0, true ); 506 m_aStartSlide = new QAction( tr( "Start slideshow" ), Resource::loadIconSet("play"),0, 0, this, 0, true );
505 m_aStartSlide->setToggleAction(false); 507 m_aStartSlide->setToggleAction(false);
506 connect(m_aStartSlide,SIGNAL(activated()),m_view,SLOT(slotStartSlide())); 508 connect(m_aStartSlide,SIGNAL(activated()),m_view,SLOT(slotStartSlide()));
507 509
508 m_aHideToolbar = new QAction( tr( "Show toolbar" ), Resource::loadIconSet( "UtilsIcon" ), 0, 0, this, 0, true ); 510 m_aHideToolbar = new QAction( tr( "Show toolbar" ), Resource::loadIconSet( "UtilsIcon" ), 0, 0, this, 0, true );
509 m_aHideToolbar->setOn (true); 511 m_aHideToolbar->setOn (true);
510 connect(m_aHideToolbar,SIGNAL(toggled(bool)),this,SLOT(showToolbar(bool))); 512 connect(m_aHideToolbar,SIGNAL(toggled(bool)),this,SLOT(showToolbar(bool)));
511 513
512 m_aSetup = new QAction( tr( "Settings" ), Resource::loadIconSet("SettingsIcon"), 0, 0, this, 0, true ); 514 m_aSetup = new QAction( tr( "Settings" ), Resource::loadIconSet("SettingsIcon"), 0, 0, this, 0, true );
513 m_aSetup->setToggleAction(false); 515 m_aSetup->setToggleAction(false);
514 connect(m_aSetup,SIGNAL(activated()),this,SLOT(slotConfig())); 516 connect(m_aSetup,SIGNAL(activated()),this,SLOT(slotConfig()));
515 517
516 m_gListViewMode = new QActionGroup(this,"Select listmode",true); 518 m_gListViewMode = new QActionGroup(this,"Select listmode",true);
517 connect(m_gListViewMode,SIGNAL(selected(QAction*)),this,SLOT(listviewselected(QAction*))); 519 connect(m_gListViewMode,SIGNAL(selected(QAction*)),this,SLOT(listviewselected(QAction*)));
518 520
519 m_aDirLong = new QAction( tr( "Thumbnail and Imageinfo" ),Resource::loadIconSet("opie-eye/opie-eye-thumb"), 0, 0, this, 0, true ); 521 m_aDirLong = new QAction( tr( "Thumbnail and Imageinfo" ),Resource::loadIconSet("opie-eye/opie-eye-thumb"), 0, 0, this, 0, true );
520 m_aDirLong->setToggleAction(true); 522 m_aDirLong->setToggleAction(true);
521 m_aDirShort = new QAction( tr( "Thumbnail and name" ),Resource::loadIconSet("opie-eye/opie-eye-thumbonly"), 0, 0, this, 0, true ); 523 m_aDirShort = new QAction( tr( "Thumbnail and name" ),Resource::loadIconSet("opie-eye/opie-eye-thumbonly"), 0, 0, this, 0, true );
522 m_aDirShort->setToggleAction(true); 524 m_aDirShort->setToggleAction(true);
523 m_aDirName = new QAction( tr( "Name only" ), Resource::loadIconSet("opie-eye/opie-eye-textview"),0, 0, this, 0, true ); 525 m_aDirName = new QAction( tr( "Name only" ), Resource::loadIconSet("opie-eye/opie-eye-textview"),0, 0, this, 0, true );
524 m_aDirName->setToggleAction(true); 526 m_aDirName->setToggleAction(true);
525 int mode = m_cfg->readNumEntry("ListViewMode", 1); 527 int mode = m_cfg->readNumEntry("ListViewMode", 1);
526 if (mode < 1 || mode>3) mode = 1; 528 if (mode < 1 || mode>3) mode = 1;
527 switch (mode) { 529 switch (mode) {
528 case 3: 530 case 3:
529 m_aDirName->setOn(true); 531 m_aDirName->setOn(true);
530 break; 532 break;
531 case 2: 533 case 2:
532 m_aDirShort->setOn(true); 534 m_aDirShort->setOn(true);
533 break; 535 break;
534 case 1: 536 case 1:
535 default: 537 default:
536 m_aDirLong->setOn(true); 538 m_aDirLong->setOn(true);
537 } 539 }
538 m_gListViewMode->insert(m_aDirLong); 540 m_gListViewMode->insert(m_aDirLong);
539 m_gListViewMode->insert(m_aDirShort); 541 m_gListViewMode->insert(m_aDirShort);
540 m_gListViewMode->insert(m_aDirName); 542 m_gListViewMode->insert(m_aDirName);
541 543
542 m_gPrevNext = new QActionGroup(this,"imageprevnext",false); 544 m_gPrevNext = new QActionGroup(this,"imageprevnext",false);
543 m_aNext = new QAction( tr( "Next image" ), Resource::loadIconSet("forward"), 0, 0, this, 0, true ); 545 m_aNext = new QAction( tr( "Next image" ), Resource::loadIconSet("forward"), 0, 0, this, 0, true );
544 m_aNext->setToggleAction(false); 546 m_aNext->setToggleAction(false);
545 connect(m_aNext,SIGNAL(activated()),m_view,SLOT(slotShowNext())); 547 connect(m_aNext,SIGNAL(activated()),m_view,SLOT(slotShowNext()));
546 m_aPrevious = new QAction( tr( "Previous image" ), Resource::loadIconSet("back"), 0, 0, this, 0, true ); 548 m_aPrevious = new QAction( tr( "Previous image" ), Resource::loadIconSet("back"), 0, 0, this, 0, true );
547 m_aPrevious->setToggleAction(false); 549 m_aPrevious->setToggleAction(false);
548 connect(m_aPrevious,SIGNAL(activated()),m_view,SLOT(slotShowPrev())); 550 connect(m_aPrevious,SIGNAL(activated()),m_view,SLOT(slotShowPrev()));
549 m_gPrevNext->insert(m_aPrevious); 551 m_gPrevNext->insert(m_aPrevious);
550 m_gPrevNext->insert(m_aNext); 552 m_gPrevNext->insert(m_aNext);
551 553
552 m_aFullScreen = new QAction( tr( "Show images fullscreen" ), 554 m_aFullScreen = new QAction( tr( "Show images fullscreen" ),
553 Resource::loadIconSet("fullscreen"), 0, 0, this, 0, true ); 555 Resource::loadIconSet("fullscreen"), 0, 0, this, 0, true );
554 m_aFullScreen->setToggleAction(true); 556 m_aFullScreen->setToggleAction(true);
555 if (autoSave) { 557 if (autoSave) {
556 m_aFullScreen->setOn(m_cfg->readBoolEntry("fullscreen",false)); 558 m_aFullScreen->setOn(m_cfg->readBoolEntry("fullscreen",false));
557 } else { 559 } else {
558 m_aFullScreen->setOn(false); 560 m_aFullScreen->setOn(false);
559 } 561 }
560 connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool))); 562 connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool)));
561 563
562 m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false); 564 m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false);
563 m_aAutoRotate = new QAction( tr( "Auto rotate images" ), Resource::loadIconSet( "rotate" ), 0, 0, this, 0, true ); 565 m_aAutoRotate = new QAction( tr( "Auto rotate images" ), Resource::loadIconSet( "rotate" ), 0, 0, this, 0, true );
564 m_aAutoRotate->setToggleAction(true); 566 m_aAutoRotate->setToggleAction(true);
565 567
566 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 568 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
567 m_aAutoRotate->setOn(true); 569 m_aAutoRotate->setOn(true);
568 } else { 570 } else {
569 m_aAutoRotate->setOn(false); 571 m_aAutoRotate->setOn(false);
570 } 572 }
571 if (autoSave) { 573 if (autoSave) {
572 m_aAutoRotate->setOn(m_cfg->readBoolEntry("autorotate",m_aAutoRotate->isOn())); 574 m_aAutoRotate->setOn(m_cfg->readBoolEntry("autorotate",m_aAutoRotate->isOn()));
573 } 575 }
574 connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); 576 connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool)));
575 577
576 m_aUnscaled = new QAction( tr( "Show images unscaled" ), Resource::loadIconSet( "1to1" ), 0, 0, this, 0, true ); 578 m_aUnscaled = new QAction( tr( "Show images unscaled" ), Resource::loadIconSet( "1to1" ), 0, 0, this, 0, true );
577 m_aUnscaled->setToggleAction(true); 579 m_aUnscaled->setToggleAction(true);
578 connect(m_aUnscaled,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); 580 connect(m_aUnscaled,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool)));
579 if (autoSave) { 581 if (autoSave) {
580 m_aUnscaled->setOn(m_cfg->readBoolEntry("unscaled",false)); 582 m_aUnscaled->setOn(m_cfg->readBoolEntry("unscaled",false));
581 } else { 583 } else {
582 m_aUnscaled->setOn(false); 584 m_aUnscaled->setOn(false);
583 } 585 }
584 586
585 m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), Resource::loadIconSet( "mag" ), 0, 0, this, 0, true ); 587 m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), Resource::loadIconSet( "mag" ), 0, 0, this, 0, true );
586 m_aZoomer->setToggleAction(true); 588 m_aZoomer->setToggleAction(true);
587 if (autoSave) { 589 if (autoSave) {
588 m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true)); 590 m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true));
589 } else { 591 } else {
590 m_aZoomer->setOn (true); 592 m_aZoomer->setOn (true);
591 } 593 }
592 connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); 594 connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool)));
593 m_gDisplayType->insert(m_aAutoRotate); 595 m_gDisplayType->insert(m_aAutoRotate);
594 m_gDisplayType->insert(m_aUnscaled); 596 m_gDisplayType->insert(m_aUnscaled);
595 m_gDisplayType->insert(m_aZoomer); 597 m_gDisplayType->insert(m_aZoomer);
596 598
597 m_hGroup = new QActionGroup(this,"actioncollection",false); 599 m_hGroup = new QActionGroup(this,"actioncollection",false);
598 m_hGroup->insert(m_aFullScreen); 600 m_hGroup->insert(m_aFullScreen);
599} 601}
600 602
601void PMainWindow::setupToolbar() 603void PMainWindow::setupToolbar()
602{ 604{
603 toolBar = new QToolBar( this ); 605 toolBar = new QToolBar( this );
604 addToolBar(toolBar); 606 addToolBar(toolBar);
605 toolBar->setHorizontalStretchable( true ); 607 toolBar->setHorizontalStretchable( true );
606 setToolBarsMovable( false ); 608 setToolBarsMovable( false );
607 m_aDirUp->addTo( toolBar ); 609 m_aDirUp->addTo( toolBar );
608 610
609 fsButton = new PFileSystem( toolBar ); 611 fsButton = new PFileSystem( toolBar );
610 connect( fsButton, SIGNAL( changeDir( const QString& ) ), 612 connect( fsButton, SIGNAL( changeDir( const QString& ) ),
611 m_view, SLOT(slotChangeDir( const QString& ) ) ); 613 m_view, SLOT(slotChangeDir( const QString& ) ) );
612 connect( this, SIGNAL( changeDir( const QString& ) ), 614 connect( this, SIGNAL( changeDir( const QString& ) ),
613 m_view, SLOT(slotChangeDir( const QString& ) ) ); 615 m_view, SLOT(slotChangeDir( const QString& ) ) );
614 616
615 if (m_aBeam) { 617 if (m_aBeam) {
616 m_aBeam->addTo( toolBar ); 618 m_aBeam->addTo( toolBar );
617 } 619 }
618 m_aShowInfo->addTo(toolBar); 620 m_aShowInfo->addTo(toolBar);
619 m_aTrash->addTo(toolBar); 621 m_aTrash->addTo(toolBar);
620// m_aSetup->addTo(toolBar); 622// m_aSetup->addTo(toolBar);
621 623
622 m_gDisplayType->addTo(toolBar); 624 m_gDisplayType->addTo(toolBar);
623 625
624 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 626 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
625 m_gPrevNext->addTo(toolBar); 627 m_gPrevNext->addTo(toolBar);
626 } else { 628 } else {
627 m_gPrevNext->setEnabled(false); 629 m_gPrevNext->setEnabled(false);
628 } 630 }
629} 631}
630 632
631void PMainWindow::setupMenu() 633void PMainWindow::setupMenu()
632{ 634{
633 fileMenu = new QPopupMenu( menuBar() ); 635 fileMenu = new QPopupMenu( menuBar() );
634 menuBar()->insertItem( tr( "File" ), fileMenu ); 636 menuBar()->insertItem( tr( "File" ), fileMenu );
635 dispMenu = new QPopupMenu( menuBar() ); 637 dispMenu = new QPopupMenu( menuBar() );
636 menuBar()->insertItem( tr( "Show" ), dispMenu ); 638 menuBar()->insertItem( tr( "Show" ), dispMenu );
637 settingsMenu = new QPopupMenu( menuBar() ); 639 settingsMenu = new QPopupMenu( menuBar() );
638 menuBar()->insertItem( tr( "Settings" ), settingsMenu ); 640 menuBar()->insertItem( tr( "Settings" ), settingsMenu );
639 641
640 m_aViewfile->addTo(fileMenu); 642 m_aViewfile->addTo(fileMenu);
641 m_aShowInfo->addTo(fileMenu); 643 m_aShowInfo->addTo(fileMenu);
642 m_aStartSlide->addTo(fileMenu); 644 m_aStartSlide->addTo(fileMenu);
643 645
644 fileMenu->insertSeparator(); 646 fileMenu->insertSeparator();
645 m_aDirUp->addTo( fileMenu ); 647 m_aDirUp->addTo( fileMenu );
646 648
647 fsMenu = new QPopupMenu(fileMenu); 649 fsMenu = new QPopupMenu(fileMenu);
648 fileMenu->insertItem(Resource::loadIconSet( "cardmon/pcmcia" ),tr("Select filesystem"),fsMenu); 650 fileMenu->insertItem(Resource::loadIconSet( "cardmon/pcmcia" ),tr("Select filesystem"),fsMenu);
649 connect( fsMenu, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) ); 651 connect( fsMenu, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) );
650 dirChanged(); 652 dirChanged();
651 653
652 if ( m_aBeam ) { 654 if ( m_aBeam ) {
653 fileMenu->insertSeparator(); 655 fileMenu->insertSeparator();
654 m_aBeam->addTo( fileMenu ); 656 m_aBeam->addTo( fileMenu );
655 } 657 }
656 fileMenu->insertSeparator(); 658 fileMenu->insertSeparator();
657 m_aTrash->addTo(fileMenu); 659 m_aTrash->addTo(fileMenu);
658 660
659 listviewMenu = new QPopupMenu(dispMenu); 661 listviewMenu = new QPopupMenu(dispMenu);
660 dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu); 662 dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu);
661 m_gListViewMode->addTo(listviewMenu); 663 m_gListViewMode->addTo(listviewMenu);
662 dispMenu->insertSeparator(); 664 dispMenu->insertSeparator();
663 m_aFullScreen->addTo(dispMenu); 665 m_aFullScreen->addTo(dispMenu);
664 m_gDisplayType->addTo(dispMenu); 666 m_gDisplayType->addTo(dispMenu);
665 dispMenu->insertSeparator(); 667 dispMenu->insertSeparator();
666 m_gPrevNext->addTo(dispMenu); 668 m_gPrevNext->addTo(dispMenu);
667 669
668 m_aSetup->addTo(settingsMenu); 670 m_aSetup->addTo(settingsMenu);
669 m_aHideToolbar->addTo(settingsMenu); 671 m_aHideToolbar->addTo(settingsMenu);
670} 672}
671 673
672void PMainWindow::listviewselected(QAction*which) 674void PMainWindow::listviewselected(QAction*which)
673{ 675{
674 if (!which || which->isOn()==false) return; 676 if (!which || which->isOn()==false) return;
675 int val = 1; 677 int val = 1;
676// QString name; 678// QString name;
677 679
678 if (which==m_aDirName) { 680 if (which==m_aDirName) {
679 val = 3; 681 val = 3;
680// name = "opie-eye/opie-eye-textview"; 682// name = "opie-eye/opie-eye-textview";
681 } else if (which==m_aDirShort) { 683 } else if (which==m_aDirShort) {
682 val = 2; 684 val = 2;
683// name = "opie-eye/opie-eye-thumbonly"; 685// name = "opie-eye/opie-eye-thumbonly";
684 } else if (which==m_aDirLong) { 686 } else if (which==m_aDirLong) {
685 val = 1; 687 val = 1;
686// name = "opie-eye/opie-eye-thumb"; 688// name = "opie-eye/opie-eye-thumb";
687 } 689 }
688 emit changeListMode(val); 690 emit changeListMode(val);
689} 691}
690 692
691void PMainWindow::readConfig() 693void PMainWindow::readConfig()
692{ 694{
693 autoSave =m_cfg->readBoolEntry("base_savestatus",true); 695 autoSave =m_cfg->readBoolEntry("base_savestatus",true);
694} 696}
diff --git a/noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp b/noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp
index 97e3dcb..fc502d4 100644
--- a/noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp
+++ b/noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp
@@ -1,29 +1,33 @@
1#include "dir_lister.h" 1#include "dir_lister.h"
2#include "dir_ifaceinfo.h" 2#include "dir_ifaceinfo.h"
3#include "dir_dirview.h" 3#include "dir_dirview.h"
4 4
5PHUNK_VIEW_INTERFACE("Dir View", Dir_DirView ); 5PHUNK_VIEW_INTERFACE("Dir View", Dir_DirView );
6 6
7 7
8Dir_DirView::Dir_DirView( const Config& cfg) 8Dir_DirView::Dir_DirView( const Config& cfg)
9 : PDirView(cfg) 9 : PDirView(cfg)
10{ 10{
11 m_cfg = cfg.readBoolEntry( "Dir_Check_All_Files", true); 11 m_cfg = cfg.readBoolEntry( "Dir_Check_All_Files", false);
12 m_recursive = cfg.readBoolEntry( "Dir_Check_Recursive_Files", false);
13 m_recursive_depth = cfg.readNumEntry("Dir_Recursive_Files_Depth",10);
12 m_lister = 0; 14 m_lister = 0;
13 m_info = 0; 15 m_info = 0;
14} 16}
15 17
16Dir_DirView::~Dir_DirView() { 18Dir_DirView::~Dir_DirView() {
17} 19}
18 20
19PInterfaceInfo* Dir_DirView::interfaceInfo()const{ 21PInterfaceInfo* Dir_DirView::interfaceInfo()const{
20 if (!m_info ) 22 if (!m_info ) {
21 m_info =new DirInterfaceInfo; 23 m_info = new DirInterfaceInfo;
24 }
22 return m_info; 25 return m_info;
23} 26}
24 27
25PDirLister* Dir_DirView::dirLister()const{ 28PDirLister* Dir_DirView::dirLister()const{
26 if (!m_lister ) 29 if (!m_lister ) {
27 m_lister = new Dir_DirLister(m_cfg); 30 m_lister = new Dir_DirLister(m_cfg,m_recursive,m_recursive_depth);
31 }
28 return m_lister; 32 return m_lister;
29} 33}
diff --git a/noncore/graphics/opie-eye/impl/dir/dir_dirview.h b/noncore/graphics/opie-eye/impl/dir/dir_dirview.h
index 3b9b7a6..89cf6c9 100644
--- a/noncore/graphics/opie-eye/impl/dir/dir_dirview.h
+++ b/noncore/graphics/opie-eye/impl/dir/dir_dirview.h
@@ -1,24 +1,26 @@
1/* 1/*
2 * GPLv2 only zecke@handhelds.org 2 * GPLv2 only zecke@handhelds.org
3 */ 3 */
4 4
5#ifndef DIR_DIR_VIEW_H 5#ifndef DIR_DIR_VIEW_H
6#define DIR_DIR_VIEW_H 6#define DIR_DIR_VIEW_H
7 7
8#include <iface/dirview.h> 8#include <iface/dirview.h>
9 9
10 10
11struct Dir_DirView : public PDirView { 11struct Dir_DirView : public PDirView {
12 Dir_DirView( const Config& ); 12 Dir_DirView( const Config& );
13 ~Dir_DirView(); 13 ~Dir_DirView();
14 14
15 PInterfaceInfo* interfaceInfo()const; 15 PInterfaceInfo* interfaceInfo()const;
16 PDirLister* dirLister()const; 16 PDirLister* dirLister()const;
17private: 17private:
18 bool m_cfg : 1; 18 bool m_cfg : 1;
19 bool m_recursive:1;
20 int m_recursive_depth;
19 mutable PDirLister* m_lister; 21 mutable PDirLister* m_lister;
20 mutable PInterfaceInfo *m_info; 22 mutable PInterfaceInfo *m_info;
21}; 23};
22 24
23 25
24#endif 26#endif
diff --git a/noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp b/noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp
index 9c69ce5..1e4ec40 100644
--- a/noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp
+++ b/noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp
@@ -1,58 +1,82 @@
1/* 1/*
2 * GPLv2 2 * GPLv2
3 * zecke@handhelds.org 3 * zecke@handhelds.org
4 */ 4 */
5 5
6#include "dir_ifaceinfo.h" 6#include "dir_ifaceinfo.h"
7 7
8/* OPIE */ 8/* OPIE */
9#include <opie2/odebug.h> 9#include <opie2/odebug.h>
10#include <qpe/config.h> 10#include <qpe/config.h>
11 11
12/* QT */ 12/* QT */
13#include <qwidget.h> 13#include <qwidget.h>
14#include <qcheckbox.h> 14#include <qcheckbox.h>
15#include <qframe.h> 15#include <qframe.h>
16#include <qhbox.h> 16#include <qhbox.h>
17#include <qlabel.h> 17#include <qlabel.h>
18#include <qlayout.h> 18#include <qlayout.h>
19#include <qspinbox.h>
19 20
20namespace { 21namespace {
21 class DirImageWidget : public QFrame { 22 class DirImageWidget : public QFrame {
22 public: 23 public:
23 DirImageWidget(): QFrame() { 24 DirImageWidget(): QFrame() {
24 setFrameStyle(Box|Raised); 25 setFrameStyle(Box|Raised);
25 QVBoxLayout *m_MainLayout = new QVBoxLayout( this, 6, 2, "m_MainLayout"); 26 QVBoxLayout *m_MainLayout = new QVBoxLayout( this, 6, 2, "m_MainLayout");
27 QGridLayout*RecDepthLayout = new QGridLayout( 0, 1, 1, 0, 6, "RecDepthLayout");
28
26 chkbox = new QCheckBox( QObject::tr("Show all files"), this ); 29 chkbox = new QCheckBox( QObject::tr("Show all files"), this );
27 m_MainLayout->addWidget(chkbox); 30 m_MainLayout->addWidget(chkbox);
31 recWarningLabel = new QLabel(this);
32 recWarningLabel->setText(QObject::tr("<center><b>Be carefull with the following options!</b></center>"));
33 m_MainLayout->addWidget(recWarningLabel);
34 recBox = new QCheckBox( QObject::tr("Show files recursive"),this);
35 m_MainLayout->addWidget(recBox);
36 recDepthLabel = new QLabel(this);
37 recDepthLabel->setText(QObject::tr("Recursion depth:"));
38 RecDepthLayout->addWidget(recDepthLabel,0,0);
39 recDepth = new QSpinBox(this);
40 recDepth->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed));
41 recDepth->setMaxValue(10);
42 recDepth->setMinValue(1);
43 recDepth->setSuffix(QObject::tr(" directories"));
44 RecDepthLayout->addWidget(recDepth,0,1);
45 m_MainLayout->addLayout(RecDepthLayout);
28 QSpacerItem *spacer1 = new QSpacerItem( 20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding ); 46 QSpacerItem *spacer1 = new QSpacerItem( 20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding );
29 m_MainLayout->addItem( spacer1 ); 47 m_MainLayout->addItem( spacer1 );
30 48
31 } 49 }
32 ~DirImageWidget() {} 50 ~DirImageWidget() {}
33 QCheckBox* chkbox; 51 QCheckBox* chkbox,*recBox;
52 QSpinBox * recDepth;
53 QLabel* recDepthLabel,*recWarningLabel;
54
34 }; 55 };
35} 56}
36 57
37 58
38DirInterfaceInfo::DirInterfaceInfo() { 59DirInterfaceInfo::DirInterfaceInfo() {
39} 60}
40DirInterfaceInfo::~DirInterfaceInfo() { 61DirInterfaceInfo::~DirInterfaceInfo() {
41} 62}
42 63
43QString DirInterfaceInfo::name()const { 64QString DirInterfaceInfo::name()const {
44 return QObject::tr("Directory View" ); 65 return QObject::tr("Directory View" );
45} 66}
46 67
47QWidget* DirInterfaceInfo::configWidget(const Config& cfg) { 68QWidget* DirInterfaceInfo::configWidget(const Config& cfg) {
48 DirImageWidget* wid = new DirImageWidget(); 69 DirImageWidget* wid = new DirImageWidget();
49 wid->chkbox->setChecked( cfg.readBoolEntry("Dir_Check_All_Files", true) ); 70 wid->chkbox->setChecked(cfg.readBoolEntry("Dir_Check_All_Files",false));
50 71 wid->recBox->setChecked(cfg.readBoolEntry("Dir_Check_Recursive_Files",false));
72 wid->recDepth->setValue(cfg.readNumEntry("Dir_Recursive_Files_Depth",10));
51 return wid; 73 return wid;
52} 74}
53 75
54void DirInterfaceInfo::writeConfig( QWidget* _wid, Config& cfg) { 76void DirInterfaceInfo::writeConfig( QWidget* _wid, Config& cfg) {
55 owarn << "Write Config" << oendl; 77 owarn << "Write Config" << oendl;
56 DirImageWidget* wid = static_cast<DirImageWidget*>(_wid); 78 DirImageWidget* wid = static_cast<DirImageWidget*>(_wid);
57 cfg.writeEntry("Dir_Check_All_Files", wid->chkbox->isChecked() ); 79 cfg.writeEntry("Dir_Check_All_Files", wid->chkbox->isChecked());
80 cfg.writeEntry("Dir_Check_Recursive_Files", wid->recBox->isChecked());
81 cfg.writeEntry("Dir_Recursive_Files_Depth",wid->recDepth->value());
58} 82}
diff --git a/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp b/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp
index d8b332a..ff33cf2 100644
--- a/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp
+++ b/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp
@@ -1,92 +1,111 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 */ 3 */
4 4
5#include "dir_lister.h" 5#include "dir_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>
13using namespace Opie::Core; 13using namespace Opie::Core;
14 14
15/* QT */ 15/* QT */
16#include <qdir.h> 16#include <qdir.h>
17#include <qfileinfo.h> 17#include <qfileinfo.h>
18 18
19Dir_DirLister::Dir_DirLister( bool list ) 19Dir_DirLister::Dir_DirLister( bool list,bool rec,int recdepth )
20 : PDirLister( "dir_dir_lister" ) 20 : PDirLister( "dir_dir_lister" )
21{ 21{
22 m_allFiles = list; 22 m_allFiles = list;
23 m_recursive = rec;
24 m_recDepth = recdepth;
25 if (m_recDepth<1) m_recDepth = 1;
26 if (m_recDepth>10) m_recDepth = 10;
23 owarn << "All Files " << m_allFiles << "" << oendl; 27 owarn << "All Files " << m_allFiles << "" << oendl;
24 SlaveHelper::slaveConnectSignals( this ); 28 SlaveHelper::slaveConnectSignals( this );
29 m_Filter = (m_allFiles?"*":"*.jpg;*.jpeg;*.JPG;*.PNG;*.GIF;*.BMP;*.png;*.bmp;*.gif");
25} 30}
26 31
27QString Dir_DirLister::defaultPath()const { 32QString Dir_DirLister::defaultPath()const {
28 return QPEApplication::documentDir(); 33 return QPEApplication::documentDir();
29} 34}
30 35
31QString Dir_DirLister::setStartPath( const QString& path ) { 36QString Dir_DirLister::setStartPath( const QString& path ) {
32 m_currentDir.cd( path ); 37 m_currentDir.cd( path );
33 if (!m_currentDir.exists() ) 38 if (!m_currentDir.exists() )
34 m_currentDir.cd(defaultPath()); 39 m_currentDir.cd(defaultPath());
35 40
36 41
37 return m_currentDir.absPath(); 42 return m_currentDir.absPath();
38} 43}
39 44
40QString Dir_DirLister::currentPath()const { 45QString Dir_DirLister::currentPath()const {
41 return m_currentDir.absPath(); 46 return m_currentDir.absPath();
42} 47}
43 48
44 49
45QStringList Dir_DirLister::folders()const { 50QStringList Dir_DirLister::folders()const {
46 return m_currentDir.entryList( QDir::Dirs ); 51 return m_currentDir.entryList( QDir::Dirs );
47} 52}
48 53
49QStringList Dir_DirLister::files()const { 54QStringList Dir_DirLister::recFiles(const QString&aPath,int currentDepth)const
50 if ( m_allFiles ) 55{
51 return m_currentDir.entryList( QDir::Files ); 56 QStringList all;
52 else { 57 if (currentDepth>m_recDepth) return all;
53 QStringList out; 58
54 QStringList list = m_currentDir.entryList( QDir::Files | QDir::Readable ); 59 QString subPath;
55 for (QStringList::Iterator it = list.begin(); it != list.end();++it ) { 60 subPath = aPath;
56 QFileInfo inf( *it ); 61 if (subPath.length()==0) {
57 QString ext = inf.extension(false).lower(); 62 subPath=".";
58 if( ext == QString::fromLatin1("jpg") || 63 }
59 ext == QString::fromLatin1("jpeg" ) || 64 QDir checkDir(currentPath()+"/"+aPath);
60 ext == QString::fromLatin1("png" ) || 65
61 ext == QString::fromLatin1("bmp" ) || 66 QStringList p = checkDir.entryList( QDir::Dirs );
62 ext == QString::fromLatin1("gif" ) ) 67 all+=checkDir.entryList(m_Filter,QDir::Files|QDir::Readable);
63 out.append( *it ); 68 QStringList tmp;
69 for (unsigned i = 0; i < p.count();++i) {
70 if (p[i]=="." || p[i]=="..") continue;
71 tmp =recFiles(subPath+"/"+p[i],currentDepth+1);
72 for (unsigned j = 0; j < tmp.count();++j) {
73 all.append(p[i]+"/"+tmp[j]);
64 } 74 }
65 return out;
66 } 75 }
76 return all;
77}
78
79QStringList Dir_DirLister::files()const
80{
81 if (m_recursive) {
82 odebug << "Startpfad: "<<m_currentDir.absPath()<<oendl;
83 return recFiles("",0);
84 }
85 return m_currentDir.entryList(m_Filter,QDir::Files|QDir::Readable);
67} 86}
68 87
69void Dir_DirLister::deleteImage( const QString& fl) { 88void Dir_DirLister::deleteImage( const QString& fl) {
70 QFile::remove( fl ); 89 QFile::remove( fl );
71} 90}
72 91
73void Dir_DirLister::thumbNail( const QString& str, int w, int h) { 92void Dir_DirLister::thumbNail( const QString& str, int w, int h) {
74 SlaveMaster::self()->thumbNail( str, w, h ); 93 SlaveMaster::self()->thumbNail( str, w, h );
75} 94}
76 95
77QImage Dir_DirLister::image( const QString& str, Factor f, int m) { 96QImage Dir_DirLister::image( const QString& str, Factor f, int m) {
78 return SlaveMaster::self()->image( str, f, m ); 97 return SlaveMaster::self()->image( str, f, m );
79} 98}
80 99
81void Dir_DirLister::imageInfo( const QString& str) { 100void Dir_DirLister::imageInfo( const QString& str) {
82 SlaveMaster::self()->thumbInfo( str ); 101 SlaveMaster::self()->thumbInfo( str );
83} 102}
84 103
85void Dir_DirLister::fullImageInfo( const QString& str) { 104void Dir_DirLister::fullImageInfo( const QString& str) {
86 SlaveMaster::self()->imageInfo( str ); 105 SlaveMaster::self()->imageInfo( str );
87} 106}
88 107
89QString Dir_DirLister::nameToFname(const QString&name)const 108QString Dir_DirLister::nameToFname(const QString&name)const
90{ 109{
91 return name; 110 return name;
92} 111}
diff --git a/noncore/graphics/opie-eye/impl/dir/dir_lister.h b/noncore/graphics/opie-eye/impl/dir/dir_lister.h
index d6ca6c0..445adbf 100644
--- a/noncore/graphics/opie-eye/impl/dir/dir_lister.h
+++ b/noncore/graphics/opie-eye/impl/dir/dir_lister.h
@@ -1,37 +1,45 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 */ 3 */
4 4
5#ifndef DIR_LISTER_INTERFACE_LISTER_H 5#ifndef DIR_LISTER_INTERFACE_LISTER_H
6#define DIR_LISTER_INTERFACE_LISTER_H 6#define DIR_LISTER_INTERFACE_LISTER_H
7 7
8#include <qdir.h> 8#include <qdir.h>
9 9
10#include <iface/dirlister.h> 10#include <iface/dirlister.h>
11 11
12class Config; 12class Config;
13class Dir_DirLister : public PDirLister { 13class Dir_DirLister : public PDirLister {
14 Q_OBJECT 14 Q_OBJECT
15public: 15public:
16 Dir_DirLister( bool ); 16 Dir_DirLister(bool,bool,int);
17 virtual ~Dir_DirLister(){} 17 virtual ~Dir_DirLister(){}
18 18
19 QString defaultPath()const; 19 QString defaultPath()const;
20 QString setStartPath( const QString& ); 20 QString setStartPath( const QString& );
21 QString currentPath()const; 21 QString currentPath()const;
22 QStringList folders()const; 22 QStringList folders()const;
23 QStringList files()const; 23 QStringList files()const;
24 24
25 void deleteImage( const QString& ); 25 void deleteImage( const QString& );
26 void thumbNail( const QString&, int, int ); 26 void thumbNail( const QString&, int, int );
27 QImage image( const QString&, Factor, int ); 27 QImage image( const QString&, Factor, int );
28 void imageInfo( const QString& ); 28 void imageInfo( const QString& );
29 void fullImageInfo( const QString& ); 29 void fullImageInfo( const QString& );
30 virtual QString nameToFname(const QString&name)const; 30 virtual QString nameToFname(const QString&name)const;
31 31
32private: 32private:
33 bool m_allFiles; 33 bool m_allFiles:1;
34 bool m_recursive:1;
35 int m_recDepth;
34 QDir m_currentDir; 36 QDir m_currentDir;
37 //! recursive listing.
38 /*!
39 * \param path this is the offset to the current path. eg. when currentDepth = 0 then it MUST empty
40 */
41 QStringList recFiles(const QString&path,int currentDepth)const;
42 QString m_Filter;
35}; 43};
36 44
37#endif 45#endif