author | zecke <zecke> | 2004-04-14 18:38:37 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-04-14 18:38:37 (UTC) |
commit | 0b83b10334da449fb9304c9b89a4175f3728d377 (patch) (unidiff) | |
tree | 465cdb61d1fa032de425761ef0074ee58bad7cd2 | |
parent | b671d282c25e86429727b6b52a674d1d8cd3f1a7 (diff) | |
download | opie-0b83b10334da449fb9304c9b89a4175f3728d377.zip opie-0b83b10334da449fb9304c9b89a4175f3728d377.tar.gz opie-0b83b10334da449fb9304c9b89a4175f3728d377.tar.bz2 |
-comments on imagezoomer
recalculateGrid Alwin please fill in the blank
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 20 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.h | 4 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/viewmodebutton.cpp | 29 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/viewmodebutton.h | 2 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/lib/oimagezoomer.cpp | 9 |
5 files changed, 56 insertions, 8 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index a06844a..e61f9d9 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -450,42 +450,54 @@ void PIconView::slotShowImage() | |||
450 | { | 450 | { |
451 | bool isDir = false; | 451 | bool isDir = false; |
452 | QString name = currentFileName(isDir); | 452 | QString name = currentFileName(isDir); |
453 | if (isDir) return; | 453 | if (isDir) return; |
454 | 454 | ||
455 | slotShowImage( name ); | 455 | slotShowImage( name ); |
456 | } | 456 | } |
457 | void PIconView::slotShowImage( const QString& name) { | 457 | void PIconView::slotShowImage( const QString& name) { |
458 | emit sig_display( name ); | 458 | emit sig_display( name ); |
459 | } | 459 | } |
460 | void PIconView::slotImageInfo() { | 460 | void PIconView::slotImageInfo() { |
461 | bool isDir = false; | 461 | bool isDir = false; |
462 | QString name = currentFileName(isDir); | 462 | QString name = currentFileName(isDir); |
463 | if (isDir) return; | 463 | if (isDir) return; |
464 | 464 | ||
465 | slotImageInfo( name ); | 465 | slotImageInfo( name ); |
466 | } | 466 | } |
467 | 467 | ||
468 | void PIconView::slotImageInfo( const QString& name) { | 468 | void PIconView::slotImageInfo( const QString& name) { |
469 | emit sig_showInfo( name ); | 469 | emit sig_showInfo( name ); |
470 | } | 470 | } |
471 | 471 | ||
472 | 472 | ||
473 | void PIconView::slotChangeMode( int mode ) { | 473 | void PIconView::slotChangeMode( int mode ) { |
474 | if ( mode >= 0 && mode <= 3 ) | 474 | if ( mode >= 1 && mode <= 3 ) |
475 | m_mode = mode; | 475 | m_mode = mode; |
476 | 476 | ||
477 | QIconView::ItemTextPos pos; | 477 | QIconView::ItemTextPos pos; |
478 | switch( m_mode ) { | 478 | switch( m_mode ) { |
479 | case 1: | 479 | case 2: |
480 | pos = QIconView::Bottom; | 480 | pos = QIconView::Bottom; |
481 | break; | 481 | break; |
482 | case 2: | 482 | case 3: |
483 | case 0: | 483 | case 1: |
484 | default: | 484 | default: |
485 | pos = QIconView::Right; | 485 | pos = QIconView::Right; |
486 | break; | 486 | break; |
487 | } | 487 | } |
488 | m_view->setItemTextPos( pos ); | 488 | m_view->setItemTextPos( pos ); |
489 | 489 | ||
490 | calculateGrid(); | ||
490 | slotReloadDir(); | 491 | slotReloadDir(); |
491 | } | 492 | } |
493 | |||
494 | |||
495 | void PIconView::resizeEvent( QResizeEvent* re ) { | ||
496 | QVBox::resizeEvent( re ); | ||
497 | calculateGrid(); | ||
498 | } | ||
499 | |||
500 | |||
501 | void PIconView::calculateGrid() { | ||
502 | |||
503 | } | ||
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h index af41aef..903c4fd 100644 --- a/noncore/graphics/opie-eye/gui/iconview.h +++ b/noncore/graphics/opie-eye/gui/iconview.h | |||
@@ -18,52 +18,56 @@ class Ir; | |||
18 | 18 | ||
19 | namespace Opie { | 19 | namespace Opie { |
20 | namespace Core{ | 20 | namespace Core{ |
21 | class OConfig; | 21 | class OConfig; |
22 | class OKeyConfigManager; | 22 | class OKeyConfigManager; |
23 | } | 23 | } |
24 | } | 24 | } |
25 | 25 | ||
26 | class PIconView : public QVBox { | 26 | class 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 | 30 | BeamItem, DeleteItem, ViewItem, InfoItem |
31 | }; | 31 | }; |
32 | public: | 32 | public: |
33 | PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); | 33 | PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); |
34 | ~PIconView(); | 34 | ~PIconView(); |
35 | void resetView(); | 35 | void resetView(); |
36 | Opie::Core::OKeyConfigManager* manager(); | 36 | Opie::Core::OKeyConfigManager* manager(); |
37 | 37 | ||
38 | signals: | 38 | signals: |
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 | 41 | ||
42 | protected: | ||
43 | void resizeEvent( QResizeEvent* ); | ||
44 | |||
42 | private: | 45 | private: |
43 | void initKeys(); | 46 | void initKeys(); |
44 | QString currentFileName(bool &isDir)const; | 47 | QString currentFileName(bool &isDir)const; |
45 | void loadViews(); | 48 | void loadViews(); |
49 | void calculateGrid(); | ||
46 | 50 | ||
47 | private slots: | 51 | private slots: |
48 | void slotDirUp(); | 52 | void slotDirUp(); |
49 | void slotChangeDir(const QString&); | 53 | void slotChangeDir(const QString&); |
50 | void slotTrash(); | 54 | void slotTrash(); |
51 | void slotViewChanged( int ); | 55 | void slotViewChanged( int ); |
52 | void slotReloadDir(); | 56 | void slotReloadDir(); |
53 | void slotRename(); | 57 | void slotRename(); |
54 | void slotBeam(); | 58 | void slotBeam(); |
55 | void slotBeamDone( Ir* ); | 59 | void slotBeamDone( Ir* ); |
56 | 60 | ||
57 | void slotShowImage(); | 61 | void slotShowImage(); |
58 | void slotShowImage( const QString& ); | 62 | void slotShowImage( const QString& ); |
59 | void slotImageInfo(); | 63 | void slotImageInfo(); |
60 | void slotImageInfo( const QString& ); | 64 | void slotImageInfo( const QString& ); |
61 | 65 | ||
62 | void slotStart(); | 66 | void slotStart(); |
63 | void slotEnd(); | 67 | void slotEnd(); |
64 | 68 | ||
65 | /* for performance reasons make it inline in the future */ | 69 | /* for performance reasons make it inline in the future */ |
66 | void addFolders( const QStringList& ); | 70 | void addFolders( const QStringList& ); |
67 | void addFiles( const QStringList& ); | 71 | void addFiles( const QStringList& ); |
68 | void slotClicked(QIconViewItem* ); | 72 | void slotClicked(QIconViewItem* ); |
69 | 73 | ||
diff --git a/noncore/graphics/opie-eye/gui/viewmodebutton.cpp b/noncore/graphics/opie-eye/gui/viewmodebutton.cpp index fdf4e77..0e4a7cb 100644 --- a/noncore/graphics/opie-eye/gui/viewmodebutton.cpp +++ b/noncore/graphics/opie-eye/gui/viewmodebutton.cpp | |||
@@ -1,24 +1,45 @@ | |||
1 | #include "viewmodebutton.h" | 1 | #include "viewmodebutton.h" |
2 | 2 | ||
3 | #include <opie2/odebug.h> | ||
4 | |||
3 | #include <qtoolbar.h> | 5 | #include <qtoolbar.h> |
4 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
5 | 7 | ||
6 | ViewModeButton::ViewModeButton( QToolBar* bar ) | 8 | ViewModeButton::ViewModeButton( QToolBar* bar ) |
7 | : QToolButton( bar ) | 9 | : QToolButton( bar ) |
8 | { | 10 | { |
9 | setIconSet( Resource::loadIconSet( "toys" ) ); | 11 | slotChange( 1 ); |
10 | QPopupMenu *pop= new QPopupMenu( this ); | 12 | QPopupMenu *pop= new QPopupMenu( this ); |
11 | pop->setCheckable( true ); | 13 | pop->setCheckable( true ); |
12 | pop->insertItem( tr("Thumbnail and Imageinfo"), 0 ); | 14 | pop->insertItem( tr("Thumbnail and Imageinfo"), 1 ); |
13 | pop->insertItem( tr("Thumbnail and Name" ), 1 ); | 15 | pop->insertItem( tr("Thumbnail and Name" ), 2 ); |
14 | pop->insertItem( tr("Name Only" ), 2 ); | 16 | pop->insertItem( tr("Name Only" ), 3 ); |
15 | connect(pop, SIGNAL(activated(int)), | 17 | connect(pop, SIGNAL(activated(int)), |
16 | this, SIGNAL(changeMode(int)) ); | 18 | this, SIGNAL(changeMode(int)) ); |
19 | connect(pop, SIGNAL(activated(int)), | ||
20 | this, SLOT(slotChange(int)) ); | ||
17 | 21 | ||
18 | 22 | ||
19 | setPopup( pop ); | 23 | setPopup( pop ); |
20 | } | 24 | } |
21 | 25 | ||
22 | ViewModeButton::~ViewModeButton() { | 26 | ViewModeButton::~ViewModeButton() { |
27 | } | ||
28 | |||
29 | void ViewModeButton::slotChange( int i ) { | ||
30 | QString name; | ||
31 | switch( i ) { | ||
32 | case 1: | ||
33 | name = "opie-eye/opie-eye-thumb"; | ||
34 | break; | ||
35 | case 2: | ||
36 | name = "opie-eye/opie-eye-thumbonly"; | ||
37 | break; | ||
38 | case 3: | ||
39 | name = "opie-eye/opie-eye-textview"; | ||
40 | break; | ||
41 | } | ||
23 | 42 | ||
43 | qWarning("foo %d" +name, i ); | ||
44 | setIconSet( Resource::loadIconSet( name ) ); | ||
24 | } | 45 | } |
diff --git a/noncore/graphics/opie-eye/gui/viewmodebutton.h b/noncore/graphics/opie-eye/gui/viewmodebutton.h index 44f2228..3247114 100644 --- a/noncore/graphics/opie-eye/gui/viewmodebutton.h +++ b/noncore/graphics/opie-eye/gui/viewmodebutton.h | |||
@@ -1,23 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 only | 2 | * GPLv2 only |
3 | * zecke@handhelds.org | 3 | * zecke@handhelds.org |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #ifndef PHUNK_VIEW_MODE_BUTTON_H | 6 | #ifndef PHUNK_VIEW_MODE_BUTTON_H |
7 | #define PHUNK_VIEW_MODE_BUTTON_H | 7 | #define PHUNK_VIEW_MODE_BUTTON_H |
8 | 8 | ||
9 | #include <qpe/resource.h> | 9 | #include <qpe/resource.h> |
10 | 10 | ||
11 | #include <qtoolbutton.h> | 11 | #include <qtoolbutton.h> |
12 | 12 | ||
13 | class ViewModeButton : public QToolButton { | 13 | class ViewModeButton : public QToolButton { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | public: | 15 | public: |
16 | ViewModeButton( QToolBar* ); | 16 | ViewModeButton( QToolBar* ); |
17 | ~ViewModeButton(); | 17 | ~ViewModeButton(); |
18 | 18 | ||
19 | signals: | 19 | signals: |
20 | void changeMode( int ); | 20 | void changeMode( int ); |
21 | private slots: | ||
22 | void slotChange( int i ); | ||
21 | }; | 23 | }; |
22 | 24 | ||
23 | #endif | 25 | #endif |
diff --git a/noncore/graphics/opie-eye/lib/oimagezoomer.cpp b/noncore/graphics/opie-eye/lib/oimagezoomer.cpp index 4df5dcc..00b93e2 100644 --- a/noncore/graphics/opie-eye/lib/oimagezoomer.cpp +++ b/noncore/graphics/opie-eye/lib/oimagezoomer.cpp | |||
@@ -152,48 +152,57 @@ void OImageZoomer::resizeEvent( QResizeEvent* ev ) { | |||
152 | QFrame::resizeEvent( ev ); | 152 | QFrame::resizeEvent( ev ); |
153 | setBackgroundOrigin( QWidget::WidgetOrigin ); | 153 | setBackgroundOrigin( QWidget::WidgetOrigin ); |
154 | // TODO Qt3 use PalettePixmap and use size | 154 | // TODO Qt3 use PalettePixmap and use size |
155 | QPixmap pix; pix.convertFromImage( m_img.smoothScale( size().width(), size().height() ) ); | 155 | QPixmap pix; pix.convertFromImage( m_img.smoothScale( size().width(), size().height() ) ); |
156 | setBackgroundPixmap( pix); | 156 | setBackgroundPixmap( pix); |
157 | } | 157 | } |
158 | 158 | ||
159 | void OImageZoomer::drawContents( QPainter* p ) { | 159 | void OImageZoomer::drawContents( QPainter* p ) { |
160 | /* | 160 | /* |
161 | * if the page size | 161 | * if the page size |
162 | */ | 162 | */ |
163 | if ( m_imgSize.isEmpty() ) | 163 | if ( m_imgSize.isEmpty() ) |
164 | return; | 164 | return; |
165 | 165 | ||
166 | /* | 166 | /* |
167 | * paint a red rect which represents the visible size | 167 | * paint a red rect which represents the visible size |
168 | * | 168 | * |
169 | * We need to recalculate x,y and width and height of the | 169 | * We need to recalculate x,y and width and height of the |
170 | * rect. So image size relates to contentRect | 170 | * rect. So image size relates to contentRect |
171 | * | 171 | * |
172 | */ | 172 | */ |
173 | QRect c( contentsRect() ); | 173 | QRect c( contentsRect() ); |
174 | p->setPen( Qt::red ); | 174 | p->setPen( Qt::red ); |
175 | 175 | ||
176 | /* | ||
177 | * the contentRect is set equal to the size of the image | ||
178 | * Rect/Original = NewRectORWidth/OriginalVisibleStuff and then simply we | ||
179 | * need to add the c.y/x due usage of QFrame | ||
180 | * For x and y we use the visiblePoint | ||
181 | * For height and width we use the size of the viewport | ||
182 | * if width/height would be bigger than our widget we use this width/height | ||
183 | * | ||
184 | */ | ||
176 | int len = m_imgSize.width(); | 185 | int len = m_imgSize.width(); |
177 | int x = (c.width()*m_visPt.x())/len + c.x(); | 186 | int x = (c.width()*m_visPt.x())/len + c.x(); |
178 | int w = (c.width()*m_visSize.width() )/len + c.x(); | 187 | int w = (c.width()*m_visSize.width() )/len + c.x(); |
179 | if ( w > c.width() ) w = c.width(); | 188 | if ( w > c.width() ) w = c.width(); |
180 | 189 | ||
181 | len = m_imgSize.height(); | 190 | len = m_imgSize.height(); |
182 | int y = (c.height()*m_visPt.y() )/len + c.y(); | 191 | int y = (c.height()*m_visPt.y() )/len + c.y(); |
183 | int h = (c.height()*m_visSize.height() )/len + c.y(); | 192 | int h = (c.height()*m_visSize.height() )/len + c.y(); |
184 | if ( h > c.height() ) h = c.height(); | 193 | if ( h > c.height() ) h = c.height(); |
185 | 194 | ||
186 | p->drawRect( x, y, w, h ); | 195 | p->drawRect( x, y, w, h ); |
187 | } | 196 | } |
188 | 197 | ||
189 | void OImageZoomer::mousePressEvent( QMouseEvent* ) { | 198 | void OImageZoomer::mousePressEvent( QMouseEvent* ) { |
190 | m_mouseX = m_mouseY = -1; | 199 | m_mouseX = m_mouseY = -1; |
191 | } | 200 | } |
192 | 201 | ||
193 | void OImageZoomer::mouseMoveEvent( QMouseEvent* ev ) { | 202 | void OImageZoomer::mouseMoveEvent( QMouseEvent* ev ) { |
194 | int mx, my; | 203 | int mx, my; |
195 | mx = ev->x(); | 204 | mx = ev->x(); |
196 | my = ev->y(); | 205 | my = ev->y(); |
197 | 206 | ||
198 | if ( m_mouseX != -1 && m_mouseY != -1 ) { | 207 | if ( m_mouseX != -1 && m_mouseY != -1 ) { |
199 | int diffx = ( mx - m_mouseX ) * m_imgSize.width() / width(); | 208 | int diffx = ( mx - m_mouseX ) * m_imgSize.width() / width(); |