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 | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.cpp b/noncore/graphics/opie-eye/gui/imagescrollview.cpp index 0d35354..7d83e29 100644 --- a/noncore/graphics/opie-eye/gui/imagescrollview.cpp +++ b/noncore/graphics/opie-eye/gui/imagescrollview.cpp | |||
@@ -1,43 +1,54 @@ | |||
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 ) | ||
11 | :QScrollView(parent,name,f|Qt::WRepaintNoErase ),_image_data(),_original_data(),scale_to_fit(true), | ||
12 | rotate_to_fit(true),first_resize_done(false) | ||
13 | { | ||
14 | init(); | ||
15 | } | ||
16 | |||
10 | ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) | 17 | ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) |
11 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale), | 18 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(img),scale_to_fit(always_scale), |
12 | rotate_to_fit(rfit),first_resize_done(false) | 19 | rotate_to_fit(rfit),first_resize_done(false) |
13 | { | 20 | { |
14 | init(); | 21 | init(); |
15 | } | 22 | } |
16 | 23 | ||
17 | ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) | 24 | ImageScrollView::ImageScrollView (const QString&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), | 25 | :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) | 26 | rotate_to_fit(rfit),first_resize_done(false) |
20 | { | 27 | { |
21 | init(); | 28 | init(); |
22 | } | 29 | } |
23 | 30 | ||
24 | void ImageScrollView::setImage(const QImage&img) | 31 | void ImageScrollView::setImage(const QImage&img) |
25 | { | 32 | { |
26 | _image_data = QImage(); | 33 | _image_data = QImage(); |
27 | _original_data=img; | 34 | _original_data=img; |
28 | first_resize_done = false; | 35 | first_resize_done = false; |
29 | init(); | 36 | init(); |
30 | } | 37 | } |
31 | 38 | ||
39 | void ImageScrollView::setImage( const QString& path ) { | ||
40 | |||
41 | } | ||
42 | |||
32 | /* should be called every time the QImage changed it content */ | 43 | /* should be called every time the QImage changed it content */ |
33 | void ImageScrollView::init() | 44 | void ImageScrollView::init() |
34 | { | 45 | { |
35 | viewport()->setBackgroundColor(white); | 46 | viewport()->setBackgroundColor(white); |
36 | if (_original_data.size().isValid()) { | 47 | if (_original_data.size().isValid()) { |
37 | resizeContents(_original_data.width(),_original_data.height()); | 48 | resizeContents(_original_data.width(),_original_data.height()); |
38 | } | 49 | } |
39 | last_rot = Rotate0; | 50 | last_rot = Rotate0; |
40 | } | 51 | } |
41 | 52 | ||
42 | ImageScrollView::~ImageScrollView() | 53 | ImageScrollView::~ImageScrollView() |
43 | { | 54 | { |
@@ -250,24 +261,33 @@ void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) | |||
250 | void ImageScrollView::contentsMouseReleaseEvent ( QMouseEvent * e) | 261 | void ImageScrollView::contentsMouseReleaseEvent ( QMouseEvent * e) |
251 | { | 262 | { |
252 | _mouseStartPosX = e->x(); | 263 | _mouseStartPosX = e->x(); |
253 | _mouseStartPosY = e->y(); | 264 | _mouseStartPosY = e->y(); |
254 | } | 265 | } |
255 | 266 | ||
256 | void ImageScrollView::contentsMousePressEvent ( QMouseEvent * e) | 267 | void ImageScrollView::contentsMousePressEvent ( QMouseEvent * e) |
257 | { | 268 | { |
258 | _mouseStartPosX = e->x(); | 269 | _mouseStartPosX = e->x(); |
259 | _mouseStartPosY = e->y(); | 270 | _mouseStartPosY = e->y(); |
260 | } | 271 | } |
261 | 272 | ||
273 | void ImageScrollView::setDestructiveClose() { | ||
274 | WFlags fl = getWFlags(); | ||
275 | /* clear it just in case */ | ||
276 | fl &= ~WDestructiveClose; | ||
277 | fl |= WDestructiveClose; | ||
278 | setWFlags( fl ); | ||
279 | } | ||
280 | |||
281 | |||
262 | /* for testing */ | 282 | /* for testing */ |
263 | ImageDlg::ImageDlg(const QString&fname,QWidget * parent, const char * name) | 283 | ImageDlg::ImageDlg(const QString&fname,QWidget * parent, const char * name) |
264 | :QDialog(parent,name,true,WStyle_ContextHelp) | 284 | :QDialog(parent,name,true,WStyle_ContextHelp) |
265 | { | 285 | { |
266 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | 286 | QVBoxLayout*dlglayout = new QVBoxLayout(this); |
267 | dlglayout->setSpacing(2); | 287 | dlglayout->setSpacing(2); |
268 | dlglayout->setMargin(1); | 288 | dlglayout->setMargin(1); |
269 | ImageScrollView*inf = new ImageScrollView(fname,this); | 289 | ImageScrollView*inf = new ImageScrollView(fname,this); |
270 | dlglayout->addWidget(inf); | 290 | dlglayout->addWidget(inf); |
271 | odebug << "Imagedlg constructor end" << oendl; | 291 | odebug << "Imagedlg constructor end" << oendl; |
272 | } | 292 | } |
273 | 293 | ||