Diffstat (limited to 'noncore/graphics/opie-eye/gui/iconview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 59091a8..9365932 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -1,44 +1,44 @@ | |||
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 | #include "messagebox.h" | 7 | #include "messagebox.h" |
8 | 8 | ||
9 | #include <lib/imagecache.h> | 9 | #include <lib/imagecache.h> |
10 | #include <gui/imageinfoui.h> | 10 | #include <gui/imageinfoui.h> |
11 | 11 | ||
12 | #include <iface/dirview.h> | 12 | #include <iface/dirview.h> |
13 | #include <iface/dirlister.h> | 13 | #include <iface/dirlister.h> |
14 | 14 | ||
15 | #include <opie2/oconfig.h> | 15 | #include <opie2/oconfig.h> |
16 | #include <opie2/okeyconfigwidget.h> | 16 | #include <opie2/okeyconfigwidget.h> |
17 | #include <opie2/odebug.h> | 17 | #include <opie2/odebug.h> |
18 | #include <opie2/oimagescrollview.h> | 18 | #include <opie2/oimagescrollview.h> |
19 | #include <opie2/oresource.h> | ||
19 | 20 | ||
20 | #include <qpe/resource.h> | ||
21 | #include <qpe/qpemessagebox.h> | 21 | #include <qpe/qpemessagebox.h> |
22 | #include <qpe/ir.h> | 22 | #include <qpe/ir.h> |
23 | #include <qpe/qcopenvelope_qws.h> | 23 | #include <qpe/qcopenvelope_qws.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | 25 | ||
26 | #include <qiconview.h> | 26 | #include <qiconview.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qhbox.h> | 28 | #include <qhbox.h> |
29 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | #include <qmainwindow.h> | 32 | #include <qmainwindow.h> |
33 | #include <qtimer.h> | 33 | #include <qtimer.h> |
34 | #include <qstyle.h> | 34 | #include <qstyle.h> |
35 | 35 | ||
36 | 36 | ||
37 | using Opie::Core::OKeyConfigItem; | 37 | using Opie::Core::OKeyConfigItem; |
38 | 38 | ||
39 | const int PIconView::sMAX_ICON_SIZE = 128; | 39 | const int PIconView::sMAX_ICON_SIZE = 128; |
40 | const int PIconView::sMIN_ICON_SIZE = 12; | 40 | const int PIconView::sMIN_ICON_SIZE = 12; |
41 | const int PIconView::sDEF_ICON_SIZE = 64; | 41 | const int PIconView::sDEF_ICON_SIZE = 64; |
42 | 42 | ||
43 | /* | 43 | /* |
44 | * The Icons, Request Cache and IconViewItem for the IconView | 44 | * The Icons, Request Cache and IconViewItem for the IconView |
@@ -81,53 +81,53 @@ namespace { | |||
81 | void setText( const QString& ); | 81 | void setText( const QString& ); |
82 | }; | 82 | }; |
83 | class ThumbViewItem : public IconViewItem { | 83 | class ThumbViewItem : public IconViewItem { |
84 | ThumbViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize, bool isDir = false ); | 84 | ThumbViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize, bool isDir = false ); |
85 | QPixmap *pixmap()const; | 85 | QPixmap *pixmap()const; |
86 | void setText( const QString& ); | 86 | void setText( const QString& ); |
87 | }; | 87 | }; |
88 | 88 | ||
89 | 89 | ||
90 | /* | 90 | /* |
91 | * If we request an Image or String | 91 | * If we request an Image or String |
92 | * we add it to the map | 92 | * we add it to the map |
93 | */ | 93 | */ |
94 | static QMap<QString, IconViewItem*> g_stringInf; | 94 | static QMap<QString, IconViewItem*> g_stringInf; |
95 | static QMap<QString, IconViewItem*> g_stringPix; | 95 | static QMap<QString, IconViewItem*> g_stringPix; |
96 | 96 | ||
97 | IconViewItem::IconViewItem( QIconView* view,const QString& path, | 97 | IconViewItem::IconViewItem( QIconView* view,const QString& path, |
98 | const QString& name, int a_iconsize, bool isDir) | 98 | const QString& name, int a_iconsize, bool isDir) |
99 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), | 99 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), |
100 | m_noInfo( false ),m_textOnly(false),m_Pixset(false) | 100 | m_noInfo( false ),m_textOnly(false),m_Pixset(false) |
101 | { | 101 | { |
102 | m_iconsize = a_iconsize; | 102 | m_iconsize = a_iconsize; |
103 | if ( isDir ) { | 103 | if ( isDir ) { |
104 | if (!_dirPix ) { | 104 | if (!_dirPix ) { |
105 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); | 105 | _dirPix = new QPixmap( Opie::Core::OResource::loadPixmap("advancedfm/FileBrowser", Opie::Core::OResource::SmallIcon)); |
106 | } | 106 | } |
107 | } else { | 107 | } else { |
108 | if (!_unkPix ) { | 108 | if (!_unkPix ) { |
109 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); | 109 | _unkPix = new QPixmap( Opie::Core::OResource::loadPixmap( "UnknownDocument", Opie::Core::OResource::SmallIcon ) ); |
110 | } | 110 | } |
111 | } | 111 | } |
112 | check_pix(); | 112 | check_pix(); |
113 | } | 113 | } |
114 | 114 | ||
115 | inline void IconViewItem::check_pix()const | 115 | inline void IconViewItem::check_pix()const |
116 | { | 116 | { |
117 | if (_dirPix && _dirPix->width()>m_iconsize) { | 117 | if (_dirPix && _dirPix->width()>m_iconsize) { |
118 | QImage Pix = _dirPix->convertToImage(); | 118 | QImage Pix = _dirPix->convertToImage(); |
119 | *_dirPix = Pix.smoothScale(m_iconsize,m_iconsize); | 119 | *_dirPix = Pix.smoothScale(m_iconsize,m_iconsize); |
120 | } | 120 | } |
121 | if (!_cpyPix && _unkPix) { | 121 | if (!_cpyPix && _unkPix) { |
122 | if (_unkPix->width()>=m_iconsize) { | 122 | if (_unkPix->width()>=m_iconsize) { |
123 | QImage Pix = _unkPix->convertToImage(); | 123 | QImage Pix = _unkPix->convertToImage(); |
124 | _cpyPix = new QPixmap(); | 124 | _cpyPix = new QPixmap(); |
125 | if (_unkPix->width()>m_iconsize) { | 125 | if (_unkPix->width()>m_iconsize) { |
126 | *_cpyPix = Pix.smoothScale(m_iconsize,m_iconsize); | 126 | *_cpyPix = Pix.smoothScale(m_iconsize,m_iconsize); |
127 | } else { | 127 | } else { |
128 | _cpyPix->convertFromImage(Pix); | 128 | _cpyPix->convertFromImage(Pix); |
129 | } | 129 | } |
130 | 130 | ||
131 | } else { | 131 | } else { |
132 | _cpyPix = new QPixmap(m_iconsize,m_iconsize); | 132 | _cpyPix = new QPixmap(m_iconsize,m_iconsize); |
133 | _cpyPix->fill(); | 133 | _cpyPix->fill(); |
@@ -249,66 +249,66 @@ PIconView::~PIconView() { | |||
249 | m_viewManager->save(); | 249 | m_viewManager->save(); |
250 | delete m_viewManager; | 250 | delete m_viewManager; |
251 | } | 251 | } |
252 | 252 | ||
253 | Opie::Core::OKeyConfigManager* PIconView::manager() { | 253 | Opie::Core::OKeyConfigManager* PIconView::manager() { |
254 | return m_viewManager; | 254 | return m_viewManager; |
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
258 | /* | 258 | /* |
259 | * init the KeyBoard Shortcuts | 259 | * init the KeyBoard Shortcuts |
260 | * called from the c'tor | 260 | * called from the c'tor |
261 | */ | 261 | */ |
262 | void PIconView::initKeys() { | 262 | void PIconView::initKeys() { |
263 | Opie::Core::OKeyPair::List lst; | 263 | Opie::Core::OKeyPair::List lst; |
264 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); | 264 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); |
265 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | 265 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); |
266 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | 266 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); |
267 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 267 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
268 | lst.append( Opie::Core::OKeyPair::returnKey() ); | 268 | lst.append( Opie::Core::OKeyPair::returnKey() ); |
269 | 269 | ||
270 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", | 270 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", |
271 | lst, false,this, "keyconfig name" ); | 271 | lst, false,this, "keyconfig name" ); |
272 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", | 272 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", |
273 | Resource::loadPixmap("beam"), BeamItem, | 273 | Opie::Core::OResource::loadPixmap("beam", Opie::Core::OResource::SmallIcon), |
274 | Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), | 274 | BeamItem, Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), |
275 | this, SLOT(slotBeam())) ); | 275 | this, SLOT(slotBeam())) ); |
276 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", | 276 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", |
277 | Resource::loadPixmap("trash"), DeleteItem, | 277 | Opie::Core::OResource::loadPixmap("trash", Opie::Core::OResource::SmallIcon), |
278 | Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), | 278 | DeleteItem, Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), |
279 | this, SLOT(slotTrash())) ); | 279 | this, SLOT(slotTrash())) ); |
280 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", | 280 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", |
281 | Resource::loadPixmap("1to1"), ViewItem, | 281 | Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), |
282 | Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), | 282 | ViewItem, Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), |
283 | this, SLOT(slotShowImage()))); | 283 | this, SLOT(slotShowImage()))); |
284 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", | 284 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", |
285 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, | 285 | Opie::Core::OResource::loadPixmap("DocumentTypeWord", Opie::Core::OResource::SmallIcon), |
286 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), | 286 | InfoItem, Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), |
287 | this, SLOT(slotImageInfo()) ) ); | 287 | this, SLOT(slotImageInfo()) ) ); |
288 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow", | 288 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow", |
289 | Resource::loadPixmap("1to1"), SlideItem, | 289 | Opie::Core::OResource::loadPixmap("1to1", Opie::Core::OResource::SmallIcon), |
290 | Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton), | 290 | SlideItem, Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton), |
291 | this, SLOT(slotStartSlide()))); | 291 | this, SLOT(slotStartSlide()))); |
292 | m_viewManager->load(); | 292 | m_viewManager->load(); |
293 | m_viewManager->handleWidget( m_view ); | 293 | m_viewManager->handleWidget( m_view ); |
294 | } | 294 | } |
295 | 295 | ||
296 | 296 | ||
297 | /* | 297 | /* |
298 | * change one dir up | 298 | * change one dir up |
299 | */ | 299 | */ |
300 | void PIconView::slotDirUp() | 300 | void PIconView::slotDirUp() |
301 | { | 301 | { |
302 | slotChangeDir( currentView()->dirLister()->dirUp( m_path ) ); | 302 | slotChangeDir( currentView()->dirLister()->dirUp( m_path ) ); |
303 | } | 303 | } |
304 | 304 | ||
305 | /* | 305 | /* |
306 | * change the dir | 306 | * change the dir |
307 | */ | 307 | */ |
308 | void PIconView::slotChangeDir(const QString& path) { | 308 | void PIconView::slotChangeDir(const QString& path) { |
309 | if ( !currentView() ) | 309 | if ( !currentView() ) |
310 | return; | 310 | return; |
311 | 311 | ||
312 | PDirLister *lister = currentView()->dirLister(); | 312 | PDirLister *lister = currentView()->dirLister(); |
313 | if (!lister ) | 313 | if (!lister ) |
314 | return; | 314 | return; |
@@ -621,49 +621,50 @@ void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { | |||
621 | return; | 621 | return; |
622 | 622 | ||
623 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 623 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
624 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 624 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
625 | m_updatet = true; | 625 | m_updatet = true; |
626 | 626 | ||
627 | if (pix.width()>0) { | 627 | if (pix.width()>0) { |
628 | if (pix.width()<m_iconsize) { | 628 | if (pix.width()<m_iconsize) { |
629 | QPixmap p(m_iconsize,m_iconsize); | 629 | QPixmap p(m_iconsize,m_iconsize); |
630 | p.fill(); | 630 | p.fill(); |
631 | QPainter pa(&p); | 631 | QPainter pa(&p); |
632 | int offset = (m_iconsize-pix.width())/2; | 632 | int offset = (m_iconsize-pix.width())/2; |
633 | int offy = (m_iconsize-pix.height())/2; | 633 | int offy = (m_iconsize-pix.height())/2; |
634 | if (offy<0) offy=0; | 634 | if (offy<0) offy=0; |
635 | pa.drawPixmap(offset,offy,pix); | 635 | pa.drawPixmap(offset,offy,pix); |
636 | pa.end(); | 636 | pa.end(); |
637 | PPixmapCache::self()->insertImage( _path, p, m_iconsize, m_iconsize ); | 637 | PPixmapCache::self()->insertImage( _path, p, m_iconsize, m_iconsize ); |
638 | item->setPixmap(p,true); | 638 | item->setPixmap(p,true); |
639 | } else { | 639 | } else { |
640 | PPixmapCache::self()->insertImage( _path, pix, m_iconsize, m_iconsize ); | 640 | PPixmapCache::self()->insertImage( _path, pix, m_iconsize, m_iconsize ); |
641 | item->setPixmap(pix,true); | 641 | item->setPixmap(pix,true); |
642 | } | 642 | } |
643 | 643 | ||
644 | } else { | 644 | } else { |
645 | PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), m_iconsize, m_iconsize ); | 645 | PPixmapCache::self()->insertImage( _path, Opie::Core::OResource::loadPixmap( "UnknownDocument", |
646 | Opie::Core::OResource::SmallIcon ), m_iconsize, m_iconsize ); | ||
646 | } | 647 | } |
647 | g_stringPix.remove( _path ); | 648 | g_stringPix.remove( _path ); |
648 | m_view->arrangeItemsInGrid(true); | 649 | m_view->arrangeItemsInGrid(true); |
649 | } | 650 | } |
650 | 651 | ||
651 | 652 | ||
652 | /* | 653 | /* |
653 | * FIXME rename | 654 | * FIXME rename |
654 | */ | 655 | */ |
655 | void PIconView::slotRename() { | 656 | void PIconView::slotRename() { |
656 | 657 | ||
657 | } | 658 | } |
658 | 659 | ||
659 | 660 | ||
660 | /* | 661 | /* |
661 | * BEAM the current file | 662 | * BEAM the current file |
662 | */ | 663 | */ |
663 | void PIconView::slotBeam() { | 664 | void PIconView::slotBeam() { |
664 | bool isDir; | 665 | bool isDir; |
665 | QString pa = currentFileName( isDir ); | 666 | QString pa = currentFileName( isDir ); |
666 | if ( isDir && pa.isEmpty() ) | 667 | if ( isDir && pa.isEmpty() ) |
667 | return; | 668 | return; |
668 | 669 | ||
669 | Ir* ir = new Ir( this ); | 670 | Ir* ir = new Ir( this ); |