summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/imagescrollview.cpp30
-rw-r--r--noncore/graphics/opie-eye/gui/imagescrollview.h2
2 files changed, 21 insertions, 11 deletions
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.cpp b/noncore/graphics/opie-eye/gui/imagescrollview.cpp
index 98054ff..ad19219 100644
--- a/noncore/graphics/opie-eye/gui/imagescrollview.cpp
+++ b/noncore/graphics/opie-eye/gui/imagescrollview.cpp
@@ -1,142 +1,148 @@
1#include "imagescrollview.h" 1#include "imagescrollview.h"
2 2
3#include <opie2/odebug.h> 3#include <opie2/odebug.h>
4 4
5using namespace Opie::Core; 5using namespace Opie::Core;
6 6
7#include <qimage.h> 7#include <qimage.h>
8#include <qlayout.h> 8#include <qlayout.h>
9 9
10ImageScrollView::ImageScrollView( QWidget* parent, const char* name, WFlags f ) 10ImageScrollView::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),m_lastName("") 12 rotate_to_fit(true),first_resize_done(false),m_lastName("")
13{ 13{
14 init(); 14 init();
15} 15}
16 16
17ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) 17ImageScrollView::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), 18 :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),m_lastName("") 19 rotate_to_fit(rfit),first_resize_done(false),m_lastName("")
20{ 20{
21 _original_data.convertDepth(QPixmap::defaultDepth());
22 _original_data.setAlphaBuffer(false);
21 init(); 23 init();
22} 24}
23 25
24ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f,bool always_scale,bool rfit) 26ImageScrollView::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(),scale_to_fit(always_scale), 27 :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(),_original_data(),scale_to_fit(always_scale),
26 rotate_to_fit(rfit),first_resize_done(false),m_lastName("") 28 rotate_to_fit(rfit),first_resize_done(false),m_lastName("")
27{ 29{
28 init(); 30 init();
29 setImage(img); 31 setImage(img);
30} 32}
31 33
32void ImageScrollView::setImage(const QImage&img) 34void ImageScrollView::setImage(const QImage&img)
33{ 35{
34 _image_data = QImage(); 36 _image_data = QImage();
35 _original_data=img; 37 _original_data=img;
38 _original_data.convertDepth(QPixmap::defaultDepth());
39 _original_data.setAlphaBuffer(false);
36 m_lastName = ""; 40 m_lastName = "";
37 if (first_resize_done) { 41 if (first_resize_done) {
38 generateImage(); 42 generateImage();
39 } 43 }
40} 44}
41 45
42void ImageScrollView::setImage( const QString& path ) { 46void ImageScrollView::setImage( const QString& path ) {
43 odebug << "load new image " << oendl; 47 odebug << "load new image " << oendl;
44 if (m_lastName == path) return; 48 if (m_lastName == path) return;
45 m_lastName = path; 49 m_lastName = path;
46 _original_data.load(path); 50 _original_data.load(path);
51 _original_data.convertDepth(QPixmap::defaultDepth());
52 _original_data.setAlphaBuffer(false);
47 _image_data = QImage(); 53 _image_data = QImage();
48 if (first_resize_done) { 54 if (first_resize_done) {
49 generateImage(); 55 generateImage();
50 } 56 }
51} 57}
52 58
53/* should be called every time the QImage changed it content */ 59/* should be called every time the QImage changed it content */
54void ImageScrollView::init() 60void ImageScrollView::init()
55{ 61{
56 odebug << "init " << oendl; 62 odebug << "init " << oendl;
57 viewport()->setBackgroundColor(white); 63 viewport()->setBackgroundColor(white);
58 setFocusPolicy(QWidget::StrongFocus); 64 setFocusPolicy(QWidget::StrongFocus);
59 if (first_resize_done) { 65 if (first_resize_done) {
60 last_rot = Rotate0; 66 last_rot = Rotate0;
61 generateImage(); 67 generateImage();
62 odebug << "reinit display " << oendl; 68 odebug << "reinit display " << oendl;
63 } else if (_original_data.size().isValid()) { 69 } else if (_original_data.size().isValid()) {
64 resizeContents(_original_data.width(),_original_data.height()); 70 resizeContents(_original_data.width(),_original_data.height());
65 } 71 }
66} 72}
67 73
68void ImageScrollView::setAutoRotate(bool how) 74void ImageScrollView::setAutoRotate(bool how)
69{ 75{
70 /* to avoid double repaints */ 76 /* to avoid double repaints */
71 if (rotate_to_fit != how) { 77 if (rotate_to_fit != how) {
72 rotate_to_fit = how; 78 rotate_to_fit = how;
73 _image_data = QImage(); 79 _image_data = QImage();
74 generateImage(); 80 generateImage();
75 } 81 }
76} 82}
77 83
78void ImageScrollView::setAutoScale(bool how) 84void ImageScrollView::setAutoScale(bool how)
79{ 85{
80 scale_to_fit = how; 86 scale_to_fit = how;
81 if (!how) { 87 if (!how) {
82 rotate_to_fit = false; 88 rotate_to_fit = false;
83 } 89 }
84 _image_data = QImage(); 90 _image_data = QImage();
85 generateImage(); 91 generateImage();
86} 92}
87 93
88ImageScrollView::~ImageScrollView() 94ImageScrollView::~ImageScrollView()
89{ 95{
90} 96}
91 97
92void ImageScrollView::rescaleImage(int w, int h) 98void ImageScrollView::rescaleImage(int w, int h)
93{ 99{
94 if (_image_data.width()==w && _image_data.height()==h) { 100 if (_image_data.width()==w && _image_data.height()==h) {
95 return; 101 return;
96 } 102 }
97 double hs = (double)h / (double)_image_data.height() ; 103 double hs = (double)h / (double)_image_data.height() ;
98 double ws = (double)w / (double)_image_data.width() ; 104 double ws = (double)w / (double)_image_data.width() ;
99 double scaleFactor = (hs > ws) ? ws : hs; 105 double scaleFactor = (hs > ws) ? ws : hs;
100 int smoothW = (int)(scaleFactor * _image_data.width()); 106 int smoothW = (int)(scaleFactor * _image_data.width());
101 int smoothH = (int)(scaleFactor * _image_data.height()); 107 int smoothH = (int)(scaleFactor * _image_data.height());
102 _image_data = _image_data.smoothScale(smoothW,smoothH); 108 _image_data = _image_data.smoothScale(smoothW,smoothH);
103} 109}
104 110
105void ImageScrollView::rotate_into_data(Rotation r) 111void ImageScrollView::rotate_into_data(Rotation r)
106{ 112{
107 /* realy - we must do this that way, 'cause when acting direct on _image_data the app will 113 /* realy - we must do this that way, 'cause when acting direct on _image_data the app will
108 segfault :( */ 114 segfault :( */
109 QImage dest; 115 QImage dest;
110 int x, y; 116 int x, y;
111 if ( _original_data.depth() > 8 ) 117 if ( _original_data.depth() > 8 )
112 { 118 {
113 unsigned int *srcData, *destData; 119 unsigned int *srcData, *destData;
114 switch ( r ) 120 switch ( r )
115 { 121 {
116 case Rotate90: 122 case Rotate90:
117 dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); 123 dest.create(_original_data.height(), _original_data.width(), _original_data.depth());
118 for ( y=0; y < _original_data.height(); ++y ) 124 for ( y=0; y < _original_data.height(); ++y )
119 { 125 {
120 srcData = (unsigned int *)_original_data.scanLine(y); 126 srcData = (unsigned int *)_original_data.scanLine(y);
121 for ( x=0; x < _original_data.width(); ++x ) 127 for ( x=0; x < _original_data.width(); ++x )
122 { 128 {
123 destData = (unsigned int *)dest.scanLine(x); 129 destData = (unsigned int *)dest.scanLine(x);
124 destData[_original_data.height()-y-1] = srcData[x]; 130 destData[_original_data.height()-y-1] = srcData[x];
125 } 131 }
126 } 132 }
127 break; 133 break;
128 case Rotate180: 134 case Rotate180:
129 dest.create(_original_data.width(), _original_data.height(), _original_data.depth()); 135 dest.create(_original_data.width(), _original_data.height(), _original_data.depth());
130 for ( y=0; y < _original_data.height(); ++y ) 136 for ( y=0; y < _original_data.height(); ++y )
131 { 137 {
132 srcData = (unsigned int *)_original_data.scanLine(y); 138 srcData = (unsigned int *)_original_data.scanLine(y);
133 destData = (unsigned int *)dest.scanLine(_original_data.height()-y-1); 139 destData = (unsigned int *)dest.scanLine(_original_data.height()-y-1);
134 for ( x=0; x < _original_data.width(); ++x ) 140 for ( x=0; x < _original_data.width(); ++x )
135 destData[_original_data.width()-x-1] = srcData[x]; 141 destData[_original_data.width()-x-1] = srcData[x];
136 } 142 }
137 break; 143 break;
138 case Rotate270: 144 case Rotate270:
139 dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); 145 dest.create(_original_data.height(), _original_data.width(), _original_data.depth());
140 for ( y=0; y < _original_data.height(); ++y ) 146 for ( y=0; y < _original_data.height(); ++y )
141 { 147 {
142 srcData = (unsigned int *)_original_data.scanLine(y); 148 srcData = (unsigned int *)_original_data.scanLine(y);
@@ -151,208 +157,210 @@ void ImageScrollView::rotate_into_data(Rotation r)
151 dest = _original_data; 157 dest = _original_data;
152 break; 158 break;
153 } 159 }
154 } 160 }
155 else 161 else
156 { 162 {
157 unsigned char *srcData, *destData; 163 unsigned char *srcData, *destData;
158 unsigned int *srcTable, *destTable; 164 unsigned int *srcTable, *destTable;
159 switch ( r ) 165 switch ( r )
160 { 166 {
161 case Rotate90: 167 case Rotate90:
162 dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); 168 dest.create(_original_data.height(), _original_data.width(), _original_data.depth());
163 dest.setNumColors(_original_data.numColors()); 169 dest.setNumColors(_original_data.numColors());
164 srcTable = (unsigned int *)_original_data.colorTable(); 170 srcTable = (unsigned int *)_original_data.colorTable();
165 destTable = (unsigned int *)dest.colorTable(); 171 destTable = (unsigned int *)dest.colorTable();
166 for ( x=0; x < _original_data.numColors(); ++x ) 172 for ( x=0; x < _original_data.numColors(); ++x )
167 destTable[x] = srcTable[x]; 173 destTable[x] = srcTable[x];
168 for ( y=0; y < _original_data.height(); ++y ) 174 for ( y=0; y < _original_data.height(); ++y )
169 { 175 {
170 srcData = (unsigned char *)_original_data.scanLine(y); 176 srcData = (unsigned char *)_original_data.scanLine(y);
171 for ( x=0; x < _original_data.width(); ++x ) 177 for ( x=0; x < _original_data.width(); ++x )
172 { 178 {
173 destData = (unsigned char *)dest.scanLine(x); 179 destData = (unsigned char *)dest.scanLine(x);
174 destData[_original_data.height()-y-1] = srcData[x]; 180 destData[_original_data.height()-y-1] = srcData[x];
175 } 181 }
176 } 182 }
177 break; 183 break;
178 case Rotate180: 184 case Rotate180:
179 dest.create(_original_data.width(), _original_data.height(), _original_data.depth()); 185 dest.create(_original_data.width(), _original_data.height(), _original_data.depth());
180 dest.setNumColors(_original_data.numColors()); 186 dest.setNumColors(_original_data.numColors());
181 srcTable = (unsigned int *)_original_data.colorTable(); 187 srcTable = (unsigned int *)_original_data.colorTable();
182 destTable = (unsigned int *)dest.colorTable(); 188 destTable = (unsigned int *)dest.colorTable();
183 for ( x=0; x < _original_data.numColors(); ++x ) 189 for ( x=0; x < _original_data.numColors(); ++x )
184 destTable[x] = srcTable[x]; 190 destTable[x] = srcTable[x];
185 for ( y=0; y < _original_data.height(); ++y ) 191 for ( y=0; y < _original_data.height(); ++y )
186 { 192 {
187 srcData = (unsigned char *)_original_data.scanLine(y); 193 srcData = (unsigned char *)_original_data.scanLine(y);
188 destData = (unsigned char *)dest.scanLine(_original_data.height()-y-1); 194 destData = (unsigned char *)dest.scanLine(_original_data.height()-y-1);
189 for ( x=0; x < _original_data.width(); ++x ) 195 for ( x=0; x < _original_data.width(); ++x )
190 destData[_original_data.width()-x-1] = srcData[x]; 196 destData[_original_data.width()-x-1] = srcData[x];
191 } 197 }
192 break; 198 break;
193 case Rotate270: 199 case Rotate270:
194 dest.create(_original_data.height(), _original_data.width(), _original_data.depth()); 200 dest.create(_original_data.height(), _original_data.width(), _original_data.depth());
195 dest.setNumColors(_original_data.numColors()); 201 dest.setNumColors(_original_data.numColors());
196 srcTable = (unsigned int *)_original_data.colorTable(); 202 srcTable = (unsigned int *)_original_data.colorTable();
197 destTable = (unsigned int *)dest.colorTable(); 203 destTable = (unsigned int *)dest.colorTable();
198 for ( x=0; x < _original_data.numColors(); ++x ) 204 for ( x=0; x < _original_data.numColors(); ++x )
199 destTable[x] = srcTable[x]; 205 destTable[x] = srcTable[x];
200 for ( y=0; y < _original_data.height(); ++y ) 206 for ( y=0; y < _original_data.height(); ++y )
201 { 207 {
202 srcData = (unsigned char *)_original_data.scanLine(y); 208 srcData = (unsigned char *)_original_data.scanLine(y);
203 for ( x=0; x < _original_data.width(); ++x ) 209 for ( x=0; x < _original_data.width(); ++x )
204 { 210 {
205 destData = (unsigned char *)dest.scanLine(_original_data.width()-x-1); 211 destData = (unsigned char *)dest.scanLine(_original_data.width()-x-1);
206 destData[y] = srcData[x]; 212 destData[y] = srcData[x];
207 } 213 }
208 } 214 }
209 break; 215 break;
210 default: 216 default:
211 dest = _original_data; 217 dest = _original_data;
212 break; 218 break;
213 } 219 }
214 220
215 } 221 }
216 _image_data = dest; 222 _image_data = dest;
217} 223}
218 224
219void ImageScrollView::generateImage() 225void ImageScrollView::generateImage()
220{ 226{
221 Rotation r = Rotate0; 227 Rotation r = Rotate0;
222 if (width()>height()&&_original_data.width()<_original_data.height() || 228 if (width()>height()&&_original_data.width()<_original_data.height() ||
223 width()<height()&&_original_data.width()>_original_data.height()) { 229 width()<height()&&_original_data.width()>_original_data.height()) {
224 if (rotate_to_fit) r = Rotate90; 230 if (rotate_to_fit) r = Rotate90;
225 } 231 }
226 odebug << " r = " << r << oendl; 232 odebug << " r = " << r << oendl;
227 if (scale_to_fit) { 233 if (scale_to_fit) {
228 if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) { 234 if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) {
229 odebug << "Rescaling data" << oendl; 235 odebug << "Rescaling data" << oendl;
230 if (r==Rotate0) { 236 if (r==Rotate0) {
231 _image_data = _original_data; 237 _image_data = _original_data;
232 } else { 238 } else {
233 rotate_into_data(r); 239 rotate_into_data(r);
234 } 240 }
235 } 241 }
236 rescaleImage(width(),height()); 242 rescaleImage(width(),height());
237 resizeContents(_image_data.width(),_image_data.height()); 243 resizeContents(_image_data.width(),_image_data.height());
238 } else if (!first_resize_done||r!=last_rot||_image_data.width()==0) { 244 } else if (!first_resize_done||r!=last_rot||_image_data.width()==0) {
239 if (r==Rotate0) { 245 if (r==Rotate0) {
240 _image_data = _original_data; 246 _image_data = _original_data;
241 } else { 247 } else {
242 rotate_into_data(r); 248 rotate_into_data(r);
243 } 249 }
244 last_rot = r; 250 last_rot = r;
245 resizeContents(_image_data.width(),_image_data.height()); 251 resizeContents(_image_data.width(),_image_data.height());
246 } 252 }
253 _pdata.convertFromImage(_image_data);
254 _image_data=QImage();
247} 255}
248 256
249void ImageScrollView::resizeEvent(QResizeEvent * e) 257void ImageScrollView::resizeEvent(QResizeEvent * e)
250{ 258{
251 odebug << "ImageScrollView resizeEvent" << oendl; 259 odebug << "ImageScrollView resizeEvent" << oendl;
252 QScrollView::resizeEvent(e); 260 QScrollView::resizeEvent(e);
253 generateImage(); 261 generateImage();
254 first_resize_done = true; 262 first_resize_done = true;
255} 263}
256 264
257void ImageScrollView::keyPressEvent(QKeyEvent * e) 265void ImageScrollView::keyPressEvent(QKeyEvent * e)
258{ 266{
259 if (!e) return; 267 if (!e) return;
260 int dx = horizontalScrollBar()->lineStep(); 268 int dx = horizontalScrollBar()->lineStep();
261 int dy = verticalScrollBar()->lineStep(); 269 int dy = verticalScrollBar()->lineStep();
262 if (e->key()==Qt::Key_Right) { 270 if (e->key()==Qt::Key_Right) {
263 scrollBy(dx,0); 271 scrollBy(dx,0);
264 e->accept(); 272 e->accept();
265 } else if (e->key()==Qt::Key_Left) { 273 } else if (e->key()==Qt::Key_Left) {
266 scrollBy(0-dx,0); 274 scrollBy(0-dx,0);
267 e->accept(); 275 e->accept();
268 } else if (e->key()==Qt::Key_Up) { 276 } else if (e->key()==Qt::Key_Up) {
269 scrollBy(0,0-dy); 277 scrollBy(0,0-dy);
270 e->accept(); 278 e->accept();
271 } else if (e->key()==Qt::Key_Down) { 279 } else if (e->key()==Qt::Key_Down) {
272 scrollBy(0,dy); 280 scrollBy(0,dy);
273 e->accept(); 281 e->accept();
274 } else { 282 } else {
275 e->ignore(); 283 e->ignore();
276 } 284 }
277 QScrollView::keyPressEvent(e); 285 QScrollView::keyPressEvent(e);
278} 286}
279 287
280void ImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw, int cliph) 288void ImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw, int cliph)
281{ 289{
282 int w = clipw; 290 int w = clipw;
283 int h = cliph; 291 int h = cliph;
284 int x = clipx; 292 int x = clipx;
285 int y = clipy; 293 int y = clipy;
286 bool erase = false; 294 bool erase = false;
287 295
288 if (!_image_data.size().isValid()) { 296 if (!_pdata.size().isValid()) {
289 p->fillRect(clipx,clipy,clipw,cliph,white); 297 p->fillRect(clipx,clipy,clipw,cliph,white);
290 return; 298 return;
291 } 299 }
292 if (w>_image_data.width()) { 300 if (w>_pdata.width()) {
293 w=_image_data.width(); 301 w=_pdata.width();
294 x = 0; 302 x = 0;
295 erase = true; 303 erase = true;
296 } else if (x+w>_image_data.width()){ 304 } else if (x+w>_pdata.width()){
297 x = _image_data.width()-w; 305 x = _pdata.width()-w;
298 } 306 }
299 if (h>_image_data.height()) { 307 if (h>_pdata.height()) {
300 h=_image_data.height(); 308 h=_pdata.height();
301 y = 0; 309 y = 0;
302 erase = true; 310 erase = true;
303 } else if (y+h>_image_data.height()){ 311 } else if (y+h>_pdata.height()){
304 y = _image_data.height()-h; 312 y = _pdata.height()-h;
305 } 313 }
306 if (erase||_image_data.hasAlphaBuffer()) { 314 if (erase||_original_data.hasAlphaBuffer()) {
307 p->fillRect(clipx,clipy,clipw,cliph,white); 315 p->fillRect(clipx,clipy,clipw,cliph,white);
308 } 316 }
309 p->drawImage(clipx,clipy,_image_data,x,y,w,h); 317 p->drawPixmap(clipx,clipy,_pdata,x,y,w,h);
310} 318}
311 319
312/* using the real geometry points and not the translated points is wanted! */ 320/* using the real geometry points and not the translated points is wanted! */
313void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) 321void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e)
314{ 322{
315 int mx, my; 323 int mx, my;
316 mx = e->x(); 324 mx = e->x();
317 my = e->y(); 325 my = e->y();
318 if (_mouseStartPosX!=-1 && _mouseStartPosY!=-1) { 326 if (_mouseStartPosX!=-1 && _mouseStartPosY!=-1) {
319 int diffx = _mouseStartPosX-mx; 327 int diffx = _mouseStartPosX-mx;
320 int diffy = _mouseStartPosY-my; 328 int diffy = _mouseStartPosY-my;
321#if 0 329#if 0
322 QScrollBar*xbar = horizontalScrollBar(); 330 QScrollBar*xbar = horizontalScrollBar();
323 QScrollBar*ybar = verticalScrollBar(); 331 QScrollBar*ybar = verticalScrollBar();
324 if (xbar->value()+diffx>xbar->maxValue()) { 332 if (xbar->value()+diffx>xbar->maxValue()) {
325 diffx = xbar->maxValue()-xbar->value(); 333 diffx = xbar->maxValue()-xbar->value();
326 } else if (xbar->value()+diffx<0) { 334 } else if (xbar->value()+diffx<0) {
327 diffx=0-xbar->value(); 335 diffx=0-xbar->value();
328 } 336 }
329 if (ybar->value()+diffy>ybar->maxValue()) { 337 if (ybar->value()+diffy>ybar->maxValue()) {
330 diffy = ybar->maxValue()-ybar->value(); 338 diffy = ybar->maxValue()-ybar->value();
331 } else if (ybar->value()+diffy<0) { 339 } else if (ybar->value()+diffy<0) {
332 diffy=0-ybar->value(); 340 diffy=0-ybar->value();
333 } 341 }
334#endif 342#endif
335 scrollBy(diffx,diffy); 343 scrollBy(diffx,diffy);
336 } 344 }
337 _mouseStartPosX=mx; 345 _mouseStartPosX=mx;
338 _mouseStartPosY=my; 346 _mouseStartPosY=my;
339} 347}
340 348
341void ImageScrollView::contentsMousePressEvent ( QMouseEvent * ) 349void ImageScrollView::contentsMousePressEvent ( QMouseEvent * )
342{ 350{
343 /* this marks the beginning of a possible mouse move. Due internal reasons of QT 351 /* this marks the beginning of a possible mouse move. Due internal reasons of QT
344 the geometry values here may real differ from that set in MoveEvent (I don't know 352 the geometry values here may real differ from that set in MoveEvent (I don't know
345 why). For getting them in real context, we use the first move-event to set the start 353 why). For getting them in real context, we use the first move-event to set the start
346 position ;) 354 position ;)
347 */ 355 */
348 _mouseStartPosX = -1; 356 _mouseStartPosX = -1;
349 _mouseStartPosY = -1; 357 _mouseStartPosY = -1;
350} 358}
351 359
352void ImageScrollView::setDestructiveClose() { 360void ImageScrollView::setDestructiveClose() {
353 WFlags fl = getWFlags(); 361 WFlags fl = getWFlags();
354 /* clear it just in case */ 362 /* clear it just in case */
355 fl &= ~WDestructiveClose; 363 fl &= ~WDestructiveClose;
356 fl |= WDestructiveClose; 364 fl |= WDestructiveClose;
357 setWFlags( fl ); 365 setWFlags( fl );
358} 366}
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.h b/noncore/graphics/opie-eye/gui/imagescrollview.h
index 17e2f5f..eb91dbd 100644
--- a/noncore/graphics/opie-eye/gui/imagescrollview.h
+++ b/noncore/graphics/opie-eye/gui/imagescrollview.h
@@ -1,62 +1,64 @@
1#ifndef _IMAGE_SCROLL_VIEW_H 1#ifndef _IMAGE_SCROLL_VIEW_H
2#define _IMAGE_SCROLL_VIEW_H 2#define _IMAGE_SCROLL_VIEW_H
3 3
4#include <qscrollview.h> 4#include <qscrollview.h>
5#include <qimage.h> 5#include <qimage.h>
6#include <qpixmap.h>
6#include <qstring.h> 7#include <qstring.h>
7#include <qdialog.h> 8#include <qdialog.h>
8 9
9class QPainter; 10class QPainter;
10 11
11class ImageScrollView:public QScrollView 12class ImageScrollView:public QScrollView
12{ 13{
13 Q_OBJECT 14 Q_OBJECT
14public: 15public:
15 ImageScrollView( QWidget* parent, const char* name = 0, WFlags fl = 0 ); 16 ImageScrollView( QWidget* parent, const char* name = 0, WFlags fl = 0 );
16 ImageScrollView (const QImage&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); 17 ImageScrollView (const QImage&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false );
17 ImageScrollView (const QString&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false ); 18 ImageScrollView (const QString&, QWidget * parent=0, const char * name=0, WFlags f=0,bool always_scale=false,bool rfit=false );
18 virtual ~ImageScrollView(); 19 virtual ~ImageScrollView();
19 20
20 virtual void setImage(const QImage&); 21 virtual void setImage(const QImage&);
21 virtual void setImage( const QString& path ); 22 virtual void setImage( const QString& path );
22 virtual void setDestructiveClose(); 23 virtual void setDestructiveClose();
23 24
24 virtual void setAutoRotate(bool); 25 virtual void setAutoRotate(bool);
25 virtual void setAutoScale(bool); 26 virtual void setAutoScale(bool);
26 27
27 enum Rotation { 28 enum Rotation {
28 Rotate0, 29 Rotate0,
29 Rotate90, 30 Rotate90,
30 Rotate180, 31 Rotate180,
31 Rotate270 32 Rotate270
32 }; 33 };
33 34
34signals: 35signals:
35 void sig_return(); 36 void sig_return();
36 37
37protected: 38protected:
38 virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph ); 39 virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph );
39 void init(); 40 void init();
40 41
41 QImage _image_data; 42 QImage _image_data;
42 QImage _original_data; 43 QImage _original_data;
44 QPixmap _pdata;
43 45
44 int _mouseStartPosX,_mouseStartPosY; 46 int _mouseStartPosX,_mouseStartPosY;
45 47
46 bool scale_to_fit; 48 bool scale_to_fit;
47 bool rotate_to_fit; 49 bool rotate_to_fit;
48 bool first_resize_done; 50 bool first_resize_done;
49 Rotation last_rot; 51 Rotation last_rot;
50 QString m_lastName; 52 QString m_lastName;
51 virtual void rescaleImage(int w, int h); 53 virtual void rescaleImage(int w, int h);
52 54
53 virtual void rotate_into_data(Rotation r); 55 virtual void rotate_into_data(Rotation r);
54 virtual void generateImage(); 56 virtual void generateImage();
55 57
56protected slots: 58protected slots:
57 virtual void viewportMouseMoveEvent(QMouseEvent* e); 59 virtual void viewportMouseMoveEvent(QMouseEvent* e);
58 virtual void contentsMousePressEvent ( QMouseEvent * e); 60 virtual void contentsMousePressEvent ( QMouseEvent * e);
59 virtual void resizeEvent(QResizeEvent * e); 61 virtual void resizeEvent(QResizeEvent * e);
60 virtual void keyPressEvent(QKeyEvent * e); 62 virtual void keyPressEvent(QKeyEvent * e);
61}; 63};
62#endif 64#endif