-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 6 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 1 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_lister.cpp | 40 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_lister.h | 1 |
4 files changed, 28 insertions, 20 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 087db30..77597d2 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -50,579 +50,583 @@ namespace { | |||
50 | QString path()const { return m_path; } | 50 | QString path()const { return m_path; } |
51 | bool isDir()const { return m_isDir; } | 51 | bool isDir()const { return m_isDir; } |
52 | void setText( const QString& ); | 52 | void setText( const QString& ); |
53 | bool textOnly()const{return m_textOnly;} | 53 | bool textOnly()const{return m_textOnly;} |
54 | void setTextOnly(bool how){m_textOnly=how;} | 54 | void setTextOnly(bool how){m_textOnly=how;} |
55 | /* just for starting recalc of item rect! */ | 55 | /* just for starting recalc of item rect! */ |
56 | virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); | 56 | virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); |
57 | /* just for starting recalc of item rect! */ | 57 | /* just for starting recalc of item rect! */ |
58 | virtual void setPixmap( const QPixmap & icon); | 58 | virtual void setPixmap( const QPixmap & icon); |
59 | 59 | ||
60 | protected: | 60 | protected: |
61 | mutable QPixmap* m_pix; | 61 | mutable QPixmap* m_pix; |
62 | 62 | ||
63 | private: | 63 | private: |
64 | QString m_path; | 64 | QString m_path; |
65 | bool m_isDir : 1; | 65 | bool m_isDir : 1; |
66 | bool m_noInfo :1; | 66 | bool m_noInfo :1; |
67 | bool m_textOnly:1; | 67 | bool m_textOnly:1; |
68 | bool m_NameOnly:1; | 68 | bool m_NameOnly:1; |
69 | bool m_Pixset:1; | 69 | bool m_Pixset:1; |
70 | }; | 70 | }; |
71 | class TextViewItem : public IconViewItem { | 71 | class TextViewItem : public IconViewItem { |
72 | TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); | 72 | TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); |
73 | QPixmap *pixmap()const; | 73 | QPixmap *pixmap()const; |
74 | void setText( const QString& ); | 74 | void setText( const QString& ); |
75 | }; | 75 | }; |
76 | class ThumbViewItem : public IconViewItem { | 76 | class ThumbViewItem : public IconViewItem { |
77 | ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); | 77 | ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); |
78 | QPixmap *pixmap()const; | 78 | QPixmap *pixmap()const; |
79 | void setText( const QString& ); | 79 | void setText( const QString& ); |
80 | }; | 80 | }; |
81 | 81 | ||
82 | 82 | ||
83 | /* | 83 | /* |
84 | * If we request an Image or String | 84 | * If we request an Image or String |
85 | * we add it to the map | 85 | * we add it to the map |
86 | */ | 86 | */ |
87 | static QMap<QString, IconViewItem*> g_stringInf; | 87 | static QMap<QString, IconViewItem*> g_stringInf; |
88 | static QMap<QString, IconViewItem*> g_stringPix; | 88 | static QMap<QString, IconViewItem*> g_stringPix; |
89 | 89 | ||
90 | IconViewItem::IconViewItem( QIconView* view,const QString& path, | 90 | IconViewItem::IconViewItem( QIconView* view,const QString& path, |
91 | const QString& name, bool isDir ) | 91 | const QString& name, bool isDir ) |
92 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), | 92 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), |
93 | m_noInfo( false ),m_textOnly(false),m_Pixset(false) | 93 | m_noInfo( false ),m_textOnly(false),m_Pixset(false) |
94 | { | 94 | { |
95 | if ( isDir && !_dirPix ) | 95 | if ( isDir && !_dirPix ) |
96 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); | 96 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); |
97 | else if ( !isDir && !_unkPix ) | 97 | else if ( !isDir && !_unkPix ) |
98 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); | 98 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); |
99 | } | 99 | } |
100 | 100 | ||
101 | inline void IconViewItem::setPixmap( const QPixmap & icon, bool recalc, bool redraw) | 101 | inline void IconViewItem::setPixmap( const QPixmap & icon, bool recalc, bool redraw) |
102 | { | 102 | { |
103 | m_Pixset = true; | 103 | m_Pixset = true; |
104 | calcRect(text()); | 104 | calcRect(text()); |
105 | } | 105 | } |
106 | inline void IconViewItem::setPixmap( const QPixmap & icon) | 106 | inline void IconViewItem::setPixmap( const QPixmap & icon) |
107 | { | 107 | { |
108 | m_Pixset = true; | 108 | m_Pixset = true; |
109 | calcRect(text()); | 109 | calcRect(text()); |
110 | } | 110 | } |
111 | 111 | ||
112 | inline QPixmap* IconViewItem::pixmap()const { | 112 | inline QPixmap* IconViewItem::pixmap()const { |
113 | // qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", | 113 | // qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", |
114 | // rect().x(),rect().y(),rect().width(),rect().height(), | 114 | // rect().x(),rect().y(),rect().width(),rect().height(), |
115 | // iconView()->contentsX(), iconView()->contentsY()); | 115 | // iconView()->contentsX(), iconView()->contentsY()); |
116 | 116 | ||
117 | if (textOnly()&&!m_isDir) { | 117 | if (textOnly()&&!m_isDir) { |
118 | if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); | 118 | if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); |
119 | return _emptyPix; | 119 | return _emptyPix; |
120 | } | 120 | } |
121 | if ( m_isDir ) | 121 | if ( m_isDir ) |
122 | return _dirPix; | 122 | return _dirPix; |
123 | else{ | 123 | else{ |
124 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { | 124 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { |
125 | currentView()->dirLister()->imageInfo( m_path ); | 125 | currentView()->dirLister()->imageInfo( m_path ); |
126 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); | 126 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); |
127 | } | 127 | } |
128 | 128 | ||
129 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); | 129 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); |
130 | if (!m_pix && !g_stringPix.contains( m_path )) { | 130 | if (!m_pix && !g_stringPix.contains( m_path )) { |
131 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); | 131 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); |
132 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); | 132 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); |
133 | } | 133 | } |
134 | return m_pix ? m_pix : _unkPix; | 134 | return m_pix ? m_pix : _unkPix; |
135 | } | 135 | } |
136 | } | 136 | } |
137 | inline void IconViewItem::setText( const QString& str ) { | 137 | inline void IconViewItem::setText( const QString& str ) { |
138 | QString text = QIconViewItem::text()+"\n"+str; | 138 | QString text = QIconViewItem::text()+"\n"+str; |
139 | m_noInfo = true; | 139 | m_noInfo = true; |
140 | QIconViewItem::setText( text ); | 140 | QIconViewItem::setText( text ); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | 144 | ||
145 | /* | 145 | /* |
146 | * Set up the GUI.. initialize the slave set up gui | 146 | * Set up the GUI.. initialize the slave set up gui |
147 | * and also load a dir | 147 | * and also load a dir |
148 | */ | 148 | */ |
149 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | 149 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) |
150 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) | 150 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) |
151 | { | 151 | { |
152 | { | 152 | { |
153 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 153 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
154 | } | 154 | } |
155 | m_path = QDir::homeDirPath(); | 155 | m_path = QDir::homeDirPath(); |
156 | m_mode = 0; | 156 | m_mode = 0; |
157 | 157 | ||
158 | QHBox *hbox = new QHBox( this ); | 158 | QHBox *hbox = new QHBox( this ); |
159 | QLabel* lbl = new QLabel( hbox ); | 159 | QLabel* lbl = new QLabel( hbox ); |
160 | lbl->setText( tr("View as" ) ); | 160 | lbl->setText( tr("View as" ) ); |
161 | 161 | ||
162 | m_views = new QComboBox( hbox, "View As" ); | 162 | m_views = new QComboBox( hbox, "View As" ); |
163 | connect( m_views, SIGNAL(activated(int)), | 163 | connect( m_views, SIGNAL(activated(int)), |
164 | this, SLOT(slotViewChanged(int)) ); | 164 | this, SLOT(slotViewChanged(int)) ); |
165 | 165 | ||
166 | m_view= new QIconView( this ); | 166 | m_view= new QIconView( this ); |
167 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), | 167 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), |
168 | this, SLOT(slotClicked(QIconViewItem*)) ); | 168 | this, SLOT(slotClicked(QIconViewItem*)) ); |
169 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), | 169 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), |
170 | this, SLOT(slotClicked(QIconViewItem*)) ); | 170 | this, SLOT(slotClicked(QIconViewItem*)) ); |
171 | 171 | ||
172 | m_view->setArrangement( QIconView::LeftToRight ); | 172 | m_view->setArrangement( QIconView::LeftToRight ); |
173 | 173 | ||
174 | m_mode = cfg->readNumEntry("ListViewMode", 1); | 174 | m_mode = cfg->readNumEntry("ListViewMode", 1); |
175 | 175 | ||
176 | if (m_mode < 1 || m_mode>3) m_mode = 1; | 176 | if (m_mode < 1 || m_mode>3) m_mode = 1; |
177 | 177 | ||
178 | m_view->setItemTextPos( QIconView::Right ); | 178 | m_view->setItemTextPos( QIconView::Right ); |
179 | 179 | ||
180 | calculateGrid(); | 180 | calculateGrid(); |
181 | 181 | ||
182 | initKeys(); | 182 | initKeys(); |
183 | 183 | ||
184 | loadViews(); | 184 | loadViews(); |
185 | slotViewChanged( m_views->currentItem() ); | 185 | slotViewChanged( m_views->currentItem() ); |
186 | } | 186 | } |
187 | 187 | ||
188 | /* | 188 | /* |
189 | * Unref the slave and save the keyboard manager | 189 | * Unref the slave and save the keyboard manager |
190 | */ | 190 | */ |
191 | PIconView::~PIconView() { | 191 | PIconView::~PIconView() { |
192 | { | 192 | { |
193 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 193 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
194 | } | 194 | } |
195 | m_viewManager->save(); | 195 | m_viewManager->save(); |
196 | delete m_viewManager; | 196 | delete m_viewManager; |
197 | } | 197 | } |
198 | 198 | ||
199 | Opie::Core::OKeyConfigManager* PIconView::manager() { | 199 | Opie::Core::OKeyConfigManager* PIconView::manager() { |
200 | return m_viewManager; | 200 | return m_viewManager; |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | /* | 204 | /* |
205 | * init the KeyBoard Shortcuts | 205 | * init the KeyBoard Shortcuts |
206 | * called from the c'tor | 206 | * called from the c'tor |
207 | */ | 207 | */ |
208 | void PIconView::initKeys() { | 208 | void PIconView::initKeys() { |
209 | Opie::Core::OKeyPair::List lst; | 209 | Opie::Core::OKeyPair::List lst; |
210 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); | 210 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); |
211 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | 211 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); |
212 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | 212 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); |
213 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 213 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
214 | lst.append( Opie::Core::OKeyPair::returnKey() ); | 214 | lst.append( Opie::Core::OKeyPair::returnKey() ); |
215 | 215 | ||
216 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", | 216 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", |
217 | lst, false,this, "keyconfig name" ); | 217 | lst, false,this, "keyconfig name" ); |
218 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", | 218 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", |
219 | Resource::loadPixmap("beam"), BeamItem, | 219 | Resource::loadPixmap("beam"), BeamItem, |
220 | Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), | 220 | Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), |
221 | this, SLOT(slotBeam())) ); | 221 | this, SLOT(slotBeam())) ); |
222 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", | 222 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", |
223 | Resource::loadPixmap("trash"), DeleteItem, | 223 | Resource::loadPixmap("trash"), DeleteItem, |
224 | Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), | 224 | Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), |
225 | this, SLOT(slotTrash())) ); | 225 | this, SLOT(slotTrash())) ); |
226 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", | 226 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", |
227 | Resource::loadPixmap("1to1"), ViewItem, | 227 | Resource::loadPixmap("1to1"), ViewItem, |
228 | Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), | 228 | Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), |
229 | this, SLOT(slotShowImage()))); | 229 | this, SLOT(slotShowImage()))); |
230 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", | 230 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", |
231 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, | 231 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, |
232 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), | 232 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), |
233 | this, SLOT(slotImageInfo()) ) ); | 233 | this, SLOT(slotImageInfo()) ) ); |
234 | m_viewManager->load(); | 234 | m_viewManager->load(); |
235 | m_viewManager->handleWidget( m_view ); | 235 | m_viewManager->handleWidget( m_view ); |
236 | } | 236 | } |
237 | 237 | ||
238 | 238 | ||
239 | /* | 239 | /* |
240 | * change one dir up | 240 | * change one dir up |
241 | */ | 241 | */ |
242 | void PIconView::slotDirUp() { | 242 | void PIconView::slotDirUp() |
243 | { | ||
244 | if (m_path.isEmpty()) return; | ||
243 | QDir dir( m_path ); | 245 | QDir dir( m_path ); |
244 | dir.cdUp(); | 246 | dir.cdUp(); |
245 | slotChangeDir( dir.absPath() ); | 247 | slotChangeDir( dir.absPath() ); |
246 | } | 248 | } |
247 | 249 | ||
248 | /* | 250 | /* |
249 | * change the dir | 251 | * change the dir |
250 | */ | 252 | */ |
251 | void PIconView::slotChangeDir(const QString& path) { | 253 | void PIconView::slotChangeDir(const QString& path) { |
252 | if ( !currentView() ) | 254 | if ( !currentView() ) |
253 | return; | 255 | return; |
254 | 256 | ||
255 | PDirLister *lister = currentView()->dirLister(); | 257 | PDirLister *lister = currentView()->dirLister(); |
256 | if (!lister ) | 258 | if (!lister ) |
257 | return; | 259 | return; |
258 | 260 | ||
259 | /* | 261 | /* |
260 | * Say what we want and take what we get | 262 | * Say what we want and take what we get |
261 | */ | 263 | */ |
262 | lister->setStartPath( path ); | 264 | lister->setStartPath( path ); |
263 | m_path = lister->currentPath(); | 265 | m_path = lister->currentPath(); |
264 | 266 | ||
265 | m_view->viewport()->setUpdatesEnabled( false ); | 267 | m_view->viewport()->setUpdatesEnabled( false ); |
266 | m_view->clear(); | 268 | m_view->clear(); |
267 | 269 | ||
268 | /* | 270 | /* |
269 | * add files and folders | 271 | * add files and folders |
270 | */ | 272 | */ |
271 | addFolders( lister->folders() ); | 273 | addFolders( lister->folders() ); |
272 | addFiles( lister->files() ); | 274 | addFiles( lister->files() ); |
273 | m_view->viewport()->setUpdatesEnabled( true ); | 275 | m_view->viewport()->setUpdatesEnabled( true ); |
274 | 276 | ||
275 | // Also invalidate the cache. We can't cancel the operations anyway | 277 | // Also invalidate the cache. We can't cancel the operations anyway |
276 | g_stringPix.clear(); | 278 | g_stringPix.clear(); |
277 | g_stringInf.clear(); | 279 | g_stringInf.clear(); |
278 | 280 | ||
279 | // looks ugly | 281 | // looks ugly |
280 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); | 282 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); |
281 | } | 283 | } |
282 | 284 | ||
283 | /** | 285 | /** |
284 | * get the current file name | 286 | * get the current file name |
285 | * @param isDir see if this is a dir or real file | 287 | * @param isDir see if this is a dir or real file |
286 | */ | 288 | */ |
287 | QString PIconView::currentFileName(bool &isDir)const { | 289 | QString PIconView::currentFileName(bool &isDir)const { |
288 | isDir = false; | 290 | isDir = false; |
289 | QIconViewItem* _it = m_view->currentItem(); | 291 | QIconViewItem* _it = m_view->currentItem(); |
290 | if ( !_it ) | 292 | if ( !_it ) |
291 | return QString::null; | 293 | return QString::null; |
292 | 294 | ||
293 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 295 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
294 | isDir = it->isDir(); | 296 | isDir = it->isDir(); |
295 | return it->path(); | 297 | return it->path(); |
296 | } | 298 | } |
297 | 299 | ||
298 | QString PIconView::nextFileName(bool &isDir)const | 300 | QString PIconView::nextFileName(bool &isDir)const |
299 | { | 301 | { |
300 | isDir = false; | 302 | isDir = false; |
301 | QIconViewItem* _it1 = m_view->currentItem(); | 303 | QIconViewItem* _it1 = m_view->currentItem(); |
302 | if ( !_it1 ) | 304 | if ( !_it1 ) |
303 | return QString::null; | 305 | return QString::null; |
304 | QIconViewItem* _it = _it1->nextItem(); | 306 | QIconViewItem* _it = _it1->nextItem(); |
305 | if ( !_it ) | 307 | if ( !_it ) |
306 | return QString::null; | 308 | return QString::null; |
307 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 309 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
308 | isDir = it->isDir(); | 310 | isDir = it->isDir(); |
309 | return it->path(); | 311 | return it->path(); |
310 | } | 312 | } |
311 | 313 | ||
312 | QString PIconView::prevFileName(bool &isDir)const{ | 314 | QString PIconView::prevFileName(bool &isDir)const{ |
313 | isDir = false; | 315 | isDir = false; |
314 | QIconViewItem* _it = m_view->currentItem(); | 316 | QIconViewItem* _it = m_view->currentItem(); |
315 | if ( !_it ) | 317 | if ( !_it ) |
316 | return QString::null; | 318 | return QString::null; |
317 | _it = _it->prevItem(); | 319 | _it = _it->prevItem(); |
318 | if ( !_it ) | 320 | if ( !_it ) |
319 | return QString::null; | 321 | return QString::null; |
320 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 322 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
321 | isDir = it->isDir(); | 323 | isDir = it->isDir(); |
322 | return it->path(); | 324 | return it->path(); |
323 | } | 325 | } |
324 | 326 | ||
325 | void PIconView::slotTrash() { | 327 | void PIconView::slotTrash() { |
326 | bool isDir; | 328 | bool isDir; |
327 | QString pa = currentFileName( isDir ); | 329 | QString pa = currentFileName( isDir ); |
328 | if ( isDir && pa.isEmpty() ) | 330 | if ( isDir && pa.isEmpty() ) |
329 | return; | 331 | return; |
330 | 332 | ||
331 | if (!QPEMessageBox::confirmDelete( this, | 333 | if (!QPEMessageBox::confirmDelete( this, |
332 | tr("Delete Image" ), | 334 | tr("Delete Image" ), |
333 | tr("the Image %1" ).arg(pa))) | 335 | tr("the Image %1" ).arg(pa))) |
334 | return | 336 | return |
335 | 337 | ||
336 | 338 | ||
337 | currentView()->dirLister()->deleteImage( pa ); | 339 | currentView()->dirLister()->deleteImage( pa ); |
338 | delete m_view->currentItem(); | 340 | delete m_view->currentItem(); |
339 | } | 341 | } |
340 | 342 | ||
341 | /* | 343 | /* |
342 | * see what views are available | 344 | * see what views are available |
343 | */ | 345 | */ |
344 | void PIconView::loadViews() { | 346 | void PIconView::loadViews() { |
345 | ViewMap::Iterator it; | 347 | ViewMap::Iterator it; |
346 | ViewMap* map = viewMap(); | 348 | ViewMap* map = viewMap(); |
347 | for ( it = map->begin(); it != map->end(); ++it ) | 349 | for ( it = map->begin(); it != map->end(); ++it ) |
348 | m_views->insertItem( it.key() ); | 350 | m_views->insertItem( it.key() ); |
349 | } | 351 | } |
350 | 352 | ||
351 | void PIconView::resetView() { | 353 | void PIconView::resetView() { |
352 | slotViewChanged(m_views->currentItem()); | 354 | slotViewChanged(m_views->currentItem()); |
353 | } | 355 | } |
354 | 356 | ||
355 | /* | 357 | /* |
356 | *swicth view reloadDir and connect signals | 358 | *swicth view reloadDir and connect signals |
357 | */ | 359 | */ |
358 | void PIconView::slotViewChanged( int i) { | 360 | void PIconView::slotViewChanged( int i) { |
359 | if (!m_views->count() ) { | 361 | if (!m_views->count() ) { |
360 | setCurrentView( 0l); | 362 | setCurrentView( 0l); |
361 | return; | 363 | return; |
362 | } | 364 | } |
363 | 365 | ||
364 | PDirView* cur = currentView(); | 366 | PDirView* cur = currentView(); |
365 | if (cur) delete cur; | 367 | if (cur) delete cur; |
366 | QString str = m_views->text(i); | 368 | QString str = m_views->text(i); |
367 | ViewMap* map = viewMap(); | 369 | ViewMap* map = viewMap(); |
368 | if (!map) {setCurrentView(0l); return;} | 370 | if (!map) {setCurrentView(0l); return;} |
369 | if (map->find(str) == map->end()) { | 371 | if (map->find(str) == map->end()) { |
370 | owarn << "Key not found" << oendl; | 372 | owarn << "Key not found" << oendl; |
371 | setCurrentView(0l); return; | 373 | setCurrentView(0l); return; |
372 | } | 374 | } |
373 | cur = (*(*map)[str])(*m_cfg); | 375 | cur = (*(*map)[str])(*m_cfg); |
374 | setCurrentView( cur ); | 376 | setCurrentView( cur ); |
375 | 377 | ||
376 | /* connect to the signals of the lister */ | 378 | /* connect to the signals of the lister */ |
377 | PDirLister* lis = cur->dirLister(); | 379 | PDirLister* lis = cur->dirLister(); |
378 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), | 380 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), |
379 | this, SLOT( slotThumbInfo(const QString&, const QString&))); | 381 | this, SLOT( slotThumbInfo(const QString&, const QString&))); |
380 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 382 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
381 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 383 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
382 | connect(lis, SIGNAL(sig_start()), | 384 | connect(lis, SIGNAL(sig_start()), |
383 | this, SLOT(slotStart())); | 385 | this, SLOT(slotStart())); |
384 | connect(lis, SIGNAL(sig_end()) , | 386 | connect(lis, SIGNAL(sig_end()) , |
385 | this, SLOT(slotEnd()) ); | 387 | this, SLOT(slotEnd()) ); |
386 | 388 | ||
387 | 389 | ||
388 | /* reload now */ | 390 | /* reload now */ |
389 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); | 391 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); |
390 | } | 392 | } |
391 | 393 | ||
392 | 394 | ||
393 | void PIconView::slotReloadDir() { | 395 | void PIconView::slotReloadDir() { |
394 | slotChangeDir( m_path ); | 396 | slotChangeDir( m_path ); |
395 | } | 397 | } |
396 | 398 | ||
397 | 399 | ||
398 | /* | 400 | /* |
399 | * add files and folders | 401 | * add files and folders |
400 | */ | 402 | */ |
401 | void PIconView::addFolders( const QStringList& lst) { | 403 | void PIconView::addFolders( const QStringList& lst) { |
402 | QStringList::ConstIterator it; | 404 | QStringList::ConstIterator it; |
403 | IconViewItem * _iv; | 405 | IconViewItem * _iv; |
404 | 406 | ||
405 | for(it=lst.begin(); it != lst.end(); ++it ) { | 407 | for(it=lst.begin(); it != lst.end(); ++it ) { |
406 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); | 408 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); |
407 | if (m_mode==3) _iv->setTextOnly(true); | 409 | if (m_mode==3) _iv->setTextOnly(true); |
408 | } | 410 | } |
409 | } | 411 | } |
410 | 412 | ||
411 | void PIconView::addFiles( const QStringList& lst) { | 413 | void PIconView::addFiles( const QStringList& lst) { |
412 | QStringList::ConstIterator it; | 414 | QStringList::ConstIterator it; |
413 | IconViewItem * _iv; | 415 | IconViewItem * _iv; |
414 | QPixmap*m_pix = 0; | 416 | QPixmap*m_pix = 0; |
415 | QString pre = ""; | 417 | QString pre = ""; |
416 | if (!m_path.isEmpty()) { | 418 | if (!m_path.isEmpty()) { |
417 | pre = m_path+"/"; | 419 | pre = m_path+"/"; |
418 | } | 420 | } |
419 | for (it=lst.begin(); it!= lst.end(); ++it ) { | 421 | for (it=lst.begin(); it!= lst.end(); ++it ) { |
420 | m_pix = PPixmapCache::self()->cachedImage( pre+(*it), 64, 64 ); | 422 | m_pix = PPixmapCache::self()->cachedImage( pre+(*it), 64, 64 ); |
421 | _iv = new IconViewItem( m_view, pre+(*it), (*it) ); | 423 | _iv = new IconViewItem( m_view, pre+(*it), (*it) ); |
422 | if (m_mode==3) { | 424 | if (m_mode==3) { |
423 | _iv->setTextOnly(true); | 425 | _iv->setTextOnly(true); |
424 | _iv->setPixmap(QPixmap()); | 426 | _iv->setPixmap(QPixmap()); |
425 | } else { | 427 | } else { |
426 | if (m_pix) _iv->setPixmap(*m_pix); | 428 | if (m_pix) _iv->setPixmap(*m_pix); |
427 | } | 429 | } |
428 | } | 430 | } |
429 | 431 | ||
430 | } | 432 | } |
431 | 433 | ||
432 | /* | 434 | /* |
433 | * user clicked on the item. Change dir or view | 435 | * user clicked on the item. Change dir or view |
434 | */ | 436 | */ |
435 | void PIconView::slotClicked(QIconViewItem* _it) { | 437 | void PIconView::slotClicked(QIconViewItem* _it) { |
436 | if(!_it ) | 438 | if(!_it ) |
437 | return; | 439 | return; |
438 | 440 | ||
439 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 441 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
440 | if( it->isDir() ) | 442 | if( it->isDir() ) |
441 | slotChangeDir( it->path() ); | 443 | slotChangeDir( it->path() ); |
442 | else // view image | 444 | else // view image |
443 | slotShowImage(); | 445 | slotShowImage(); |
444 | } | 446 | } |
445 | 447 | ||
446 | /* | 448 | /* |
447 | * got thumb info add to the cache if items is visible | 449 | * got thumb info add to the cache if items is visible |
448 | * we later need update after processing of slave is done | 450 | * we later need update after processing of slave is done |
449 | */ | 451 | */ |
450 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { | 452 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { |
451 | IconViewItem* item = g_stringInf[_path]; | 453 | IconViewItem* item = g_stringInf[_path]; |
452 | if (!item ) | 454 | if (!item ) |
453 | return; | 455 | return; |
454 | 456 | ||
455 | if (m_mode == 2) { | 457 | if (m_mode == 2) { |
456 | return; | 458 | return; |
457 | } | 459 | } |
458 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 460 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
459 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 461 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
460 | m_updatet = true; | 462 | m_updatet = true; |
461 | 463 | ||
462 | item->setText( str ); | 464 | item->setText( str ); |
463 | g_stringInf.remove( _path ); | 465 | g_stringInf.remove( _path ); |
464 | } | 466 | } |
465 | 467 | ||
466 | /* | 468 | /* |
467 | * got thumbnail and see if it is visible so we need to update later | 469 | * got thumbnail and see if it is visible so we need to update later |
468 | */ | 470 | */ |
469 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { | 471 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { |
470 | IconViewItem* item = g_stringPix[_path]; | 472 | IconViewItem* item = g_stringPix[_path]; |
471 | if (!item ) | 473 | if (!item ) |
472 | return; | 474 | return; |
473 | 475 | ||
474 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 476 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
475 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 477 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
476 | m_updatet = true; | 478 | m_updatet = true; |
477 | 479 | ||
478 | if (pix.width()>0) { | 480 | if (pix.width()>0) { |
479 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); | 481 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); |
480 | item->setPixmap(pix,true); | 482 | item->setPixmap(pix,true); |
481 | } else { | 483 | } else { |
482 | PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), 64, 64 ); | 484 | PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), 64, 64 ); |
483 | } | 485 | } |
484 | g_stringPix.remove( _path ); | 486 | g_stringPix.remove( _path ); |
485 | } | 487 | } |
486 | 488 | ||
487 | 489 | ||
488 | /* | 490 | /* |
489 | * FIXME rename | 491 | * FIXME rename |
490 | */ | 492 | */ |
491 | void PIconView::slotRename() { | 493 | void PIconView::slotRename() { |
492 | 494 | ||
493 | } | 495 | } |
494 | 496 | ||
495 | 497 | ||
496 | /* | 498 | /* |
497 | * BEAM the current file | 499 | * BEAM the current file |
498 | */ | 500 | */ |
499 | void PIconView::slotBeam() { | 501 | void PIconView::slotBeam() { |
500 | bool isDir; | 502 | bool isDir; |
501 | QString pa = currentFileName( isDir ); | 503 | QString pa = currentFileName( isDir ); |
502 | if ( isDir && pa.isEmpty() ) | 504 | if ( isDir && pa.isEmpty() ) |
503 | return; | 505 | return; |
504 | 506 | ||
505 | Ir* ir = new Ir( this ); | 507 | Ir* ir = new Ir( this ); |
506 | connect( ir, SIGNAL(done(Ir*)), | 508 | connect( ir, SIGNAL(done(Ir*)), |
507 | this, SLOT(slotBeamDone(Ir*))); | 509 | this, SLOT(slotBeamDone(Ir*))); |
508 | ir->send(pa, tr( "Image" ) ); | 510 | ir->send(pa, tr( "Image" ) ); |
509 | } | 511 | } |
510 | 512 | ||
511 | /* | 513 | /* |
512 | * BEAM done clean up | 514 | * BEAM done clean up |
513 | */ | 515 | */ |
514 | void PIconView::slotBeamDone( Ir* ir) { | 516 | void PIconView::slotBeamDone( Ir* ir) { |
515 | delete ir; | 517 | delete ir; |
516 | } | 518 | } |
517 | 519 | ||
518 | void PIconView::slotStart() { | 520 | void PIconView::slotStart() { |
519 | m_view->viewport()->setUpdatesEnabled( false ); | 521 | m_view->viewport()->setUpdatesEnabled( false ); |
520 | } | 522 | } |
521 | 523 | ||
522 | void PIconView::slotEnd() { | 524 | void PIconView::slotEnd() { |
523 | if ( m_updatet ) | 525 | if ( m_updatet ) |
524 | m_view->arrangeItemsInGrid( ); | 526 | m_view->arrangeItemsInGrid( ); |
525 | m_view->viewport()->setUpdatesEnabled( true ); | 527 | m_view->viewport()->setUpdatesEnabled( true ); |
526 | m_updatet = false; | 528 | m_updatet = false; |
527 | } | 529 | } |
528 | 530 | ||
529 | void PIconView::slotShowNext() | 531 | void PIconView::slotShowNext() |
530 | { | 532 | { |
531 | bool isDir = false; | 533 | bool isDir = false; |
532 | QString name = nextFileName(isDir); | 534 | QString name = nextFileName(isDir); |
533 | if (name.isEmpty()) return; | 535 | if (name.isEmpty()) return; |
534 | if (isDir) return; | 536 | if (isDir) return; |
535 | /* if we got a name we have a next item */ | 537 | /* if we got a name we have a next item */ |
536 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 538 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
537 | slotShowImage(name); | 539 | slotShowImage(name); |
538 | } | 540 | } |
539 | 541 | ||
540 | void PIconView::slotShowPrev() | 542 | void PIconView::slotShowPrev() |
541 | { | 543 | { |
542 | bool isDir = false; | 544 | bool isDir = false; |
543 | QString name = prevFileName(isDir); | 545 | QString name = prevFileName(isDir); |
544 | if (name.isEmpty()) return; | 546 | if (name.isEmpty()) return; |
545 | if (isDir) return; | 547 | if (isDir) return; |
546 | /* if we got a name we have a prev item */ | 548 | /* if we got a name we have a prev item */ |
547 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | 549 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); |
548 | slotShowImage(name); | 550 | slotShowImage(name); |
549 | } | 551 | } |
550 | 552 | ||
551 | void PIconView::slotShowImage() | 553 | void PIconView::slotShowImage() |
552 | { | 554 | { |
553 | bool isDir = false; | 555 | bool isDir = false; |
554 | QString name = currentFileName(isDir); | 556 | QString name = currentFileName(isDir); |
555 | if (isDir) return; | 557 | if (isDir) return; |
556 | slotShowImage( name ); | 558 | slotShowImage( name ); |
557 | } | 559 | } |
558 | void PIconView::slotShowImage( const QString& name) { | 560 | void PIconView::slotShowImage( const QString& name) { |
559 | PDirLister *lister = currentView()->dirLister(); | 561 | PDirLister *lister = currentView()->dirLister(); |
560 | QString r_name = lister->nameToFname(name); | 562 | QString r_name = lister->nameToFname(name); |
561 | emit sig_display( r_name ); | 563 | emit sig_display( r_name ); |
562 | } | 564 | } |
563 | void PIconView::slotImageInfo() { | 565 | void PIconView::slotImageInfo() { |
564 | bool isDir = false; | 566 | bool isDir = false; |
565 | QString name = currentFileName(isDir); | 567 | QString name = currentFileName(isDir); |
566 | if (isDir) return; | 568 | if (isDir) return; |
567 | 569 | ||
568 | slotImageInfo( name ); | 570 | slotImageInfo( name ); |
569 | } | 571 | } |
570 | 572 | ||
571 | void PIconView::slotImageInfo( const QString& name) { | 573 | void PIconView::slotImageInfo( const QString& name) { |
572 | PDirLister *lister = currentView()->dirLister(); | 574 | PDirLister *lister = currentView()->dirLister(); |
573 | QString r_name = lister->nameToFname(name); | 575 | QString r_name = lister->nameToFname(name); |
574 | emit sig_showInfo(r_name ); | 576 | emit sig_showInfo(r_name ); |
575 | } | 577 | } |
576 | 578 | ||
577 | 579 | ||
578 | void PIconView::slotChangeMode( int mode ) { | 580 | void PIconView::slotChangeMode( int mode ) { |
579 | if ( mode >= 1 && mode <= 3 ) | 581 | if ( mode >= 1 && mode <= 3 ) |
580 | m_mode = mode; | 582 | m_mode = mode; |
581 | 583 | ||
582 | m_cfg->writeEntry("ListViewMode", m_mode); | 584 | m_cfg->writeEntry("ListViewMode", m_mode); |
585 | /* performance! */ | ||
586 | m_view->clear(); | ||
583 | calculateGrid(); | 587 | calculateGrid(); |
584 | slotReloadDir(); | 588 | slotReloadDir(); |
585 | } | 589 | } |
586 | 590 | ||
587 | 591 | ||
588 | void PIconView::resizeEvent( QResizeEvent* re ) { | 592 | void PIconView::resizeEvent( QResizeEvent* re ) { |
589 | QVBox::resizeEvent( re ); | 593 | QVBox::resizeEvent( re ); |
590 | calculateGrid(); | 594 | calculateGrid(); |
591 | } | 595 | } |
592 | 596 | ||
593 | 597 | ||
594 | void PIconView::calculateGrid() { | 598 | void PIconView::calculateGrid() { |
595 | int dw = QApplication::desktop()->width(); | 599 | int dw = QApplication::desktop()->width(); |
596 | int viewerWidth = dw-style().scrollBarExtent().width(); | 600 | int viewerWidth = dw-style().scrollBarExtent().width(); |
597 | 601 | ||
598 | QIconView::ItemTextPos pos; | 602 | QIconView::ItemTextPos pos; |
599 | switch( m_mode ) { | 603 | switch( m_mode ) { |
600 | case 2: | 604 | case 2: |
601 | pos = QIconView::Bottom; | 605 | pos = QIconView::Bottom; |
602 | break; | 606 | break; |
603 | case 3: | 607 | case 3: |
604 | case 1: | 608 | case 1: |
605 | default: | 609 | default: |
606 | pos = QIconView::Right; | 610 | pos = QIconView::Right; |
607 | break; | 611 | break; |
608 | } | 612 | } |
609 | m_view->setItemTextPos( pos ); | 613 | m_view->setItemTextPos( pos ); |
610 | switch (m_mode) { | 614 | switch (m_mode) { |
611 | case 2: | 615 | case 2: |
612 | m_view->setGridX(50); | 616 | m_view->setGridX(50); |
613 | m_view->setGridY(20); | 617 | m_view->setGridY(20); |
614 | PPixmapCache::self()->setMaxImages(40); | 618 | PPixmapCache::self()->setMaxImages(40); |
615 | break; | 619 | break; |
616 | case 3: | 620 | case 3: |
617 | m_view->setGridX( fontMetrics().width("testimage.jpg")+20); | 621 | m_view->setGridX( fontMetrics().width("testimage.jpg")+20); |
618 | m_view->setGridY(8); | 622 | m_view->setGridY(8); |
619 | PPixmapCache::self()->setMaxImages(2); | 623 | PPixmapCache::self()->setMaxImages(2); |
620 | break; | 624 | break; |
621 | case 1: | 625 | case 1: |
622 | default: | 626 | default: |
623 | m_view->setGridX( viewerWidth-3*m_view->spacing()); | 627 | m_view->setGridX( viewerWidth-3*m_view->spacing()); |
624 | m_view->setGridY( fontMetrics().height()*2+40 ); | 628 | m_view->setGridY( fontMetrics().height()*2+40 ); |
625 | PPixmapCache::self()->setMaxImages(20); | 629 | PPixmapCache::self()->setMaxImages(20); |
626 | break; | 630 | break; |
627 | } | 631 | } |
628 | } | 632 | } |
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 058fca0..ec6b051 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp | |||
@@ -35,384 +35,385 @@ | |||
35 | 35 | ||
36 | 36 | ||
37 | //OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) | 37 | //OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) |
38 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) | 38 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) |
39 | 39 | ||
40 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | 40 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) |
41 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) | 41 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) |
42 | { | 42 | { |
43 | setCaption( QObject::tr("Opie Eye Caramba" ) ); | 43 | setCaption( QObject::tr("Opie Eye Caramba" ) ); |
44 | m_cfg = new Opie::Core::OConfig("phunkview"); | 44 | m_cfg = new Opie::Core::OConfig("phunkview"); |
45 | m_cfg->setGroup("Zecke_view" ); | 45 | m_cfg->setGroup("Zecke_view" ); |
46 | tFrame = 0; | 46 | tFrame = 0; |
47 | // qDebug( "Process-wide OApplication object @ %0x", oApp ); | 47 | // qDebug( "Process-wide OApplication object @ %0x", oApp ); |
48 | /* | 48 | /* |
49 | * Initialize ToolBar and IconView | 49 | * Initialize ToolBar and IconView |
50 | * And Connect Them | 50 | * And Connect Them |
51 | */ | 51 | */ |
52 | QToolBar *bar = new QToolBar( this ); | 52 | QToolBar *bar = new QToolBar( this ); |
53 | bar->setHorizontalStretchable( true ); | 53 | bar->setHorizontalStretchable( true ); |
54 | setToolBarsMovable( false ); | 54 | setToolBarsMovable( false ); |
55 | 55 | ||
56 | m_stack = new Opie::Ui::OWidgetStack( this ); | 56 | m_stack = new Opie::Ui::OWidgetStack( this ); |
57 | setCentralWidget( m_stack ); | 57 | setCentralWidget( m_stack ); |
58 | 58 | ||
59 | m_view = new PIconView( m_stack, m_cfg ); | 59 | m_view = new PIconView( m_stack, m_cfg ); |
60 | m_stack->addWidget( m_view, IconView ); | 60 | m_stack->addWidget( m_view, IconView ); |
61 | m_stack->raiseWidget( IconView ); | 61 | m_stack->raiseWidget( IconView ); |
62 | connect(m_view, SIGNAL(sig_display(const QString&)), | 62 | connect(m_view, SIGNAL(sig_display(const QString&)), |
63 | this, SLOT(slotDisplay(const QString&))); | 63 | this, SLOT(slotDisplay(const QString&))); |
64 | connect(m_view, SIGNAL(sig_showInfo(const QString&)), | 64 | connect(m_view, SIGNAL(sig_showInfo(const QString&)), |
65 | this, SLOT(slotShowInfo(const QString&)) ); | 65 | this, SLOT(slotShowInfo(const QString&)) ); |
66 | 66 | ||
67 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); | 67 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); |
68 | 68 | ||
69 | upButton = new QToolButton( bar ); | 69 | upButton = new QToolButton( bar ); |
70 | upButton->setIconSet( Resource::loadIconSet( "up" ) ); | 70 | upButton->setIconSet( Resource::loadIconSet( "up" ) ); |
71 | connect( upButton, SIGNAL(clicked()), | 71 | connect( upButton, SIGNAL(clicked()), |
72 | m_view, SLOT(slotDirUp()) ); | 72 | m_view, SLOT(slotDirUp()) ); |
73 | 73 | ||
74 | fsButton = new PFileSystem( bar ); | 74 | fsButton = new PFileSystem( bar ); |
75 | connect( fsButton, SIGNAL( changeDir( const QString& ) ), | 75 | connect( fsButton, SIGNAL( changeDir( const QString& ) ), |
76 | m_view, SLOT(slotChangeDir( const QString& ) ) ); | 76 | m_view, SLOT(slotChangeDir( const QString& ) ) ); |
77 | 77 | ||
78 | QToolButton*btn = new QToolButton( bar ); | 78 | QToolButton*btn = new QToolButton( bar ); |
79 | btn->setIconSet( Resource::loadIconSet( "edit" ) ); | 79 | btn->setIconSet( Resource::loadIconSet( "edit" ) ); |
80 | connect( btn, SIGNAL(clicked()), | 80 | connect( btn, SIGNAL(clicked()), |
81 | m_view, SLOT(slotRename()) ); | 81 | m_view, SLOT(slotRename()) ); |
82 | 82 | ||
83 | if ( Ir::supported() ) { | 83 | if ( Ir::supported() ) { |
84 | btn = new QToolButton( bar ); | 84 | btn = new QToolButton( bar ); |
85 | btn->setIconSet( Resource::loadIconSet( "beam" ) ); | 85 | btn->setIconSet( Resource::loadIconSet( "beam" ) ); |
86 | connect( btn, SIGNAL(clicked()), | 86 | connect( btn, SIGNAL(clicked()), |
87 | m_view, SLOT(slotBeam()) ); | 87 | m_view, SLOT(slotBeam()) ); |
88 | } | 88 | } |
89 | 89 | ||
90 | btn = new QToolButton( bar ); | 90 | btn = new QToolButton( bar ); |
91 | btn->setIconSet( Resource::loadIconSet( "trash" ) ); | 91 | btn->setIconSet( Resource::loadIconSet( "trash" ) ); |
92 | connect( btn, SIGNAL(clicked() ), | 92 | connect( btn, SIGNAL(clicked() ), |
93 | m_view, SLOT(slotTrash() ) ); | 93 | m_view, SLOT(slotTrash() ) ); |
94 | 94 | ||
95 | 95 | ||
96 | int mode = m_cfg->readNumEntry("ListViewMode", 1); | 96 | int mode = m_cfg->readNumEntry("ListViewMode", 1); |
97 | if (mode < 1 || mode>3) mode = 1; | 97 | if (mode < 1 || mode>3) mode = 1; |
98 | viewModeButton = new ViewModeButton( bar,mode ); | 98 | viewModeButton = new ViewModeButton( bar,mode ); |
99 | connect( viewModeButton, SIGNAL(changeMode(int)), | 99 | connect( viewModeButton, SIGNAL(changeMode(int)), |
100 | m_view, SLOT(slotChangeMode(int))); | 100 | m_view, SLOT(slotChangeMode(int))); |
101 | 101 | ||
102 | btn = new QToolButton( bar ); | 102 | btn = new QToolButton( bar ); |
103 | btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); | 103 | btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); |
104 | connect( btn, SIGNAL(clicked() ), | 104 | connect( btn, SIGNAL(clicked() ), |
105 | this, SLOT(slotConfig() ) ); | 105 | this, SLOT(slotConfig() ) ); |
106 | 106 | ||
107 | 107 | ||
108 | 108 | ||
109 | prevButton = new QToolButton(bar); | 109 | prevButton = new QToolButton(bar); |
110 | prevButton->setIconSet( Resource::loadIconSet( "back" ) ); | 110 | prevButton->setIconSet( Resource::loadIconSet( "back" ) ); |
111 | connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev())); | 111 | connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev())); |
112 | 112 | ||
113 | nextButton = new QToolButton(bar); | 113 | nextButton = new QToolButton(bar); |
114 | nextButton->setIconSet( Resource::loadIconSet( "forward" ) ); | 114 | nextButton->setIconSet( Resource::loadIconSet( "forward" ) ); |
115 | connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext())); | 115 | connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext())); |
116 | 116 | ||
117 | rotateButton = new QToolButton(bar); | 117 | rotateButton = new QToolButton(bar); |
118 | rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); | 118 | rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); |
119 | rotateButton->setToggleButton(true); | 119 | rotateButton->setToggleButton(true); |
120 | 120 | ||
121 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 121 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
122 | rotateButton->setOn(true); | 122 | rotateButton->setOn(true); |
123 | autoRotate = true; | 123 | autoRotate = true; |
124 | prevButton->hide(); | 124 | prevButton->hide(); |
125 | nextButton->hide(); | 125 | nextButton->hide(); |
126 | } else { | 126 | } else { |
127 | rotateButton->setOn(false); | 127 | rotateButton->setOn(false); |
128 | autoRotate = false; | 128 | autoRotate = false; |
129 | } | 129 | } |
130 | 130 | ||
131 | connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); | 131 | connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); |
132 | 132 | ||
133 | scaleButton = new QToolButton(bar); | 133 | scaleButton = new QToolButton(bar); |
134 | scaleButton->setIconSet( Resource::loadIconSet( "1to1" ) ); | 134 | scaleButton->setIconSet( Resource::loadIconSet( "1to1" ) ); |
135 | scaleButton->setToggleButton(true); | 135 | scaleButton->setToggleButton(true); |
136 | scaleButton->setOn(false); | 136 | scaleButton->setOn(false); |
137 | connect(scaleButton,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); | 137 | connect(scaleButton,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); |
138 | autoScale = true; | 138 | autoScale = true; |
139 | 139 | ||
140 | zoomButton = new QToolButton(bar); | 140 | zoomButton = new QToolButton(bar); |
141 | zoomButton->setIconSet( Resource::loadIconSet( "mag" ) ); | 141 | zoomButton->setIconSet( Resource::loadIconSet( "mag" ) ); |
142 | zoomButton->setToggleButton(true); | 142 | zoomButton->setToggleButton(true); |
143 | zoomButton->setOn(true); | 143 | zoomButton->setOn(true); |
144 | connect(zoomButton,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); | 144 | connect(zoomButton,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); |
145 | zoomerOn = true; | 145 | zoomerOn = true; |
146 | } | 146 | } |
147 | 147 | ||
148 | PMainWindow::~PMainWindow() { | 148 | PMainWindow::~PMainWindow() { |
149 | odebug << "Shutting down" << oendl; | 149 | odebug << "Shutting down" << oendl; |
150 | if (tFrame) delete tFrame; | 150 | if (tFrame) delete tFrame; |
151 | odebug << "Shutting down done" << oendl; | 151 | odebug << "Shutting down done" << oendl; |
152 | } | 152 | } |
153 | 153 | ||
154 | void PMainWindow::slotToggleZoomer() | 154 | void PMainWindow::slotToggleZoomer() |
155 | { | 155 | { |
156 | if (!m_disp) return; | 156 | if (!m_disp) return; |
157 | bool cur = zoomButton->isOn(); | 157 | bool cur = zoomButton->isOn(); |
158 | zoomButton->setOn(!cur); | 158 | zoomButton->setOn(!cur); |
159 | } | 159 | } |
160 | 160 | ||
161 | void PMainWindow::slotZoomerToggled(bool how) | 161 | void PMainWindow::slotZoomerToggled(bool how) |
162 | { | 162 | { |
163 | zoomerOn = how; | 163 | zoomerOn = how; |
164 | if (m_disp) { | 164 | if (m_disp) { |
165 | m_disp->setShowZoomer(zoomerOn); | 165 | m_disp->setShowZoomer(zoomerOn); |
166 | } | 166 | } |
167 | } | 167 | } |
168 | 168 | ||
169 | void PMainWindow::slotToggleAutorotate() | 169 | void PMainWindow::slotToggleAutorotate() |
170 | { | 170 | { |
171 | if (!m_disp) return; | 171 | if (!m_disp) return; |
172 | if (!rotateButton->isEnabled()) return; | 172 | if (!rotateButton->isEnabled()) return; |
173 | bool cur = rotateButton->isOn(); | 173 | bool cur = rotateButton->isOn(); |
174 | rotateButton->setOn(!cur); | 174 | rotateButton->setOn(!cur); |
175 | } | 175 | } |
176 | 176 | ||
177 | void PMainWindow::slotToggleAutoscale() | 177 | void PMainWindow::slotToggleAutoscale() |
178 | { | 178 | { |
179 | if (!m_disp) return; | 179 | if (!m_disp) return; |
180 | bool cur = scaleButton->isOn(); | 180 | bool cur = scaleButton->isOn(); |
181 | scaleButton->setOn(!cur); | 181 | scaleButton->setOn(!cur); |
182 | } | 182 | } |
183 | 183 | ||
184 | void PMainWindow::slotRotateToggled(bool how) | 184 | void PMainWindow::slotRotateToggled(bool how) |
185 | { | 185 | { |
186 | autoRotate = how; | 186 | autoRotate = how; |
187 | if (m_disp) { | 187 | if (m_disp) { |
188 | m_disp->setAutoRotate(how); | 188 | m_disp->setAutoRotate(how); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
192 | void PMainWindow::slotScaleToggled(bool how) | 192 | void PMainWindow::slotScaleToggled(bool how) |
193 | { | 193 | { |
194 | autoScale = !how; | 194 | autoScale = !how; |
195 | if (!how) { | 195 | if (!how) { |
196 | autoRotate = how; | 196 | autoRotate = how; |
197 | } | 197 | } |
198 | if (m_disp) { | 198 | if (m_disp) { |
199 | m_disp->setAutoScaleRotate(autoScale,autoRotate); | 199 | m_disp->setAutoScaleRotate(autoScale,autoRotate); |
200 | } | 200 | } |
201 | if (!autoScale) { | 201 | if (!autoScale) { |
202 | rotateButton->setOn(false); | 202 | rotateButton->setOn(false); |
203 | } | 203 | } |
204 | rotateButton->setEnabled(!how); | 204 | rotateButton->setEnabled(!how); |
205 | } | 205 | } |
206 | 206 | ||
207 | void PMainWindow::slotConfig() { | 207 | void PMainWindow::slotConfig() { |
208 | /* | 208 | /* |
209 | * have a tab with the possible views | 209 | * have a tab with the possible views |
210 | * a tab for globals image cache size.. scaled loading | 210 | * a tab for globals image cache size.. scaled loading |
211 | * and one tab for the KeyConfigs | 211 | * and one tab for the KeyConfigs |
212 | */ | 212 | */ |
213 | QDialog dlg(this, 0, true); | 213 | QDialog dlg(this, 0, true); |
214 | dlg.setCaption( tr("Phunk View - Config" ) ); | 214 | dlg.setCaption( tr("Phunk View - Config" ) ); |
215 | 215 | ||
216 | QHBoxLayout *lay = new QHBoxLayout(&dlg); | 216 | QHBoxLayout *lay = new QHBoxLayout(&dlg); |
217 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); | 217 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); |
218 | lay->addWidget( wid ); | 218 | lay->addWidget( wid ); |
219 | ViewMap *vM = viewMap(); | 219 | ViewMap *vM = viewMap(); |
220 | ViewMap::Iterator _it = vM->begin(); | 220 | ViewMap::Iterator _it = vM->begin(); |
221 | QMap<PDirView*, QWidget*> lst; | 221 | QMap<PDirView*, QWidget*> lst; |
222 | 222 | ||
223 | for( ; _it != vM->end(); ++_it ) { | 223 | for( ; _it != vM->end(); ++_it ) { |
224 | PDirView *view = (_it.data())(*m_cfg); | 224 | PDirView *view = (_it.data())(*m_cfg); |
225 | PInterfaceInfo *inf = view->interfaceInfo(); | 225 | PInterfaceInfo *inf = view->interfaceInfo(); |
226 | QWidget *_wid = inf->configWidget( *m_cfg ); | 226 | QWidget *_wid = inf->configWidget( *m_cfg ); |
227 | if (!_wid) continue; | ||
227 | _wid->reparent(wid, QPoint() ); | 228 | _wid->reparent(wid, QPoint() ); |
228 | lst.insert( view, _wid ); | 229 | lst.insert( view, _wid ); |
229 | wid->addTab( _wid, "fileopen", inf->name() ); | 230 | wid->addTab( _wid, "fileopen", inf->name() ); |
230 | } | 231 | } |
231 | 232 | ||
232 | /* | 233 | /* |
233 | * Add the KeyConfigWidget | 234 | * Add the KeyConfigWidget |
234 | */ | 235 | */ |
235 | Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); | 236 | Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); |
236 | keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); | 237 | keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); |
237 | keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); | 238 | keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); |
238 | 239 | ||
239 | if ( !m_info ) { | 240 | if ( !m_info ) { |
240 | initInfo(); | 241 | initInfo(); |
241 | } | 242 | } |
242 | keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); | 243 | keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); |
243 | 244 | ||
244 | if ( !m_disp ) { | 245 | if ( !m_disp ) { |
245 | initDisp(); | 246 | initDisp(); |
246 | } | 247 | } |
247 | keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); | 248 | keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); |
248 | 249 | ||
249 | keyWid->load(); | 250 | keyWid->load(); |
250 | wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); | 251 | wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); |
251 | 252 | ||
252 | 253 | ||
253 | bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); | 254 | bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); |
254 | 255 | ||
255 | /* | 256 | /* |
256 | * clean up | 257 | * clean up |
257 | *apply changes | 258 | *apply changes |
258 | */ | 259 | */ |
259 | 260 | ||
260 | QMap<PDirView*, QWidget*>::Iterator it; | 261 | QMap<PDirView*, QWidget*>::Iterator it; |
261 | for ( it = lst.begin(); it != lst.end(); ++it ) { | 262 | for ( it = lst.begin(); it != lst.end(); ++it ) { |
262 | if ( act ) | 263 | if ( act ) |
263 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); | 264 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); |
264 | delete it.key(); | 265 | delete it.key(); |
265 | } | 266 | } |
266 | 267 | ||
267 | 268 | ||
268 | if ( act ) { | 269 | if ( act ) { |
269 | m_view->resetView(); | 270 | m_view->resetView(); |
270 | keyWid->save(); | 271 | keyWid->save(); |
271 | m_disp->manager()->save(); | 272 | m_disp->manager()->save(); |
272 | m_info->manager()->save(); | 273 | m_info->manager()->save(); |
273 | m_view->manager()->save(); | 274 | m_view->manager()->save(); |
274 | } | 275 | } |
275 | delete keyWid; | 276 | delete keyWid; |
276 | } | 277 | } |
277 | 278 | ||
278 | /* | 279 | /* |
279 | * create a new image info component | 280 | * create a new image info component |
280 | * and detach the current one | 281 | * and detach the current one |
281 | * we will make the other delete on exit | 282 | * we will make the other delete on exit |
282 | */ | 283 | */ |
283 | template<class T> | 284 | template<class T> |
284 | void PMainWindow::initT( const char* name, T** ptr, int id) { | 285 | void PMainWindow::initT( const char* name, T** ptr, int id) { |
285 | if ( *ptr ) { | 286 | if ( *ptr ) { |
286 | (*ptr)->disconnect(this, SLOT(slotReturn())); | 287 | (*ptr)->disconnect(this, SLOT(slotReturn())); |
287 | (*ptr)->setDestructiveClose(); | 288 | (*ptr)->setDestructiveClose(); |
288 | m_stack->removeWidget( *ptr ); | 289 | m_stack->removeWidget( *ptr ); |
289 | } | 290 | } |
290 | *ptr = new T(m_cfg, m_stack, name ); | 291 | *ptr = new T(m_cfg, m_stack, name ); |
291 | m_stack->addWidget( *ptr, id ); | 292 | m_stack->addWidget( *ptr, id ); |
292 | 293 | ||
293 | connect(*ptr, SIGNAL(sig_return()), | 294 | connect(*ptr, SIGNAL(sig_return()), |
294 | this,SLOT(slotReturn())); | 295 | this,SLOT(slotReturn())); |
295 | 296 | ||
296 | } | 297 | } |
297 | void PMainWindow::initInfo() { | 298 | void PMainWindow::initInfo() { |
298 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); | 299 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); |
299 | connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); | 300 | connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); |
300 | } | 301 | } |
301 | void PMainWindow::initDisp() { | 302 | void PMainWindow::initDisp() { |
302 | initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); | 303 | initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); |
303 | if (m_disp) { | 304 | if (m_disp) { |
304 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 305 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
305 | m_disp->setMinimumSize(QApplication::desktop()->size()/2); | 306 | m_disp->setMinimumSize(QApplication::desktop()->size()/2); |
306 | } | 307 | } |
307 | m_disp->setAutoScale(autoScale); | 308 | m_disp->setAutoScale(autoScale); |
308 | m_disp->setAutoRotate(autoRotate); | 309 | m_disp->setAutoRotate(autoRotate); |
309 | m_disp->setShowZoomer(zoomerOn); | 310 | m_disp->setShowZoomer(zoomerOn); |
310 | m_disp->setBackgroundColor(white); | 311 | m_disp->setBackgroundColor(white); |
311 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); | 312 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); |
312 | connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); | 313 | connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); |
313 | connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); | 314 | connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); |
314 | connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); | 315 | connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); |
315 | connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); | 316 | connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); |
316 | connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); | 317 | connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); |
317 | connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); | 318 | connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); |
318 | connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); | 319 | connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); |
319 | } | 320 | } |
320 | } | 321 | } |
321 | 322 | ||
322 | void PMainWindow::slotToggleFullScreen() | 323 | void PMainWindow::slotToggleFullScreen() |
323 | { | 324 | { |
324 | odebug << "Toggle full " << oendl; | 325 | odebug << "Toggle full " << oendl; |
325 | if (!m_disp) return; | 326 | if (!m_disp) return; |
326 | bool current = !m_disp->fullScreen(); | 327 | bool current = !m_disp->fullScreen(); |
327 | m_disp->setFullScreen(current); | 328 | m_disp->setFullScreen(current); |
328 | odebug << "Current = " << current << oendl; | 329 | odebug << "Current = " << current << oendl; |
329 | if (current) { | 330 | if (current) { |
330 | odebug << "full" << oendl; | 331 | odebug << "full" << oendl; |
331 | m_disp->setBackgroundColor(black); | 332 | m_disp->setBackgroundColor(black); |
332 | if (!tFrame) { | 333 | if (!tFrame) { |
333 | tFrame = new QWidget(0,0,WStyle_Customize|WStyle_NoBorder); | 334 | tFrame = new QWidget(0,0,WStyle_Customize|WStyle_NoBorder); |
334 | tFrame->resize(qApp->desktop()->width(), qApp->desktop()->height()); | 335 | tFrame->resize(qApp->desktop()->width(), qApp->desktop()->height()); |
335 | tFrame->setMinimumSize(qApp->desktop()->width(), qApp->desktop()->height()); | 336 | tFrame->setMinimumSize(qApp->desktop()->width(), qApp->desktop()->height()); |
336 | } | 337 | } |
337 | m_disp->reparent(tFrame,QPoint(0,0)); | 338 | m_disp->reparent(tFrame,QPoint(0,0)); |
338 | m_disp->setVScrollBarMode(QScrollView::AlwaysOff); | 339 | m_disp->setVScrollBarMode(QScrollView::AlwaysOff); |
339 | m_disp->setHScrollBarMode(QScrollView::AlwaysOff); | 340 | m_disp->setHScrollBarMode(QScrollView::AlwaysOff); |
340 | m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); | 341 | m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); |
341 | tFrame->showFullScreen(); | 342 | tFrame->showFullScreen(); |
342 | } else { | 343 | } else { |
343 | setUpdatesEnabled(false); | 344 | setUpdatesEnabled(false); |
344 | odebug << "window" << oendl; | 345 | odebug << "window" << oendl; |
345 | m_disp->reparent(0,QPoint(0,0)); | 346 | m_disp->reparent(0,QPoint(0,0)); |
346 | m_disp->showNormal(); | 347 | m_disp->showNormal(); |
347 | /* don't forget it! */ | 348 | /* don't forget it! */ |
348 | tFrame->hide(); | 349 | tFrame->hide(); |
349 | m_disp->setBackgroundColor(white); | 350 | m_disp->setBackgroundColor(white); |
350 | m_stack->addWidget(m_disp,ImageDisplay); | 351 | m_stack->addWidget(m_disp,ImageDisplay); |
351 | m_disp->setVScrollBarMode(QScrollView::Auto); | 352 | m_disp->setVScrollBarMode(QScrollView::Auto); |
352 | m_disp->setHScrollBarMode(QScrollView::Auto); | 353 | m_disp->setHScrollBarMode(QScrollView::Auto); |
353 | m_stack->raiseWidget(m_disp); | 354 | m_stack->raiseWidget(m_disp); |
354 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 355 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
355 | m_disp->resize(m_disp->minimumSize()); | 356 | m_disp->resize(m_disp->minimumSize()); |
356 | } | 357 | } |
357 | setUpdatesEnabled(true); | 358 | setUpdatesEnabled(true); |
358 | } | 359 | } |
359 | } | 360 | } |
360 | 361 | ||
361 | /** | 362 | /** |
362 | * With big Screen the plan could be to 'detach' the image | 363 | * With big Screen the plan could be to 'detach' the image |
363 | * window if visible and to create a ne wone | 364 | * window if visible and to create a ne wone |
364 | * init* already supports it but I make no use of it for | 365 | * init* already supports it but I make no use of it for |
365 | * now. We set filename and raise | 366 | * now. We set filename and raise |
366 | * | 367 | * |
367 | * ### FIXME and talk to alwin | 368 | * ### FIXME and talk to alwin |
368 | */ | 369 | */ |
369 | void PMainWindow::slotShowInfo( const QString& inf ) { | 370 | void PMainWindow::slotShowInfo( const QString& inf ) { |
370 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { | 371 | if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { |
371 | return; | 372 | return; |
372 | } | 373 | } |
373 | if ( !m_info ) { | 374 | if ( !m_info ) { |
374 | initInfo(); | 375 | initInfo(); |
375 | } | 376 | } |
376 | m_info->setPath( inf ); | 377 | m_info->setPath( inf ); |
377 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 378 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
378 | prevButton->hide(); | 379 | prevButton->hide(); |
379 | nextButton->hide(); | 380 | nextButton->hide(); |
380 | upButton->hide(); | 381 | upButton->hide(); |
381 | fsButton->hide(); | 382 | fsButton->hide(); |
382 | viewModeButton->hide(); | 383 | viewModeButton->hide(); |
383 | } | 384 | } |
384 | m_stack->raiseWidget( ImageInfo ); | 385 | m_stack->raiseWidget( ImageInfo ); |
385 | } | 386 | } |
386 | 387 | ||
387 | void PMainWindow::slotDisplay( const QString& inf ) { | 388 | void PMainWindow::slotDisplay( const QString& inf ) { |
388 | if ( !m_disp ) { | 389 | if ( !m_disp ) { |
389 | initDisp(); | 390 | initDisp(); |
390 | } | 391 | } |
391 | m_disp->setImage( inf ); | 392 | m_disp->setImage( inf ); |
392 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 393 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
393 | prevButton->show(); | 394 | prevButton->show(); |
394 | nextButton->show(); | 395 | nextButton->show(); |
395 | upButton->hide(); | 396 | upButton->hide(); |
396 | fsButton->hide(); | 397 | fsButton->hide(); |
397 | viewModeButton->hide(); | 398 | viewModeButton->hide(); |
398 | } | 399 | } |
399 | if (m_disp->fullScreen()) { | 400 | if (m_disp->fullScreen()) { |
400 | tFrame->setActiveWindow(); | 401 | tFrame->setActiveWindow(); |
401 | tFrame->showFullScreen(); | 402 | tFrame->showFullScreen(); |
402 | } else { | 403 | } else { |
403 | m_stack->raiseWidget( ImageDisplay ); | 404 | m_stack->raiseWidget( ImageDisplay ); |
404 | } | 405 | } |
405 | } | 406 | } |
406 | 407 | ||
407 | void PMainWindow::slotReturn() { | 408 | void PMainWindow::slotReturn() { |
408 | raiseIconView(); | 409 | raiseIconView(); |
409 | } | 410 | } |
410 | 411 | ||
411 | 412 | ||
412 | void PMainWindow::closeEvent( QCloseEvent* ev ) { | 413 | void PMainWindow::closeEvent( QCloseEvent* ev ) { |
413 | /* | 414 | /* |
414 | * return from view | 415 | * return from view |
415 | * or properly quit | 416 | * or properly quit |
416 | */ | 417 | */ |
417 | if ( m_stack->visibleWidget() == m_info || | 418 | if ( m_stack->visibleWidget() == m_info || |
418 | m_stack->visibleWidget() == m_disp ) { | 419 | m_stack->visibleWidget() == m_disp ) { |
diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp index f695a76..73b2863 100644 --- a/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp +++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp | |||
@@ -1,148 +1,152 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include "doc_lister.h" | 5 | #include "doc_lister.h" |
6 | 6 | ||
7 | #include <lib/slavemaster.h> | 7 | #include <lib/slavemaster.h> |
8 | 8 | ||
9 | /* OPIE */ | 9 | /* OPIE */ |
10 | #include <opie2/odebug.h> | 10 | #include <opie2/odebug.h> |
11 | #include <qpe/config.h> | 11 | #include <qpe/config.h> |
12 | #include <qpe/qpeapplication.h> | 12 | #include <qpe/qpeapplication.h> |
13 | #include <qpe/applnk.h> | 13 | #include <qpe/applnk.h> |
14 | 14 | ||
15 | using namespace Opie::Core; | 15 | using namespace Opie::Core; |
16 | 16 | ||
17 | /* QT */ | 17 | /* QT */ |
18 | #include <qdir.h> | 18 | #include <qdir.h> |
19 | #include <qfileinfo.h> | 19 | #include <qfileinfo.h> |
20 | 20 | ||
21 | Doc_DirLister::Doc_DirLister() | 21 | Doc_DirLister::Doc_DirLister() |
22 | : PDirLister( "doc_dir_lister" ) | 22 | : PDirLister( "doc_dir_lister" ) |
23 | { | 23 | { |
24 | SlaveMaster* master = SlaveMaster::self(); | 24 | SlaveMaster* master = SlaveMaster::self(); |
25 | connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) ); | 25 | connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) ); |
26 | connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) ); | 26 | connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) ); |
27 | connect( master, SIGNAL(sig_thumbInfo(const QString&, const QString&)), | 27 | connect( master, SIGNAL(sig_thumbInfo(const QString&, const QString&)), |
28 | this, SLOT(slotThumbInfo(const QString&, const QString&)) ); | 28 | this, SLOT(slotThumbInfo(const QString&, const QString&)) ); |
29 | connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), | 29 | connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), |
30 | this, SLOT(slotFullInfo(const QString&, const QString&)) ); | 30 | this, SLOT(slotFullInfo(const QString&, const QString&)) ); |
31 | connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)), | 31 | connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)), |
32 | this, SLOT(slotThumbNail(const QString&, const QPixmap&)) ); | 32 | this, SLOT(slotThumbNail(const QString&, const QPixmap&)) ); |
33 | 33 | ||
34 | m_namemap.clear(); | ||
35 | m_filemap.clear(); | ||
34 | } | 36 | } |
35 | 37 | ||
36 | QString Doc_DirLister::defaultPath()const { | 38 | QString Doc_DirLister::defaultPath()const { |
37 | return ""; QPEApplication::documentDir(); | 39 | return ""; QPEApplication::documentDir(); |
38 | } | 40 | } |
39 | 41 | ||
40 | QString Doc_DirLister::setStartPath( const QString& path ) { | 42 | QString Doc_DirLister::setStartPath(const QString&) { |
41 | m_namemap.clear(); | ||
42 | m_out.clear(); | ||
43 | static const QString Mtype_str("image/jpeg;image/gif;image/bmp;image/png"); | 43 | static const QString Mtype_str("image/jpeg;image/gif;image/bmp;image/png"); |
44 | owarn << "Set start path" << oendl; | 44 | if (m_namemap.isEmpty()) { |
45 | DocLnkSet ds; | 45 | DocLnkSet ds; |
46 | Global::findDocuments(&ds,Mtype_str); | 46 | Global::findDocuments(&ds,Mtype_str); |
47 | QListIterator<DocLnk> dit(ds.children()); | 47 | QListIterator<DocLnk> dit(ds.children()); |
48 | for( ; dit.current(); ++dit) { | 48 | for( ; dit.current(); ++dit) { |
49 | owarn << (*dit)->file() << oendl; | 49 | owarn << (*dit)->file() << oendl; |
50 | m_namemap[(*dit)->name()]=(*dit)->file(); | 50 | m_namemap[(*dit)->name()]=(*dit)->file(); |
51 | m_filemap[(*dit)->file()]=(*dit)->name(); | 51 | m_filemap[(*dit)->file()]=(*dit)->name(); |
52 | m_out.append((*dit)->name()); | 52 | } |
53 | } | 53 | } |
54 | owarn << "Set start path end" << oendl; | 54 | return QString::null; |
55 | return ""; | ||
56 | } | 55 | } |
57 | 56 | ||
58 | QString Doc_DirLister::currentPath()const { | 57 | QString Doc_DirLister::currentPath()const { |
59 | return ""; | 58 | return QString::null; |
60 | } | 59 | } |
61 | 60 | ||
62 | 61 | ||
63 | QStringList Doc_DirLister::folders()const { | 62 | QStringList Doc_DirLister::folders()const { |
64 | return QStringList(); | 63 | return QStringList(); |
65 | } | 64 | } |
66 | 65 | ||
67 | QStringList Doc_DirLister::files()const { | 66 | QStringList Doc_DirLister::files()const { |
68 | return m_out; | 67 | QStringList out; |
68 | QMap<QString,QString>::ConstIterator it; | ||
69 | for (it = m_namemap.begin();it != m_namemap.end();++it) { | ||
70 | out.append(it.key()); | ||
71 | } | ||
72 | return out; | ||
69 | } | 73 | } |
70 | 74 | ||
71 | void Doc_DirLister::deleteImage( const QString& ) { | 75 | void Doc_DirLister::deleteImage( const QString& ) |
76 | { | ||
72 | } | 77 | } |
73 | 78 | ||
74 | void Doc_DirLister::thumbNail( const QString& str, int w, int h) { | 79 | void Doc_DirLister::thumbNail( const QString& str, int w, int h) { |
75 | if (m_namemap.find(str)==m_namemap.end()) { | 80 | if (m_namemap.find(str)==m_namemap.end()) { |
76 | owarn << "Item " << str << " not found" << oendl; | 81 | owarn << "Item " << str << " not found" << oendl; |
77 | return; | 82 | return; |
78 | } | 83 | } |
79 | QString fname = m_namemap[str]; | 84 | QString fname = m_namemap[str]; |
80 | SlaveMaster::self()->thumbNail( fname, w, h ); | 85 | SlaveMaster::self()->thumbNail( fname, w, h ); |
81 | } | 86 | } |
82 | 87 | ||
83 | QImage Doc_DirLister::image( const QString& str, Factor f, int m) { | 88 | QImage Doc_DirLister::image( const QString& str, Factor f, int m) { |
84 | if (m_namemap.find(str)==m_namemap.end()) { | 89 | if (m_namemap.find(str)==m_namemap.end()) { |
85 | owarn << "Item " << str << " not found" << oendl; | 90 | owarn << "Item " << str << " not found" << oendl; |
86 | return QImage(); | 91 | return QImage(); |
87 | } | 92 | } |
88 | QString fname = m_namemap[str]; | 93 | QString fname = m_namemap[str]; |
89 | return SlaveMaster::self()->image( fname, f, m ); | 94 | return SlaveMaster::self()->image( fname, f, m ); |
90 | } | 95 | } |
91 | 96 | ||
92 | void Doc_DirLister::imageInfo( const QString& str) { | 97 | void Doc_DirLister::imageInfo( const QString& str) { |
93 | if (m_namemap.find(str)==m_namemap.end()) { | 98 | if (m_namemap.find(str)==m_namemap.end()) { |
94 | owarn << "Item " << str << " not found" << oendl; | 99 | owarn << "Item " << str << " not found" << oendl; |
95 | return; | 100 | return; |
96 | } | 101 | } |
97 | QString fname = m_namemap[str]; | 102 | QString fname = m_namemap[str]; |
98 | owarn << "Image info: " << fname << oendl; | ||
99 | SlaveMaster::self()->thumbInfo( fname ); | 103 | SlaveMaster::self()->thumbInfo( fname ); |
100 | } | 104 | } |
101 | 105 | ||
102 | void Doc_DirLister::fullImageInfo( const QString& str) { | 106 | void Doc_DirLister::fullImageInfo( const QString& str) { |
103 | if (m_namemap.find(str)==m_namemap.end()) { | 107 | if (m_namemap.find(str)==m_namemap.end()) { |
104 | owarn << "Item " << str << " not found" << oendl; | 108 | owarn << "Item " << str << " not found" << oendl; |
105 | return; | 109 | return; |
106 | } | 110 | } |
107 | QString fname = m_namemap[str]; | 111 | QString fname = m_namemap[str]; |
108 | SlaveMaster::self()->imageInfo( fname ); | 112 | SlaveMaster::self()->imageInfo( fname ); |
109 | } | 113 | } |
110 | 114 | ||
111 | void Doc_DirLister::slotFullInfo(const QString&f, const QString&t) | 115 | void Doc_DirLister::slotFullInfo(const QString&f, const QString&t) |
112 | { | 116 | { |
113 | if (m_filemap.find(f)==m_filemap.end()) { | 117 | if (m_filemap.find(f)==m_filemap.end()) { |
114 | owarn << "Item " << f << " not found" << oendl; | 118 | owarn << "Item " << f << " not found" << oendl; |
115 | return; | 119 | return; |
116 | } | 120 | } |
117 | QString name = m_filemap[f]; | 121 | QString name = m_filemap[f]; |
118 | emit sig_fullInfo(name, t); | 122 | emit sig_fullInfo(name, t); |
119 | } | 123 | } |
120 | 124 | ||
121 | void Doc_DirLister::slotThumbInfo(const QString&f, const QString&t) | 125 | void Doc_DirLister::slotThumbInfo(const QString&f, const QString&t) |
122 | { | 126 | { |
123 | if (m_filemap.find(f)==m_filemap.end()) { | 127 | if (m_filemap.find(f)==m_filemap.end()) { |
124 | owarn << "Item " << f << " not found" << oendl; | 128 | owarn << "Item " << f << " not found" << oendl; |
125 | return; | 129 | return; |
126 | } | 130 | } |
127 | QString name = m_filemap[f]; | 131 | QString name = m_filemap[f]; |
128 | emit sig_thumbInfo(name, t); | 132 | emit sig_thumbInfo(name, t); |
129 | } | 133 | } |
130 | 134 | ||
131 | void Doc_DirLister::slotThumbNail(const QString&f, const QPixmap&p) | 135 | void Doc_DirLister::slotThumbNail(const QString&f, const QPixmap&p) |
132 | { | 136 | { |
133 | if (m_filemap.find(f)==m_filemap.end()) { | 137 | if (m_filemap.find(f)==m_filemap.end()) { |
134 | owarn << "Item " << f << " not found" << oendl; | 138 | owarn << "Item " << f << " not found" << oendl; |
135 | return; | 139 | return; |
136 | } | 140 | } |
137 | QString name = m_filemap[f]; | 141 | QString name = m_filemap[f]; |
138 | emit sig_thumbNail(name, p); | 142 | emit sig_thumbNail(name, p); |
139 | } | 143 | } |
140 | 144 | ||
141 | QString Doc_DirLister::nameToFname(const QString&name)const | 145 | QString Doc_DirLister::nameToFname(const QString&name)const |
142 | { | 146 | { |
143 | if (m_namemap.find(name)==m_namemap.end()) { | 147 | if (m_namemap.find(name)==m_namemap.end()) { |
144 | owarn << "Item " << name << " not found" << oendl; | 148 | owarn << "Item " << name << " not found" << oendl; |
145 | return QString::null; | 149 | return QString::null; |
146 | } | 150 | } |
147 | return m_namemap[name]; | 151 | return m_namemap[name]; |
148 | } | 152 | } |
diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.h b/noncore/graphics/opie-eye/impl/doc/doc_lister.h index d89b579..a65b616 100644 --- a/noncore/graphics/opie-eye/impl/doc/doc_lister.h +++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.h | |||
@@ -1,42 +1,41 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #ifndef DOC_LISTER_INTERFACE_LISTER_H | 5 | #ifndef DOC_LISTER_INTERFACE_LISTER_H |
6 | #define DOC_LISTER_INTERFACE_LISTER_H | 6 | #define DOC_LISTER_INTERFACE_LISTER_H |
7 | 7 | ||
8 | #include <iface/dirlister.h> | 8 | #include <iface/dirlister.h> |
9 | 9 | ||
10 | #include <qstring.h> | 10 | #include <qstring.h> |
11 | #include <qmap.h> | 11 | #include <qmap.h> |
12 | 12 | ||
13 | class Config; | 13 | class Config; |
14 | class Doc_DirLister : public PDirLister { | 14 | class Doc_DirLister : public PDirLister { |
15 | Q_OBJECT | 15 | Q_OBJECT |
16 | public: | 16 | public: |
17 | Doc_DirLister(); | 17 | Doc_DirLister(); |
18 | virtual ~Doc_DirLister(){} | 18 | virtual ~Doc_DirLister(){} |
19 | 19 | ||
20 | QString defaultPath()const; | 20 | QString defaultPath()const; |
21 | QString setStartPath( const QString& ); | 21 | QString setStartPath( const QString& ); |
22 | QString currentPath()const; | 22 | QString currentPath()const; |
23 | QStringList folders()const; | 23 | QStringList folders()const; |
24 | QStringList files()const; | 24 | QStringList files()const; |
25 | 25 | ||
26 | void deleteImage( const QString& ); | 26 | void deleteImage( const QString& ); |
27 | void thumbNail( const QString&, int, int ); | 27 | void thumbNail( const QString&, int, int ); |
28 | QImage image( const QString&, Factor, int ); | 28 | QImage image( const QString&, Factor, int ); |
29 | void imageInfo( const QString& ); | 29 | void imageInfo( const QString& ); |
30 | void fullImageInfo( const QString& ); | 30 | void fullImageInfo( const QString& ); |
31 | virtual QString nameToFname(const QString&name)const; | 31 | virtual QString nameToFname(const QString&name)const; |
32 | 32 | ||
33 | private: | 33 | private: |
34 | QMap<QString,QString> m_namemap,m_filemap; | 34 | QMap<QString,QString> m_namemap,m_filemap; |
35 | QStringList m_out; | ||
36 | protected slots: | 35 | protected slots: |
37 | virtual void slotFullInfo(const QString&, const QString&); | 36 | virtual void slotFullInfo(const QString&, const QString&); |
38 | virtual void slotThumbInfo(const QString&, const QString&); | 37 | virtual void slotThumbInfo(const QString&, const QString&); |
39 | virtual void slotThumbNail(const QString&, const QPixmap&); | 38 | virtual void slotThumbNail(const QString&, const QPixmap&); |
40 | }; | 39 | }; |
41 | 40 | ||
42 | #endif | 41 | #endif |