author | alwin <alwin> | 2004-04-04 23:02:29 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-04 23:02:29 (UTC) |
commit | 318c10ce368a6bf99f3412a2ff1ef0a9177c965a (patch) (unidiff) | |
tree | a38485b18eb9a2cd4a8bb5bccde0f91df3c0521e | |
parent | 9242abc186f0acc3df7020aaa219c435c2e00672 (diff) | |
download | opie-318c10ce368a6bf99f3412a2ff1ef0a9177c965a.zip opie-318c10ce368a6bf99f3412a2ff1ef0a9177c965a.tar.gz opie-318c10ce368a6bf99f3412a2ff1ef0a9177c965a.tar.bz2 |
ok, the first - realy first - working shot of a special
ImageScrollView. But the most important things are working now and
can be used.
Todo:
- check on a pda(!) doublebuffering (bitBlt) - may be it will paint faster
- implemented mouseEvents seems not working good, its just a first try.
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 8 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.cpp | 97 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imagescrollview.h | 43 |
3 files changed, 147 insertions, 1 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index ac4b899..de2cdf0 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -1,57 +1,58 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | * No WArranty... | 3 | * No WArranty... |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "iconview.h" | 6 | #include "iconview.h" |
7 | 7 | ||
8 | #include <lib/imagecache.h> | 8 | #include <lib/imagecache.h> |
9 | #include <gui/imageinfoui.h> | 9 | #include <gui/imageinfoui.h> |
10 | #include <gui/imagescrollview.h> | ||
10 | 11 | ||
11 | #include <iface/dirview.h> | 12 | #include <iface/dirview.h> |
12 | #include <iface/dirlister.h> | 13 | #include <iface/dirlister.h> |
13 | 14 | ||
14 | #include <opie2/oconfig.h> | 15 | #include <opie2/oconfig.h> |
15 | #include <opie2/okeyconfigwidget.h> | 16 | #include <opie2/okeyconfigwidget.h> |
16 | #include <opie2/odebug.h> | 17 | #include <opie2/odebug.h> |
17 | 18 | ||
18 | #include <qpe/resource.h> | 19 | #include <qpe/resource.h> |
19 | #include <qpe/qpemessagebox.h> | 20 | #include <qpe/qpemessagebox.h> |
20 | #include <qpe/ir.h> | 21 | #include <qpe/ir.h> |
21 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
22 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
23 | 24 | ||
24 | #include <qiconview.h> | 25 | #include <qiconview.h> |
25 | #include <qlabel.h> | 26 | #include <qlabel.h> |
26 | #include <qhbox.h> | 27 | #include <qhbox.h> |
27 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
28 | #include <qdir.h> | 29 | #include <qdir.h> |
29 | #include <qapplication.h> | 30 | #include <qapplication.h> |
30 | #include <qmainwindow.h> | 31 | #include <qmainwindow.h> |
31 | #include <qtimer.h> | 32 | #include <qtimer.h> |
32 | #include <qstyle.h> | 33 | #include <qstyle.h> |
33 | 34 | ||
34 | 35 | ||
35 | using Opie::Ui::OKeyConfigItem; | 36 | using Opie::Ui::OKeyConfigItem; |
36 | 37 | ||
37 | namespace { | 38 | namespace { |
38 | QPixmap* _dirPix = 0; | 39 | QPixmap* _dirPix = 0; |
39 | QPixmap* _unkPix = 0; | 40 | QPixmap* _unkPix = 0; |
40 | class IconViewItem : public QIconViewItem { | 41 | class IconViewItem : public QIconViewItem { |
41 | public: | 42 | public: |
42 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); | 43 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); |
43 | QPixmap* pixmap()const; | 44 | QPixmap* pixmap()const; |
44 | QString path()const { return m_path; } | 45 | QString path()const { return m_path; } |
45 | bool isDir()const { return m_isDir; } | 46 | bool isDir()const { return m_isDir; } |
46 | void setText( const QString& ); | 47 | void setText( const QString& ); |
47 | 48 | ||
48 | 49 | ||
49 | private: | 50 | private: |
50 | mutable QPixmap* m_pix; | 51 | mutable QPixmap* m_pix; |
51 | QString m_path; | 52 | QString m_path; |
52 | bool m_isDir : 1; | 53 | bool m_isDir : 1; |
53 | bool m_noInfo :1; | 54 | bool m_noInfo :1; |
54 | }; | 55 | }; |
55 | 56 | ||
56 | 57 | ||
57 | /* | 58 | /* |
@@ -326,65 +327,70 @@ void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { | |||
326 | 327 | ||
327 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 328 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
328 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 329 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
329 | m_updatet = true; | 330 | m_updatet = true; |
330 | 331 | ||
331 | if (pix.width()>0) | 332 | if (pix.width()>0) |
332 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); | 333 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); |
333 | 334 | ||
334 | 335 | ||
335 | g_stringPix.remove( _path ); | 336 | g_stringPix.remove( _path ); |
336 | } | 337 | } |
337 | 338 | ||
338 | 339 | ||
339 | void PIconView::slotRename() { | 340 | void PIconView::slotRename() { |
340 | 341 | ||
341 | } | 342 | } |
342 | 343 | ||
343 | void PIconView::slotBeam() { | 344 | void PIconView::slotBeam() { |
344 | bool isDir; | 345 | bool isDir; |
345 | QString pa = currentFileName( isDir ); | 346 | QString pa = currentFileName( isDir ); |
346 | if ( isDir && pa.isEmpty() ) | 347 | if ( isDir && pa.isEmpty() ) |
347 | return; | 348 | return; |
348 | 349 | ||
349 | Ir* ir = new Ir( this ); | 350 | Ir* ir = new Ir( this ); |
350 | connect( ir, SIGNAL(done(Ir*)), | 351 | connect( ir, SIGNAL(done(Ir*)), |
351 | this, SLOT(slotBeamDone(Ir*))); | 352 | this, SLOT(slotBeamDone(Ir*))); |
352 | ir->send(pa, tr( "Image" ) ); | 353 | ir->send(pa, tr( "Image" ) ); |
353 | 354 | ||
354 | } | 355 | } |
355 | 356 | ||
356 | void PIconView::slotBeamDone( Ir* ir) { | 357 | void PIconView::slotBeamDone( Ir* ir) { |
357 | delete ir; | 358 | delete ir; |
358 | } | 359 | } |
359 | 360 | ||
360 | void PIconView::slotStart() { | 361 | void PIconView::slotStart() { |
361 | m_view->viewport()->setUpdatesEnabled( false ); | 362 | m_view->viewport()->setUpdatesEnabled( false ); |
362 | qWarning( "Sig Start" ); | 363 | qWarning( "Sig Start" ); |
363 | } | 364 | } |
364 | 365 | ||
365 | void PIconView::slotEnd() { | 366 | void PIconView::slotEnd() { |
366 | qWarning( "SLot End" ); | 367 | qWarning( "SLot End" ); |
367 | if ( m_updatet ) | 368 | if ( m_updatet ) |
368 | m_view->arrangeItemsInGrid( ); | 369 | m_view->arrangeItemsInGrid( ); |
369 | m_view->viewport()->setUpdatesEnabled( true ); | 370 | m_view->viewport()->setUpdatesEnabled( true ); |
370 | m_updatet = false; | 371 | m_updatet = false; |
371 | } | 372 | } |
372 | 373 | ||
373 | void PIconView::slotShowImage() { | 374 | void PIconView::slotShowImage() { |
374 | 375 | qDebug("image show"); | |
376 | bool isDir = false; | ||
377 | QString name = currentFileName(isDir); | ||
378 | if (isDir) return; | ||
379 | ImageDlg dlg(name); | ||
380 | QPEApplication::execDialog(&dlg); | ||
375 | } | 381 | } |
376 | void PIconView::slotShowImage( const QString& ) { | 382 | void PIconView::slotShowImage( const QString& ) { |
377 | 383 | ||
378 | } | 384 | } |
379 | void PIconView::slotImageInfo() { | 385 | void PIconView::slotImageInfo() { |
380 | qDebug("image info"); | 386 | qDebug("image info"); |
381 | bool isDir = false; | 387 | bool isDir = false; |
382 | QString name = currentFileName(isDir); | 388 | QString name = currentFileName(isDir); |
383 | if (isDir) return; | 389 | if (isDir) return; |
384 | infoDlg dlg(name); | 390 | infoDlg dlg(name); |
385 | QPEApplication::execDialog(&dlg); | 391 | QPEApplication::execDialog(&dlg); |
386 | } | 392 | } |
387 | 393 | ||
388 | void PIconView::slotImageInfo( const QString& ) { | 394 | void PIconView::slotImageInfo( const QString& ) { |
389 | 395 | ||
390 | } | 396 | } |
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.cpp b/noncore/graphics/opie-eye/gui/imagescrollview.cpp new file mode 100644 index 0000000..f36b717 --- a/dev/null +++ b/noncore/graphics/opie-eye/gui/imagescrollview.cpp | |||
@@ -0,0 +1,97 @@ | |||
1 | #include "imagescrollview.h" | ||
2 | |||
3 | #include <qimage.h> | ||
4 | #include <qlayout.h> | ||
5 | |||
6 | ImageScrollView::ImageScrollView (const QImage&img, QWidget * parent, const char * name, WFlags f) | ||
7 | :QScrollView(parent,name,f|Qt::WRepaintNoErase),_image_data(img) | ||
8 | { | ||
9 | init(); | ||
10 | } | ||
11 | |||
12 | ImageScrollView::ImageScrollView (const QString&img, QWidget * parent, const char * name, WFlags f) | ||
13 | :QScrollView(parent,name,f/*|Qt::WRepaintNoErase*/),_image_data(img) | ||
14 | { | ||
15 | init(); | ||
16 | } | ||
17 | |||
18 | void ImageScrollView::setImage(const QImage&img) | ||
19 | { | ||
20 | _image_data = img; | ||
21 | init(); | ||
22 | } | ||
23 | |||
24 | /* should be called every time the QImage changed it content */ | ||
25 | void ImageScrollView::init() | ||
26 | { | ||
27 | viewport()->setBackgroundColor(white); | ||
28 | resizeContents(_image_data.width(),_image_data.height()); | ||
29 | } | ||
30 | |||
31 | ImageScrollView::~ImageScrollView() | ||
32 | { | ||
33 | } | ||
34 | |||
35 | void ImageScrollView::drawContents(QPainter * p, int clipx, int clipy, int clipw, int cliph) | ||
36 | { | ||
37 | int w = clipw; | ||
38 | int h = cliph; | ||
39 | int x = clipx; | ||
40 | int y = clipy; | ||
41 | bool erase = false; | ||
42 | |||
43 | if (w>_image_data.width()) { | ||
44 | w=_image_data.width(); | ||
45 | x = 0; | ||
46 | erase = true; | ||
47 | } else if (x+w>_image_data.width()){ | ||
48 | x = _image_data.width()-w; | ||
49 | } | ||
50 | if (h>_image_data.height()) { | ||
51 | h=_image_data.height(); | ||
52 | y = 0; | ||
53 | erase = true; | ||
54 | } else if (y+h>_image_data.height()){ | ||
55 | y = _image_data.height()-h; | ||
56 | } | ||
57 | if (erase) { | ||
58 | p->fillRect(clipx,clipy,clipw,cliph,white); | ||
59 | } | ||
60 | p->drawImage(clipx,clipy,_image_data,x,y,w,h); | ||
61 | } | ||
62 | |||
63 | void ImageScrollView::viewportMouseMoveEvent(QMouseEvent* e) | ||
64 | { | ||
65 | int mx, my; | ||
66 | viewportToContents( e->x(), e->y(), mx, my ); | ||
67 | |||
68 | scrollBy(_mouseStartPosX-mx,my-_mouseStartPosY); | ||
69 | |||
70 | _mouseStartPosX=mx; | ||
71 | _mouseStartPosY=my; | ||
72 | } | ||
73 | |||
74 | void ImageScrollView::contentsMouseReleaseEvent ( QMouseEvent * e) | ||
75 | { | ||
76 | viewportToContents( e->x(), e->y(), _mouseStartPosX,_mouseStartPosY ); | ||
77 | } | ||
78 | |||
79 | void ImageScrollView::contentsMousePressEvent ( QMouseEvent * e) | ||
80 | { | ||
81 | viewportToContents( e->x(), e->y(), _mouseStartPosX,_mouseStartPosY ); | ||
82 | } | ||
83 | |||
84 | /* for testing */ | ||
85 | ImageDlg::ImageDlg(const QString&fname,QWidget * parent, const char * name) | ||
86 | :QDialog(parent,name,true,WStyle_ContextHelp) | ||
87 | { | ||
88 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | ||
89 | dlglayout->setSpacing(2); | ||
90 | dlglayout->setMargin(1); | ||
91 | ImageScrollView*inf = new ImageScrollView(fname,this); | ||
92 | dlglayout->addWidget(inf); | ||
93 | } | ||
94 | |||
95 | ImageDlg::~ImageDlg() | ||
96 | { | ||
97 | } | ||
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.h b/noncore/graphics/opie-eye/gui/imagescrollview.h new file mode 100644 index 0000000..5836c8d --- a/dev/null +++ b/noncore/graphics/opie-eye/gui/imagescrollview.h | |||
@@ -0,0 +1,43 @@ | |||
1 | #ifndef __IMAGE_SCROLL_VIEW_H | ||
2 | #define __IMAGE_SCROLL_VIEW_H | ||
3 | |||
4 | #include <qscrollview.h> | ||
5 | #include <qimage.h> | ||
6 | #include <qstring.h> | ||
7 | #include <qdialog.h> | ||
8 | |||
9 | class QPainter; | ||
10 | |||
11 | class ImageScrollView:public QScrollView | ||
12 | { | ||
13 | Q_OBJECT | ||
14 | public: | ||
15 | ImageScrollView (const QImage&, QWidget * parent=0, const char * name=0, WFlags f=0 ); | ||
16 | ImageScrollView (const QString&, QWidget * parent=0, const char * name=0, WFlags f=0 ); | ||
17 | virtual ~ImageScrollView(); | ||
18 | |||
19 | void setImage(const QImage&); | ||
20 | protected: | ||
21 | virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph ); | ||
22 | void init(); | ||
23 | |||
24 | QImage _image_data; | ||
25 | |||
26 | int _mouseStartPosX,_mouseStartPosY; | ||
27 | |||
28 | protected slots: | ||
29 | virtual void viewportMouseMoveEvent(QMouseEvent* e); | ||
30 | virtual void contentsMousePressEvent ( QMouseEvent * e); | ||
31 | virtual void contentsMouseReleaseEvent ( QMouseEvent * e); | ||
32 | }; | ||
33 | |||
34 | /* for testing */ | ||
35 | class ImageDlg:public QDialog | ||
36 | { | ||
37 | Q_OBJECT | ||
38 | public: | ||
39 | ImageDlg(const QString&,QWidget * parent=0, const char * name=0); | ||
40 | virtual ~ImageDlg(); | ||
41 | }; | ||
42 | |||
43 | #endif | ||