Diffstat (limited to 'noncore/graphics/opie-eye/gui/imagescrollview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.cpp | 13 |
1 files changed, 9 insertions, 4 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,53 +1,58 @@ | |||
1 | #include "imagescrollview.h" | 1 | #include "imagescrollview.h" |
2 | 2 | ||
3 | #include <opie2/odebug.h> | 3 | #include <opie2/odebug.h> |
4 | 4 | ||
5 | using namespace Opie::Core; | 5 | using namespace Opie::Core; |
6 | 6 | ||
7 | #include <qimage.h> | 7 | #include <qimage.h> |
8 | #include <qlayout.h> | 8 | #include <qlayout.h> |
9 | 9 | ||
10 | ImageScrollView::ImageScrollView( QWidget* parent, const char* name, WFlags f ) | 10 | ImageScrollView::ImageScrollView( QWidget* parent, const char* name, WFlags f ) |
11 | :QScrollView(parent,name,f|Qt::WRepaintNoErase ),_image_data(),_original_data(),scale_to_fit(true), | 11 | :QScrollView(parent,name,f|Qt::WRepaintNoErase ),_image_data(),_original_data(),scale_to_fit(true), |
12 | rotate_to_fit(true),first_resize_done(false) | 12 | rotate_to_fit(true),first_resize_done(false),m_lastName("") |
13 | { | 13 | { |
14 | init(); | 14 | init(); |
15 | qDebug("constructor done"); | ||
15 | } | 16 | } |
16 | 17 | ||
17 | ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) | 18 | ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) |
18 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale), | 19 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale), |
19 | rotate_to_fit(rfit),first_resize_done(false) | 20 | rotate_to_fit(rfit),first_resize_done(false),m_lastName("") |
20 | { | 21 | { |
21 | init(); | 22 | init(); |
22 | } | 23 | } |
23 | 24 | ||
24 | ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) | 25 | ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) |
25 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale), | 26 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(),scale_to_fit(always_scale), |
26 | rotate_to_fit(rfit),first_resize_done(false) | 27 | rotate_to_fit(rfit),first_resize_done(false),m_lastName("") |
27 | { | 28 | { |
28 | init(); | 29 | init(); |
30 | setImage(img); | ||
29 | } | 31 | } |
30 | 32 | ||
31 | void ImageScrollView::setImage(const QImage&img) | 33 | void ImageScrollView::setImage(const QImage&img) |
32 | { | 34 | { |
33 | _image_data = QImage(); | 35 | _image_data = QImage(); |
34 | _original_data=img; | 36 | _original_data=img; |
37 | m_lastName = ""; | ||
35 | if (first_resize_done) { | 38 | if (first_resize_done) { |
36 | generateImage(); | 39 | generateImage(); |
37 | } | 40 | } |
38 | } | 41 | } |
39 | 42 | ||
40 | void ImageScrollView::setImage( const QString& path ) { | 43 | void ImageScrollView::setImage( const QString& path ) { |
41 | odebug << "load new image " << oendl; | 44 | odebug << "load new image " << oendl; |
45 | if (m_lastName == path) return; | ||
46 | m_lastName = path; | ||
42 | _original_data.load(path); | 47 | _original_data.load(path); |
43 | _image_data = QImage(); | 48 | _image_data = QImage(); |
44 | if (first_resize_done) { | 49 | if (first_resize_done) { |
45 | generateImage(); | 50 | generateImage(); |
46 | } | 51 | } |
47 | } | 52 | } |
48 | 53 | ||
49 | /* should be called every time the QImage changed it content */ | 54 | /* should be called every time the QImage changed it content */ |
50 | void ImageScrollView::init() | 55 | void ImageScrollView::init() |
51 | { | 56 | { |
52 | odebug << "init " << oendl; | 57 | odebug << "init " << oendl; |
53 | viewport()->setBackgroundColor(white); | 58 | viewport()->setBackgroundColor(white); |