author | zecke <zecke> | 2004-04-14 18:38:37 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-04-14 18:38:37 (UTC) |
commit | 0b83b10334da449fb9304c9b89a4175f3728d377 (patch) (side-by-side diff) | |
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 @@ -282,210 +282,222 @@ void PIconView::slotTrash() { currentView()->dirLister()->deleteImage( pa ); delete m_view->currentItem(); } /* * see what views are available */ void PIconView::loadViews() { ViewMap::Iterator it; ViewMap* map = viewMap(); for ( it = map->begin(); it != map->end(); ++it ) m_views->insertItem( QObject::tr(it.key() ) ); } void PIconView::resetView() { slotViewChanged(m_views->currentItem()); } /* *swicth view reloadDir and connect signals */ void PIconView::slotViewChanged( int i) { if (!m_views->count() ) { setCurrentView( 0l); return; } PDirView* cur = currentView(); delete cur; QString str = m_views->text(i); cur = (*(*viewMap())[str])(*m_cfg); setCurrentView( cur ); /* connect to the signals of the lister */ PDirLister* lis = cur->dirLister(); connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), this, SLOT( slotThumbInfo(const QString&, const QString&))); connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), this, SLOT(slotThumbNail(const QString&, const QPixmap&))); connect(lis, SIGNAL(sig_start()), this, SLOT(slotStart())); connect(lis, SIGNAL(sig_end()) , this, SLOT(slotEnd()) ); /* reload now */ QTimer::singleShot( 0, this, SLOT(slotReloadDir())); } void PIconView::slotReloadDir() { slotChangeDir( m_path ); } /* * add files and folders */ void PIconView::addFolders( const QStringList& lst) { QStringList::ConstIterator it; for(it=lst.begin(); it != lst.end(); ++it ) (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); } void PIconView::addFiles( const QStringList& lst) { QStringList::ConstIterator it; for (it=lst.begin(); it!= lst.end(); ++it ) (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); } /* * user clicked on the item. Change dir or view */ void PIconView::slotClicked(QIconViewItem* _it) { if(!_it ) return; IconViewItem* it = static_cast<IconViewItem*>(_it); if( it->isDir() ) slotChangeDir( it->path() ); else // view image slotShowImage(); } /* * got thumb info add to the cache if items is visible * we later need update after processing of slave is done */ void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { IconViewItem* item = g_stringInf[_path]; if (!item ) return; if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), m_view->contentsWidth(), m_view->contentsHeight() ) ) ) m_updatet = true; item->setText( str ); g_stringInf.remove( _path ); } /* * got thumbnail and see if it is visible so we need to update later */ void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { IconViewItem* item = g_stringPix[_path]; if (!item ) return; if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), m_view->contentsWidth(), m_view->contentsHeight() ) ) ) m_updatet = true; if (pix.width()>0) PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); g_stringPix.remove( _path ); } /* * FIXME rename */ void PIconView::slotRename() { } /* * BEAM the current file */ void PIconView::slotBeam() { bool isDir; QString pa = currentFileName( isDir ); if ( isDir && pa.isEmpty() ) return; Ir* ir = new Ir( this ); connect( ir, SIGNAL(done(Ir*)), this, SLOT(slotBeamDone(Ir*))); ir->send(pa, tr( "Image" ) ); } /* * BEAM done clean up */ void PIconView::slotBeamDone( Ir* ir) { delete ir; } void PIconView::slotStart() { m_view->viewport()->setUpdatesEnabled( false ); } void PIconView::slotEnd() { if ( m_updatet ) m_view->arrangeItemsInGrid( ); m_view->viewport()->setUpdatesEnabled( true ); m_updatet = false; } void PIconView::slotShowImage() { bool isDir = false; QString name = currentFileName(isDir); if (isDir) return; slotShowImage( name ); } void PIconView::slotShowImage( const QString& name) { emit sig_display( name ); } void PIconView::slotImageInfo() { bool isDir = false; QString name = currentFileName(isDir); if (isDir) return; slotImageInfo( name ); } void PIconView::slotImageInfo( const QString& name) { emit sig_showInfo( name ); } void PIconView::slotChangeMode( int mode ) { - if ( mode >= 0 && mode <= 3 ) + if ( mode >= 1 && mode <= 3 ) m_mode = mode; QIconView::ItemTextPos pos; switch( m_mode ) { - case 1: + case 2: pos = QIconView::Bottom; break; - case 2: - case 0: + case 3: + case 1: default: pos = QIconView::Right; break; } m_view->setItemTextPos( pos ); + calculateGrid(); slotReloadDir(); } + + +void PIconView::resizeEvent( QResizeEvent* re ) { + QVBox::resizeEvent( re ); + calculateGrid(); +} + + +void PIconView::calculateGrid() { + +} 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 @@ -1,85 +1,89 @@ /* * GPLv2 zecke@handhelds.org * No WArranty... */ #ifndef PHUNK_ICON_VIEW_H #define PHUNK_ICON_VIEW_H #include <qvbox.h> class QIconView; class QIconViewItem; class QComboBox; class PIconViewItem; class PDirLister; class Ir; namespace Opie { namespace Core{ class OConfig; class OKeyConfigManager; } } class PIconView : public QVBox { Q_OBJECT friend class PIconViewItem; enum ActionIds { BeamItem, DeleteItem, ViewItem, InfoItem }; public: PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); ~PIconView(); void resetView(); Opie::Core::OKeyConfigManager* manager(); signals: void sig_showInfo( const QString& ); void sig_display( const QString& ); +protected: + void resizeEvent( QResizeEvent* ); + private: void initKeys(); QString currentFileName(bool &isDir)const; void loadViews(); + void calculateGrid(); private slots: void slotDirUp(); void slotChangeDir(const QString&); void slotTrash(); void slotViewChanged( int ); void slotReloadDir(); void slotRename(); void slotBeam(); void slotBeamDone( Ir* ); void slotShowImage(); void slotShowImage( const QString& ); void slotImageInfo(); void slotImageInfo( const QString& ); void slotStart(); void slotEnd(); /* for performance reasons make it inline in the future */ void addFolders( const QStringList& ); void addFiles( const QStringList& ); void slotClicked(QIconViewItem* ); /**/ void slotThumbInfo(const QString&, const QString&); void slotThumbNail(const QString&, const QPixmap&); void slotChangeMode( int ); private: Opie::Core::OKeyConfigManager *m_viewManager; Opie::Core::OConfig *m_cfg; QComboBox* m_views; QIconView* m_view; QString m_path; bool m_updatet : 1; int m_mode; }; #endif 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 @@ #include "viewmodebutton.h" +#include <opie2/odebug.h> + #include <qtoolbar.h> #include <qpopupmenu.h> ViewModeButton::ViewModeButton( QToolBar* bar ) : QToolButton( bar ) { - setIconSet( Resource::loadIconSet( "toys" ) ); + slotChange( 1 ); QPopupMenu *pop= new QPopupMenu( this ); pop->setCheckable( true ); - pop->insertItem( tr("Thumbnail and Imageinfo"), 0 ); - pop->insertItem( tr("Thumbnail and Name" ), 1 ); - pop->insertItem( tr("Name Only" ), 2 ); + pop->insertItem( tr("Thumbnail and Imageinfo"), 1 ); + pop->insertItem( tr("Thumbnail and Name" ), 2 ); + pop->insertItem( tr("Name Only" ), 3 ); connect(pop, SIGNAL(activated(int)), this, SIGNAL(changeMode(int)) ); + connect(pop, SIGNAL(activated(int)), + this, SLOT(slotChange(int)) ); setPopup( pop ); } ViewModeButton::~ViewModeButton() { +} + +void ViewModeButton::slotChange( int i ) { + QString name; + switch( i ) { + case 1: + name = "opie-eye/opie-eye-thumb"; + break; + case 2: + name = "opie-eye/opie-eye-thumbonly"; + break; + case 3: + name = "opie-eye/opie-eye-textview"; + break; + } + qWarning("foo %d" +name, i ); + setIconSet( Resource::loadIconSet( name ) ); } 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 @@ /* * GPLv2 only * zecke@handhelds.org */ #ifndef PHUNK_VIEW_MODE_BUTTON_H #define PHUNK_VIEW_MODE_BUTTON_H #include <qpe/resource.h> #include <qtoolbutton.h> class ViewModeButton : public QToolButton { Q_OBJECT public: ViewModeButton( QToolBar* ); ~ViewModeButton(); signals: void changeMode( int ); +private slots: + void slotChange( int i ); }; #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 @@ -1,210 +1,219 @@ #include "oimagezoomer.h" #include <qimage.h> #include <qpixmap.h> #include <qpainter.h> #include <qrect.h> #include <qpoint.h> #include <qsize.h> namespace Opie { namespace MM { /** * \brief The most simple c'tor * The main c'tor. You still need to set a QPixmap/QIMage, * setImageSize,setViewPortSize,setVisiblePoint * * @param parent The parent widget * @param name A name for this widget * @param fl The widget flags * */ OImageZoomer::OImageZoomer( QWidget* parent, const char* name, WFlags fl ) : QFrame( parent, name, fl ) { init(); } /** * \brief This c'tor takes a QPixmap additional * * You initially set the QPixmap but you still need to provide * the additional data to make this widget useful * * @param pix A Pixmap it'll be converted to a QImage later! * @param par The parent widget * @param name The name of this widget * @param fl The widget flags */ OImageZoomer::OImageZoomer( const QPixmap& pix, QWidget* par, const char* name, WFlags fl ) : QFrame( par, name, fl ) { init(); setImage( pix ); } /** * \brief This c'tor takes a QImage instead * You just provide a QImage which is saved. It behaves the same as the others. * * @param img A Image which will be used for the zoomer content * @param par The parent of the widget * @param name The name of the widget * @param fl The widgets flags */ OImageZoomer::OImageZoomer( const QImage& img, QWidget* par, const char* name, WFlags fl) : QFrame( par, name, fl ) { init(); setImage( img ); } /** * \brief overloaded c'tor * * This differs only in the arguments it takes * * * @param pSize The size of the Page you show * @param vSize The size of the viewport. The size of the visible part of the widget * @param par The parent of the widget * @param name The name * @param fl The window flags */ OImageZoomer::OImageZoomer( const QSize& pSize, const QSize& vSize, QWidget* par, const char* name, WFlags fl ) : QFrame( par, name, fl ), m_imgSize( pSize ),m_visSize( vSize ) { init(); } /** * d'tor */ OImageZoomer::~OImageZoomer() { } void OImageZoomer::init() { setFrameStyle( Panel | Sunken ); } /** * \brief set the page/image size * Tell us the QSize of the Data you show to the user. We need this * to do the calculations * * @param size The size of the stuff you want to zoom on */ void OImageZoomer::setImageSize( const QSize& size ) { m_imgSize = size; repaint(); } /** * \brief Set the size of the viewport * Tell us the QSize of the viewport. The viewport is the part * of the widget which is exposed on the screen * * @param size Te size of the viewport * * @see QScrollView::viewport() */ void OImageZoomer::setViewPortSize( const QSize& size ) { m_visSize = size; repaint(); } /** * \brief the point in the topleft corner which is currently visible * Set the visible point. This most of the times relate to QScrollView::contentsX() * and QScrollView::contentsY() * * @see setVisiblePoint(int,int) */ void OImageZoomer::setVisiblePoint( const QPoint& pt ) { m_visPt = pt; repaint(); } /** * Set the Image. The image will be resized on resizeEvent * and it'll set the QPixmap background * * @param img The image will be stored internally and used as the background */ void OImageZoomer::setImage( const QImage& img) { m_img = img; resizeEvent( 0 ); repaint(); } /** * overloaded function it calls the QImage version */ void OImageZoomer::setImage( const QPixmap& pix) { setImage( pix.convertToImage() ); } void OImageZoomer::resizeEvent( QResizeEvent* ev ) { QFrame::resizeEvent( ev ); setBackgroundOrigin( QWidget::WidgetOrigin ); // TODO Qt3 use PalettePixmap and use size QPixmap pix; pix.convertFromImage( m_img.smoothScale( size().width(), size().height() ) ); setBackgroundPixmap( pix); } void OImageZoomer::drawContents( QPainter* p ) { /* * if the page size */ if ( m_imgSize.isEmpty() ) return; /* * paint a red rect which represents the visible size * * We need to recalculate x,y and width and height of the * rect. So image size relates to contentRect * */ QRect c( contentsRect() ); p->setPen( Qt::red ); + /* + * the contentRect is set equal to the size of the image + * Rect/Original = NewRectORWidth/OriginalVisibleStuff and then simply we + * need to add the c.y/x due usage of QFrame + * For x and y we use the visiblePoint + * For height and width we use the size of the viewport + * if width/height would be bigger than our widget we use this width/height + * + */ int len = m_imgSize.width(); int x = (c.width()*m_visPt.x())/len + c.x(); int w = (c.width()*m_visSize.width() )/len + c.x(); if ( w > c.width() ) w = c.width(); len = m_imgSize.height(); int y = (c.height()*m_visPt.y() )/len + c.y(); int h = (c.height()*m_visSize.height() )/len + c.y(); if ( h > c.height() ) h = c.height(); p->drawRect( x, y, w, h ); } void OImageZoomer::mousePressEvent( QMouseEvent* ) { m_mouseX = m_mouseY = -1; } void OImageZoomer::mouseMoveEvent( QMouseEvent* ev ) { int mx, my; mx = ev->x(); my = ev->y(); if ( m_mouseX != -1 && m_mouseY != -1 ) { int diffx = ( mx - m_mouseX ) * m_imgSize.width() / width(); int diffy = ( my - m_mouseY ) * m_imgSize.height() / height(); emit zoomAreaRel( diffx, diffy ); emit zoomArea(m_visPt.x()+diffx, m_visPt.y()+diffy ); } m_mouseX = mx; m_mouseY = my; } } } |