author | alwin <alwin> | 2004-04-06 15:35:17 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-06 15:35:17 (UTC) |
commit | 9273c064f2ae699885ddef32155df4f5aab9d574 (patch) (side-by-side diff) | |
tree | 72bb117b9ca1888215a47edfb6ec3355309261bd | |
parent | 6821faed5fd1db0861dff48a5660a3336211b3be (diff) | |
download | opie-9273c064f2ae699885ddef32155df4f5aab9d574.zip opie-9273c064f2ae699885ddef32155df4f5aab9d574.tar.gz opie-9273c064f2ae699885ddef32155df4f5aab9d574.tar.bz2 |
saves the last loaded image name so will somewhat faster
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.cpp | 13 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.h | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.cpp b/noncore/graphics/opie-eye/gui/imagescrollview.cpp index ee20f40..99fdc51 100644 --- a/noncore/graphics/opie-eye/gui/imagescrollview.cpp +++ b/noncore/graphics/opie-eye/gui/imagescrollview.cpp @@ -1,89 +1,94 @@ #include "imagescrollview.h" #include <opie2/odebug.h> using namespace Opie::Core; #include <qimage.h> #include <qlayout.h> ImageScrollView::ImageScrollView( QWidget* parent, const char* name, WFlags f ) :QScrollView(parent,name,f|Qt::WRepaintNoErase ),_image_data(),_original_data(),scale_to_fit(true), - rotate_to_fit(true),first_resize_done(false) + rotate_to_fit(true),first_resize_done(false),m_lastName("") { init(); + qDebug("constructor done"); } ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale), - rotate_to_fit(rfit),first_resize_done(false) + rotate_to_fit(rfit),first_resize_done(false),m_lastName("") { init(); } ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) - :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale), - rotate_to_fit(rfit),first_resize_done(false) + :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(),scale_to_fit(always_scale), + rotate_to_fit(rfit),first_resize_done(false),m_lastName("") { init(); + setImage(img); } void ImageScrollView::setImage(const QImage&img) { _image_data = QImage(); _original_data=img; + m_lastName = ""; if (first_resize_done) { generateImage(); } } void ImageScrollView::setImage( const QString& path ) { odebug << "load new image " << oendl; + if (m_lastName == path) return; + m_lastName = path; _original_data.load(path); _image_data = QImage(); if (first_resize_done) { generateImage(); } } /* should be called every time the QImage changed it content */ void ImageScrollView::init() { odebug << "init " << oendl; viewport()->setBackgroundColor(white); if (first_resize_done) { last_rot = Rotate0; generateImage(); odebug << "reinit display " << oendl; } else if (_original_data.size().isValid()) { resizeContents(_original_data.width(),_original_data.height()); } } void ImageScrollView::setAutoRotate(bool how) { /* to avoid double repaints */ if (rotate_to_fit != how) { rotate_to_fit = how; _image_data = QImage(); generateImage(); } } void ImageScrollView::setAutoScale(bool how) { scale_to_fit = how; if (!how) { rotate_to_fit = false; } _image_data = QImage(); generateImage(); } ImageScrollView::~ImageScrollView() { } void ImageScrollView::rescaleImage(int w, int h) { if (_image_data.width()==w && _image_data.height()==h) { diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.h b/noncore/graphics/opie-eye/gui/imagescrollview.h index dcf54ce..44f2a64 100644 --- a/noncore/graphics/opie-eye/gui/imagescrollview.h +++ b/noncore/graphics/opie-eye/gui/imagescrollview.h @@ -2,71 +2,71 @@ #define _IMAGE_SCROLL_VIEW_H #include <qscrollview.h> #include <qimage.h> #include <qstring.h> #include <qdialog.h> class QPainter; class ImageScrollView:public QScrollView { Q_OBJECT public: ImageScrollView( QWidget* parent, const char* name = 0, WFlags fl = 0 ); ImageScrollView (const QImage&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); ImageScrollView (const QString&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); virtual ~ImageScrollView(); void setImage(const QImage&); void setImage( const QString& path ); void setDestructiveClose(); void setAutoRotate(bool); void setAutoScale(bool); enum Rotation { Rotate0, Rotate90, Rotate180, Rotate270 }; signals: void sig_return(); protected: virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph ); void init(); QImage _image_data; QImage _original_data; int _mouseStartPosX,_mouseStartPosY; bool scale_to_fit; bool rotate_to_fit; bool first_resize_done; Rotation last_rot; - + QString m_lastName; void rescaleImage(int w, int h); void rotate_into_data(Rotation r); void generateImage(); protected slots: virtual void viewportMouseMoveEvent(QMouseEvent* e); virtual void contentsMousePressEvent ( QMouseEvent * e); virtual void contentsMouseReleaseEvent ( QMouseEvent * e); virtual void resizeEvent(QResizeEvent * e); }; /* for testing */ class ImageDlg:public QDialog { Q_OBJECT public: ImageDlg(const QString&,QWidget * parent=0, const char * name=0); virtual ~ImageDlg(); }; #endif |