author | zecke <zecke> | 2004-04-14 18:38:37 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-04-14 18:38:37 (UTC) |
commit | 0b83b10334da449fb9304c9b89a4175f3728d377 (patch) (unidiff) | |
tree | 465cdb61d1fa032de425761ef0074ee58bad7cd2 | |
parent | b671d282c25e86429727b6b52a674d1d8cd3f1a7 (diff) | |
download | opie-0b83b10334da449fb9304c9b89a4175f3728d377.zip opie-0b83b10334da449fb9304c9b89a4175f3728d377.tar.gz opie-0b83b10334da449fb9304c9b89a4175f3728d377.tar.bz2 |
-comments on imagezoomer
recalculateGrid Alwin please fill in the blank
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 20 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.h | 4 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/viewmodebutton.cpp | 29 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/viewmodebutton.h | 2 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/lib/oimagezoomer.cpp | 9 |
5 files changed, 56 insertions, 8 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index a06844a..e61f9d9 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -1,491 +1,503 @@ | |||
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 | #include <gui/imagescrollview.h> |
11 | 11 | ||
12 | #include <iface/dirview.h> | 12 | #include <iface/dirview.h> |
13 | #include <iface/dirlister.h> | 13 | #include <iface/dirlister.h> |
14 | 14 | ||
15 | #include <opie2/oconfig.h> | 15 | #include <opie2/oconfig.h> |
16 | #include <opie2/okeyconfigwidget.h> | 16 | #include <opie2/okeyconfigwidget.h> |
17 | #include <opie2/odebug.h> | 17 | #include <opie2/odebug.h> |
18 | 18 | ||
19 | #include <qpe/resource.h> | 19 | #include <qpe/resource.h> |
20 | #include <qpe/qpemessagebox.h> | 20 | #include <qpe/qpemessagebox.h> |
21 | #include <qpe/ir.h> | 21 | #include <qpe/ir.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | 24 | ||
25 | #include <qiconview.h> | 25 | #include <qiconview.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qhbox.h> | 27 | #include <qhbox.h> |
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qdir.h> | 29 | #include <qdir.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | #include <qmainwindow.h> | 31 | #include <qmainwindow.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qstyle.h> | 33 | #include <qstyle.h> |
34 | 34 | ||
35 | 35 | ||
36 | using Opie::Core::OKeyConfigItem; | 36 | using Opie::Core::OKeyConfigItem; |
37 | 37 | ||
38 | /* | 38 | /* |
39 | * The Icons, Request Cache and IconViewItem for the IconView | 39 | * The Icons, Request Cache and IconViewItem for the IconView |
40 | */ | 40 | */ |
41 | namespace { | 41 | namespace { |
42 | static QPixmap* _dirPix = 0; | 42 | static QPixmap* _dirPix = 0; |
43 | static QPixmap* _unkPix = 0; | 43 | static QPixmap* _unkPix = 0; |
44 | static QPixmap* _picPix = 0; | 44 | static QPixmap* _picPix = 0; |
45 | class IconViewItem : public QIconViewItem { | 45 | class IconViewItem : public QIconViewItem { |
46 | public: | 46 | public: |
47 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); | 47 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); |
48 | QPixmap* pixmap()const; | 48 | QPixmap* pixmap()const; |
49 | QString path()const { return m_path; } | 49 | QString path()const { return m_path; } |
50 | bool isDir()const { return m_isDir; } | 50 | bool isDir()const { return m_isDir; } |
51 | void setText( const QString& ); | 51 | void setText( const QString& ); |
52 | 52 | ||
53 | protected: | 53 | protected: |
54 | mutable QPixmap* m_pix; | 54 | mutable QPixmap* m_pix; |
55 | 55 | ||
56 | private: | 56 | private: |
57 | QString m_path; | 57 | QString m_path; |
58 | bool m_isDir : 1; | 58 | bool m_isDir : 1; |
59 | bool m_noInfo :1; | 59 | bool m_noInfo :1; |
60 | }; | 60 | }; |
61 | class TextViewItem : public IconViewItem { | 61 | class TextViewItem : public IconViewItem { |
62 | TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); | 62 | TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); |
63 | QPixmap *pixmap()const; | 63 | QPixmap *pixmap()const; |
64 | void setText( const QString& ); | 64 | void setText( const QString& ); |
65 | }; | 65 | }; |
66 | class ThumbViewItem : public IconViewItem { | 66 | class ThumbViewItem : public IconViewItem { |
67 | ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); | 67 | ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); |
68 | QPixmap *pixmap()const; | 68 | QPixmap *pixmap()const; |
69 | void setText( const QString& ); | 69 | void setText( const QString& ); |
70 | }; | 70 | }; |
71 | 71 | ||
72 | 72 | ||
73 | /* | 73 | /* |
74 | * If we request an Image or String | 74 | * If we request an Image or String |
75 | * we add it to the map | 75 | * we add it to the map |
76 | */ | 76 | */ |
77 | static QMap<QString, IconViewItem*> g_stringInf; | 77 | static QMap<QString, IconViewItem*> g_stringInf; |
78 | static QMap<QString, IconViewItem*> g_stringPix; | 78 | static QMap<QString, IconViewItem*> g_stringPix; |
79 | 79 | ||
80 | IconViewItem::IconViewItem( QIconView* view,const QString& path, | 80 | IconViewItem::IconViewItem( QIconView* view,const QString& path, |
81 | const QString& name, bool isDir ) | 81 | const QString& name, bool isDir ) |
82 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), | 82 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), |
83 | m_noInfo( false ) | 83 | m_noInfo( false ) |
84 | { | 84 | { |
85 | if ( isDir && !_dirPix ) | 85 | if ( isDir && !_dirPix ) |
86 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); | 86 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); |
87 | else if ( !isDir && !_unkPix ) | 87 | else if ( !isDir && !_unkPix ) |
88 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); | 88 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); |
89 | } | 89 | } |
90 | inline QPixmap* IconViewItem::pixmap()const { | 90 | inline QPixmap* IconViewItem::pixmap()const { |
91 | // qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", | 91 | // qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", |
92 | // rect().x(),rect().y(),rect().width(),rect().height(), | 92 | // rect().x(),rect().y(),rect().width(),rect().height(), |
93 | // iconView()->contentsX(), iconView()->contentsY()); | 93 | // iconView()->contentsX(), iconView()->contentsY()); |
94 | 94 | ||
95 | if ( m_isDir ) | 95 | if ( m_isDir ) |
96 | return _dirPix; | 96 | return _dirPix; |
97 | else{ | 97 | else{ |
98 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { | 98 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { |
99 | currentView()->dirLister()->imageInfo( m_path ); | 99 | currentView()->dirLister()->imageInfo( m_path ); |
100 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); | 100 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); |
101 | } | 101 | } |
102 | 102 | ||
103 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); | 103 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); |
104 | if ( !m_pix && !g_stringPix.contains( m_path )) { | 104 | if ( !m_pix && !g_stringPix.contains( m_path )) { |
105 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); | 105 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); |
106 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); | 106 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); |
107 | } | 107 | } |
108 | return m_pix ? m_pix : _unkPix; | 108 | return m_pix ? m_pix : _unkPix; |
109 | } | 109 | } |
110 | } | 110 | } |
111 | inline void IconViewItem::setText( const QString& str ) { | 111 | inline void IconViewItem::setText( const QString& str ) { |
112 | QString text = QIconViewItem::text()+"\n"+str; | 112 | QString text = QIconViewItem::text()+"\n"+str; |
113 | m_noInfo = true; | 113 | m_noInfo = true; |
114 | QIconViewItem::setText( text ); | 114 | QIconViewItem::setText( text ); |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | 118 | ||
119 | /* | 119 | /* |
120 | * Set up the GUI.. initialize the slave set up gui | 120 | * Set up the GUI.. initialize the slave set up gui |
121 | * and also load a dir | 121 | * and also load a dir |
122 | */ | 122 | */ |
123 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | 123 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) |
124 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) | 124 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) |
125 | { | 125 | { |
126 | { | 126 | { |
127 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 127 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
128 | } | 128 | } |
129 | m_path = QDir::homeDirPath(); | 129 | m_path = QDir::homeDirPath(); |
130 | m_mode = 0; | 130 | m_mode = 0; |
131 | 131 | ||
132 | QHBox *hbox = new QHBox( this ); | 132 | QHBox *hbox = new QHBox( this ); |
133 | QLabel* lbl = new QLabel( hbox ); | 133 | QLabel* lbl = new QLabel( hbox ); |
134 | lbl->setText( tr("View as" ) ); | 134 | lbl->setText( tr("View as" ) ); |
135 | 135 | ||
136 | m_views = new QComboBox( hbox, "View As" ); | 136 | m_views = new QComboBox( hbox, "View As" ); |
137 | connect( m_views, SIGNAL(activated(int)), | 137 | connect( m_views, SIGNAL(activated(int)), |
138 | this, SLOT(slotViewChanged(int)) ); | 138 | this, SLOT(slotViewChanged(int)) ); |
139 | 139 | ||
140 | m_view= new QIconView( this ); | 140 | m_view= new QIconView( this ); |
141 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), | 141 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), |
142 | this, SLOT(slotClicked(QIconViewItem*)) ); | 142 | this, SLOT(slotClicked(QIconViewItem*)) ); |
143 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), | 143 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), |
144 | this, SLOT(slotClicked(QIconViewItem*)) ); | 144 | this, SLOT(slotClicked(QIconViewItem*)) ); |
145 | 145 | ||
146 | m_view->setArrangement( QIconView::LeftToRight ); | 146 | m_view->setArrangement( QIconView::LeftToRight ); |
147 | m_view->setItemTextPos( QIconView::Right ); | 147 | m_view->setItemTextPos( QIconView::Right ); |
148 | 148 | ||
149 | int dw = QApplication::desktop()->width(); | 149 | int dw = QApplication::desktop()->width(); |
150 | int viewerWidth = dw-style().scrollBarExtent().width(); | 150 | int viewerWidth = dw-style().scrollBarExtent().width(); |
151 | m_view->setGridX( viewerWidth-3*m_view->spacing()); | 151 | m_view->setGridX( viewerWidth-3*m_view->spacing()); |
152 | m_view->setGridY( fontMetrics().height()*2+40 ); | 152 | m_view->setGridY( fontMetrics().height()*2+40 ); |
153 | 153 | ||
154 | 154 | ||
155 | initKeys(); | 155 | initKeys(); |
156 | 156 | ||
157 | loadViews(); | 157 | loadViews(); |
158 | slotViewChanged( m_views->currentItem() ); | 158 | slotViewChanged( m_views->currentItem() ); |
159 | } | 159 | } |
160 | 160 | ||
161 | /* | 161 | /* |
162 | * Unref the slave and save the keyboard manager | 162 | * Unref the slave and save the keyboard manager |
163 | */ | 163 | */ |
164 | PIconView::~PIconView() { | 164 | PIconView::~PIconView() { |
165 | { | 165 | { |
166 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 166 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
167 | } | 167 | } |
168 | m_viewManager->save(); | 168 | m_viewManager->save(); |
169 | delete m_viewManager; | 169 | delete m_viewManager; |
170 | } | 170 | } |
171 | 171 | ||
172 | Opie::Core::OKeyConfigManager* PIconView::manager() { | 172 | Opie::Core::OKeyConfigManager* PIconView::manager() { |
173 | return m_viewManager; | 173 | return m_viewManager; |
174 | } | 174 | } |
175 | 175 | ||
176 | 176 | ||
177 | /* | 177 | /* |
178 | * init the KeyBoard Shortcuts | 178 | * init the KeyBoard Shortcuts |
179 | * called from the c'tor | 179 | * called from the c'tor |
180 | */ | 180 | */ |
181 | void PIconView::initKeys() { | 181 | void PIconView::initKeys() { |
182 | Opie::Core::OKeyPair::List lst; | 182 | Opie::Core::OKeyPair::List lst; |
183 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); | 183 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); |
184 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | 184 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); |
185 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | 185 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); |
186 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 186 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
187 | lst.append( Opie::Core::OKeyPair::returnKey() ); | 187 | lst.append( Opie::Core::OKeyPair::returnKey() ); |
188 | 188 | ||
189 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", | 189 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", |
190 | lst, false,this, "keyconfig name" ); | 190 | lst, false,this, "keyconfig name" ); |
191 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", | 191 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", |
192 | Resource::loadPixmap("beam"), BeamItem, | 192 | Resource::loadPixmap("beam"), BeamItem, |
193 | Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), | 193 | Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), |
194 | this, SLOT(slotBeam())) ); | 194 | this, SLOT(slotBeam())) ); |
195 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", | 195 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", |
196 | Resource::loadPixmap("trash"), DeleteItem, | 196 | Resource::loadPixmap("trash"), DeleteItem, |
197 | Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), | 197 | Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), |
198 | this, SLOT(slotTrash())) ); | 198 | this, SLOT(slotTrash())) ); |
199 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", | 199 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", |
200 | Resource::loadPixmap("1to1"), ViewItem, | 200 | Resource::loadPixmap("1to1"), ViewItem, |
201 | Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), | 201 | Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), |
202 | this, SLOT(slotShowImage()))); | 202 | this, SLOT(slotShowImage()))); |
203 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", | 203 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", |
204 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, | 204 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, |
205 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), | 205 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), |
206 | this, SLOT(slotImageInfo()) ) ); | 206 | this, SLOT(slotImageInfo()) ) ); |
207 | m_viewManager->load(); | 207 | m_viewManager->load(); |
208 | m_viewManager->handleWidget( m_view ); | 208 | m_viewManager->handleWidget( m_view ); |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | /* | 212 | /* |
213 | * change one dir up | 213 | * change one dir up |
214 | */ | 214 | */ |
215 | void PIconView::slotDirUp() { | 215 | void PIconView::slotDirUp() { |
216 | QDir dir( m_path ); | 216 | QDir dir( m_path ); |
217 | dir.cdUp(); | 217 | dir.cdUp(); |
218 | slotChangeDir( dir.absPath() ); | 218 | slotChangeDir( dir.absPath() ); |
219 | } | 219 | } |
220 | 220 | ||
221 | /* | 221 | /* |
222 | * change the dir | 222 | * change the dir |
223 | */ | 223 | */ |
224 | void PIconView::slotChangeDir(const QString& path) { | 224 | void PIconView::slotChangeDir(const QString& path) { |
225 | if ( !currentView() ) | 225 | if ( !currentView() ) |
226 | return; | 226 | return; |
227 | 227 | ||
228 | PDirLister *lister = currentView()->dirLister(); | 228 | PDirLister *lister = currentView()->dirLister(); |
229 | if (!lister ) | 229 | if (!lister ) |
230 | return; | 230 | return; |
231 | 231 | ||
232 | /* | 232 | /* |
233 | * Say what we want and take what we get | 233 | * Say what we want and take what we get |
234 | */ | 234 | */ |
235 | lister->setStartPath( path ); | 235 | lister->setStartPath( path ); |
236 | m_path = lister->currentPath(); | 236 | m_path = lister->currentPath(); |
237 | 237 | ||
238 | m_view->viewport()->setUpdatesEnabled( false ); | 238 | m_view->viewport()->setUpdatesEnabled( false ); |
239 | m_view->clear(); | 239 | m_view->clear(); |
240 | 240 | ||
241 | /* | 241 | /* |
242 | * add files and folders | 242 | * add files and folders |
243 | */ | 243 | */ |
244 | addFolders( lister->folders() ); | 244 | addFolders( lister->folders() ); |
245 | addFiles( lister->files() ); | 245 | addFiles( lister->files() ); |
246 | m_view->viewport()->setUpdatesEnabled( true ); | 246 | m_view->viewport()->setUpdatesEnabled( true ); |
247 | 247 | ||
248 | // Also invalidate the cache. We can't cancel the operations anyway | 248 | // Also invalidate the cache. We can't cancel the operations anyway |
249 | g_stringPix.clear(); | 249 | g_stringPix.clear(); |
250 | g_stringInf.clear(); | 250 | g_stringInf.clear(); |
251 | 251 | ||
252 | // looks ugly | 252 | // looks ugly |
253 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); | 253 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); |
254 | } | 254 | } |
255 | 255 | ||
256 | /** | 256 | /** |
257 | * get the current file name | 257 | * get the current file name |
258 | * @param isDir see if this is a dir or real file | 258 | * @param isDir see if this is a dir or real file |
259 | */ | 259 | */ |
260 | QString PIconView::currentFileName(bool &isDir)const { | 260 | QString PIconView::currentFileName(bool &isDir)const { |
261 | isDir = false; | 261 | isDir = false; |
262 | QIconViewItem* _it = m_view->currentItem(); | 262 | QIconViewItem* _it = m_view->currentItem(); |
263 | if ( !_it ) | 263 | if ( !_it ) |
264 | return QString::null; | 264 | return QString::null; |
265 | 265 | ||
266 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 266 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
267 | isDir = it->isDir(); | 267 | isDir = it->isDir(); |
268 | return it->path(); | 268 | return it->path(); |
269 | } | 269 | } |
270 | 270 | ||
271 | void PIconView::slotTrash() { | 271 | void PIconView::slotTrash() { |
272 | bool isDir; | 272 | bool isDir; |
273 | QString pa = currentFileName( isDir ); | 273 | QString pa = currentFileName( isDir ); |
274 | if ( isDir && pa.isEmpty() ) | 274 | if ( isDir && pa.isEmpty() ) |
275 | return; | 275 | return; |
276 | 276 | ||
277 | if (!QPEMessageBox::confirmDelete( this, | 277 | if (!QPEMessageBox::confirmDelete( this, |
278 | tr("Delete Image" ), | 278 | tr("Delete Image" ), |
279 | tr("the Image %1" ).arg(pa))) | 279 | tr("the Image %1" ).arg(pa))) |
280 | return | 280 | return |
281 | 281 | ||
282 | 282 | ||
283 | currentView()->dirLister()->deleteImage( pa ); | 283 | currentView()->dirLister()->deleteImage( pa ); |
284 | delete m_view->currentItem(); | 284 | delete m_view->currentItem(); |
285 | } | 285 | } |
286 | 286 | ||
287 | /* | 287 | /* |
288 | * see what views are available | 288 | * see what views are available |
289 | */ | 289 | */ |
290 | void PIconView::loadViews() { | 290 | void PIconView::loadViews() { |
291 | ViewMap::Iterator it; | 291 | ViewMap::Iterator it; |
292 | ViewMap* map = viewMap(); | 292 | ViewMap* map = viewMap(); |
293 | for ( it = map->begin(); it != map->end(); ++it ) | 293 | for ( it = map->begin(); it != map->end(); ++it ) |
294 | m_views->insertItem( QObject::tr(it.key() ) ); | 294 | m_views->insertItem( QObject::tr(it.key() ) ); |
295 | } | 295 | } |
296 | 296 | ||
297 | void PIconView::resetView() { | 297 | void PIconView::resetView() { |
298 | slotViewChanged(m_views->currentItem()); | 298 | slotViewChanged(m_views->currentItem()); |
299 | } | 299 | } |
300 | 300 | ||
301 | /* | 301 | /* |
302 | *swicth view reloadDir and connect signals | 302 | *swicth view reloadDir and connect signals |
303 | */ | 303 | */ |
304 | void PIconView::slotViewChanged( int i) { | 304 | void PIconView::slotViewChanged( int i) { |
305 | if (!m_views->count() ) { | 305 | if (!m_views->count() ) { |
306 | setCurrentView( 0l); | 306 | setCurrentView( 0l); |
307 | return; | 307 | return; |
308 | } | 308 | } |
309 | 309 | ||
310 | PDirView* cur = currentView(); | 310 | PDirView* cur = currentView(); |
311 | delete cur; | 311 | delete cur; |
312 | QString str = m_views->text(i); | 312 | QString str = m_views->text(i); |
313 | cur = (*(*viewMap())[str])(*m_cfg); | 313 | cur = (*(*viewMap())[str])(*m_cfg); |
314 | setCurrentView( cur ); | 314 | setCurrentView( cur ); |
315 | 315 | ||
316 | /* connect to the signals of the lister */ | 316 | /* connect to the signals of the lister */ |
317 | PDirLister* lis = cur->dirLister(); | 317 | PDirLister* lis = cur->dirLister(); |
318 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), | 318 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), |
319 | this, SLOT( slotThumbInfo(const QString&, const QString&))); | 319 | this, SLOT( slotThumbInfo(const QString&, const QString&))); |
320 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 320 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
321 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 321 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
322 | connect(lis, SIGNAL(sig_start()), | 322 | connect(lis, SIGNAL(sig_start()), |
323 | this, SLOT(slotStart())); | 323 | this, SLOT(slotStart())); |
324 | connect(lis, SIGNAL(sig_end()) , | 324 | connect(lis, SIGNAL(sig_end()) , |
325 | this, SLOT(slotEnd()) ); | 325 | this, SLOT(slotEnd()) ); |
326 | 326 | ||
327 | 327 | ||
328 | /* reload now */ | 328 | /* reload now */ |
329 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); | 329 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); |
330 | } | 330 | } |
331 | 331 | ||
332 | 332 | ||
333 | void PIconView::slotReloadDir() { | 333 | void PIconView::slotReloadDir() { |
334 | slotChangeDir( m_path ); | 334 | slotChangeDir( m_path ); |
335 | } | 335 | } |
336 | 336 | ||
337 | 337 | ||
338 | /* | 338 | /* |
339 | * add files and folders | 339 | * add files and folders |
340 | */ | 340 | */ |
341 | void PIconView::addFolders( const QStringList& lst) { | 341 | void PIconView::addFolders( const QStringList& lst) { |
342 | QStringList::ConstIterator it; | 342 | QStringList::ConstIterator it; |
343 | 343 | ||
344 | for(it=lst.begin(); it != lst.end(); ++it ) | 344 | for(it=lst.begin(); it != lst.end(); ++it ) |
345 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); | 345 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); |
346 | 346 | ||
347 | 347 | ||
348 | } | 348 | } |
349 | 349 | ||
350 | void PIconView::addFiles( const QStringList& lst) { | 350 | void PIconView::addFiles( const QStringList& lst) { |
351 | QStringList::ConstIterator it; | 351 | QStringList::ConstIterator it; |
352 | for (it=lst.begin(); it!= lst.end(); ++it ) | 352 | for (it=lst.begin(); it!= lst.end(); ++it ) |
353 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); | 353 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); |
354 | 354 | ||
355 | } | 355 | } |
356 | 356 | ||
357 | /* | 357 | /* |
358 | * user clicked on the item. Change dir or view | 358 | * user clicked on the item. Change dir or view |
359 | */ | 359 | */ |
360 | void PIconView::slotClicked(QIconViewItem* _it) { | 360 | void PIconView::slotClicked(QIconViewItem* _it) { |
361 | if(!_it ) | 361 | if(!_it ) |
362 | return; | 362 | return; |
363 | 363 | ||
364 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 364 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
365 | if( it->isDir() ) | 365 | if( it->isDir() ) |
366 | slotChangeDir( it->path() ); | 366 | slotChangeDir( it->path() ); |
367 | else // view image | 367 | else // view image |
368 | slotShowImage(); | 368 | slotShowImage(); |
369 | } | 369 | } |
370 | 370 | ||
371 | /* | 371 | /* |
372 | * got thumb info add to the cache if items is visible | 372 | * got thumb info add to the cache if items is visible |
373 | * we later need update after processing of slave is done | 373 | * we later need update after processing of slave is done |
374 | */ | 374 | */ |
375 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { | 375 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { |
376 | IconViewItem* item = g_stringInf[_path]; | 376 | IconViewItem* item = g_stringInf[_path]; |
377 | if (!item ) | 377 | if (!item ) |
378 | return; | 378 | return; |
379 | 379 | ||
380 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 380 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
381 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 381 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
382 | m_updatet = true; | 382 | m_updatet = true; |
383 | 383 | ||
384 | item->setText( str ); | 384 | item->setText( str ); |
385 | g_stringInf.remove( _path ); | 385 | g_stringInf.remove( _path ); |
386 | } | 386 | } |
387 | 387 | ||
388 | /* | 388 | /* |
389 | * got thumbnail and see if it is visible so we need to update later | 389 | * got thumbnail and see if it is visible so we need to update later |
390 | */ | 390 | */ |
391 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { | 391 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { |
392 | IconViewItem* item = g_stringPix[_path]; | 392 | IconViewItem* item = g_stringPix[_path]; |
393 | if (!item ) | 393 | if (!item ) |
394 | return; | 394 | return; |
395 | 395 | ||
396 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 396 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
397 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 397 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
398 | m_updatet = true; | 398 | m_updatet = true; |
399 | 399 | ||
400 | if (pix.width()>0) | 400 | if (pix.width()>0) |
401 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); | 401 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); |
402 | 402 | ||
403 | 403 | ||
404 | g_stringPix.remove( _path ); | 404 | g_stringPix.remove( _path ); |
405 | } | 405 | } |
406 | 406 | ||
407 | 407 | ||
408 | /* | 408 | /* |
409 | * FIXME rename | 409 | * FIXME rename |
410 | */ | 410 | */ |
411 | void PIconView::slotRename() { | 411 | void PIconView::slotRename() { |
412 | 412 | ||
413 | } | 413 | } |
414 | 414 | ||
415 | 415 | ||
416 | /* | 416 | /* |
417 | * BEAM the current file | 417 | * BEAM the current file |
418 | */ | 418 | */ |
419 | void PIconView::slotBeam() { | 419 | void PIconView::slotBeam() { |
420 | bool isDir; | 420 | bool isDir; |
421 | QString pa = currentFileName( isDir ); | 421 | QString pa = currentFileName( isDir ); |
422 | if ( isDir && pa.isEmpty() ) | 422 | if ( isDir && pa.isEmpty() ) |
423 | return; | 423 | return; |
424 | 424 | ||
425 | Ir* ir = new Ir( this ); | 425 | Ir* ir = new Ir( this ); |
426 | connect( ir, SIGNAL(done(Ir*)), | 426 | connect( ir, SIGNAL(done(Ir*)), |
427 | this, SLOT(slotBeamDone(Ir*))); | 427 | this, SLOT(slotBeamDone(Ir*))); |
428 | ir->send(pa, tr( "Image" ) ); | 428 | ir->send(pa, tr( "Image" ) ); |
429 | } | 429 | } |
430 | 430 | ||
431 | /* | 431 | /* |
432 | * BEAM done clean up | 432 | * BEAM done clean up |
433 | */ | 433 | */ |
434 | void PIconView::slotBeamDone( Ir* ir) { | 434 | void PIconView::slotBeamDone( Ir* ir) { |
435 | delete ir; | 435 | delete ir; |
436 | } | 436 | } |
437 | 437 | ||
438 | void PIconView::slotStart() { | 438 | void PIconView::slotStart() { |
439 | m_view->viewport()->setUpdatesEnabled( false ); | 439 | m_view->viewport()->setUpdatesEnabled( false ); |
440 | } | 440 | } |
441 | 441 | ||
442 | void PIconView::slotEnd() { | 442 | void PIconView::slotEnd() { |
443 | if ( m_updatet ) | 443 | if ( m_updatet ) |
444 | m_view->arrangeItemsInGrid( ); | 444 | m_view->arrangeItemsInGrid( ); |
445 | m_view->viewport()->setUpdatesEnabled( true ); | 445 | m_view->viewport()->setUpdatesEnabled( true ); |
446 | m_updatet = false; | 446 | m_updatet = false; |
447 | } | 447 | } |
448 | 448 | ||
449 | void PIconView::slotShowImage() | 449 | void PIconView::slotShowImage() |
450 | { | 450 | { |
451 | bool isDir = false; | 451 | bool isDir = false; |
452 | QString name = currentFileName(isDir); | 452 | QString name = currentFileName(isDir); |
453 | if (isDir) return; | 453 | if (isDir) return; |
454 | 454 | ||
455 | slotShowImage( name ); | 455 | slotShowImage( name ); |
456 | } | 456 | } |
457 | void PIconView::slotShowImage( const QString& name) { | 457 | void PIconView::slotShowImage( const QString& name) { |
458 | emit sig_display( name ); | 458 | emit sig_display( name ); |
459 | } | 459 | } |
460 | void PIconView::slotImageInfo() { | 460 | void PIconView::slotImageInfo() { |
461 | bool isDir = false; | 461 | bool isDir = false; |
462 | QString name = currentFileName(isDir); | 462 | QString name = currentFileName(isDir); |
463 | if (isDir) return; | 463 | if (isDir) return; |
464 | 464 | ||
465 | slotImageInfo( name ); | 465 | slotImageInfo( name ); |
466 | } | 466 | } |
467 | 467 | ||
468 | void PIconView::slotImageInfo( const QString& name) { | 468 | void PIconView::slotImageInfo( const QString& name) { |
469 | emit sig_showInfo( name ); | 469 | emit sig_showInfo( name ); |
470 | } | 470 | } |
471 | 471 | ||
472 | 472 | ||
473 | void PIconView::slotChangeMode( int mode ) { | 473 | void PIconView::slotChangeMode( int mode ) { |
474 | if ( mode >= 0 && mode <= 3 ) | 474 | if ( mode >= 1 && mode <= 3 ) |
475 | m_mode = mode; | 475 | m_mode = mode; |
476 | 476 | ||
477 | QIconView::ItemTextPos pos; | 477 | QIconView::ItemTextPos pos; |
478 | switch( m_mode ) { | 478 | switch( m_mode ) { |
479 | case 1: | 479 | case 2: |
480 | pos = QIconView::Bottom; | 480 | pos = QIconView::Bottom; |
481 | break; | 481 | break; |
482 | case 2: | 482 | case 3: |
483 | case 0: | 483 | case 1: |
484 | default: | 484 | default: |
485 | pos = QIconView::Right; | 485 | pos = QIconView::Right; |
486 | break; | 486 | break; |
487 | } | 487 | } |
488 | m_view->setItemTextPos( pos ); | 488 | m_view->setItemTextPos( pos ); |
489 | 489 | ||
490 | calculateGrid(); | ||
490 | slotReloadDir(); | 491 | slotReloadDir(); |
491 | } | 492 | } |
493 | |||
494 | |||
495 | void PIconView::resizeEvent( QResizeEvent* re ) { | ||
496 | QVBox::resizeEvent( re ); | ||
497 | calculateGrid(); | ||
498 | } | ||
499 | |||
500 | |||
501 | void PIconView::calculateGrid() { | ||
502 | |||
503 | } | ||
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h index af41aef..903c4fd 100644 --- a/noncore/graphics/opie-eye/gui/iconview.h +++ b/noncore/graphics/opie-eye/gui/iconview.h | |||
@@ -1,85 +1,89 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | * No WArranty... | 3 | * No WArranty... |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #ifndef PHUNK_ICON_VIEW_H | 6 | #ifndef PHUNK_ICON_VIEW_H |
7 | #define PHUNK_ICON_VIEW_H | 7 | #define PHUNK_ICON_VIEW_H |
8 | 8 | ||
9 | #include <qvbox.h> | 9 | #include <qvbox.h> |
10 | 10 | ||
11 | 11 | ||
12 | class QIconView; | 12 | class QIconView; |
13 | class QIconViewItem; | 13 | class QIconViewItem; |
14 | class QComboBox; | 14 | class QComboBox; |
15 | class PIconViewItem; | 15 | class PIconViewItem; |
16 | class PDirLister; | 16 | class PDirLister; |
17 | class Ir; | 17 | class Ir; |
18 | 18 | ||
19 | namespace Opie { | 19 | namespace Opie { |
20 | namespace Core{ | 20 | namespace Core{ |
21 | class OConfig; | 21 | class OConfig; |
22 | class OKeyConfigManager; | 22 | class OKeyConfigManager; |
23 | } | 23 | } |
24 | } | 24 | } |
25 | 25 | ||
26 | class PIconView : public QVBox { | 26 | class PIconView : public QVBox { |
27 | Q_OBJECT | 27 | Q_OBJECT |
28 | friend class PIconViewItem; | 28 | friend class PIconViewItem; |
29 | enum ActionIds { | 29 | enum ActionIds { |
30 | BeamItem, DeleteItem, ViewItem, InfoItem | 30 | BeamItem, DeleteItem, ViewItem, InfoItem |
31 | }; | 31 | }; |
32 | public: | 32 | public: |
33 | PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); | 33 | PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); |
34 | ~PIconView(); | 34 | ~PIconView(); |
35 | void resetView(); | 35 | void resetView(); |
36 | Opie::Core::OKeyConfigManager* manager(); | 36 | Opie::Core::OKeyConfigManager* manager(); |
37 | 37 | ||
38 | signals: | 38 | signals: |
39 | void sig_showInfo( const QString& ); | 39 | void sig_showInfo( const QString& ); |
40 | void sig_display( const QString& ); | 40 | void sig_display( const QString& ); |
41 | 41 | ||
42 | protected: | ||
43 | void resizeEvent( QResizeEvent* ); | ||
44 | |||
42 | private: | 45 | private: |
43 | void initKeys(); | 46 | void initKeys(); |
44 | QString currentFileName(bool &isDir)const; | 47 | QString currentFileName(bool &isDir)const; |
45 | void loadViews(); | 48 | void loadViews(); |
49 | void calculateGrid(); | ||
46 | 50 | ||
47 | private slots: | 51 | private slots: |
48 | void slotDirUp(); | 52 | void slotDirUp(); |
49 | void slotChangeDir(const QString&); | 53 | void slotChangeDir(const QString&); |
50 | void slotTrash(); | 54 | void slotTrash(); |
51 | void slotViewChanged( int ); | 55 | void slotViewChanged( int ); |
52 | void slotReloadDir(); | 56 | void slotReloadDir(); |
53 | void slotRename(); | 57 | void slotRename(); |
54 | void slotBeam(); | 58 | void slotBeam(); |
55 | void slotBeamDone( Ir* ); | 59 | void slotBeamDone( Ir* ); |
56 | 60 | ||
57 | void slotShowImage(); | 61 | void slotShowImage(); |
58 | void slotShowImage( const QString& ); | 62 | void slotShowImage( const QString& ); |
59 | void slotImageInfo(); | 63 | void slotImageInfo(); |
60 | void slotImageInfo( const QString& ); | 64 | void slotImageInfo( const QString& ); |
61 | 65 | ||
62 | void slotStart(); | 66 | void slotStart(); |
63 | void slotEnd(); | 67 | void slotEnd(); |
64 | 68 | ||
65 | /* for performance reasons make it inline in the future */ | 69 | /* for performance reasons make it inline in the future */ |
66 | void addFolders( const QStringList& ); | 70 | void addFolders( const QStringList& ); |
67 | void addFiles( const QStringList& ); | 71 | void addFiles( const QStringList& ); |
68 | void slotClicked(QIconViewItem* ); | 72 | void slotClicked(QIconViewItem* ); |
69 | 73 | ||
70 | /**/ | 74 | /**/ |
71 | void slotThumbInfo(const QString&, const QString&); | 75 | void slotThumbInfo(const QString&, const QString&); |
72 | void slotThumbNail(const QString&, const QPixmap&); | 76 | void slotThumbNail(const QString&, const QPixmap&); |
73 | 77 | ||
74 | void slotChangeMode( int ); | 78 | void slotChangeMode( int ); |
75 | private: | 79 | private: |
76 | Opie::Core::OKeyConfigManager *m_viewManager; | 80 | Opie::Core::OKeyConfigManager *m_viewManager; |
77 | Opie::Core::OConfig *m_cfg; | 81 | Opie::Core::OConfig *m_cfg; |
78 | QComboBox* m_views; | 82 | QComboBox* m_views; |
79 | QIconView* m_view; | 83 | QIconView* m_view; |
80 | QString m_path; | 84 | QString m_path; |
81 | bool m_updatet : 1; | 85 | bool m_updatet : 1; |
82 | int m_mode; | 86 | int m_mode; |
83 | }; | 87 | }; |
84 | 88 | ||
85 | #endif | 89 | #endif |
diff --git a/noncore/graphics/opie-eye/gui/viewmodebutton.cpp b/noncore/graphics/opie-eye/gui/viewmodebutton.cpp index fdf4e77..0e4a7cb 100644 --- a/noncore/graphics/opie-eye/gui/viewmodebutton.cpp +++ b/noncore/graphics/opie-eye/gui/viewmodebutton.cpp | |||
@@ -1,24 +1,45 @@ | |||
1 | #include "viewmodebutton.h" | 1 | #include "viewmodebutton.h" |
2 | 2 | ||
3 | #include <opie2/odebug.h> | ||
4 | |||
3 | #include <qtoolbar.h> | 5 | #include <qtoolbar.h> |
4 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
5 | 7 | ||
6 | ViewModeButton::ViewModeButton( QToolBar* bar ) | 8 | ViewModeButton::ViewModeButton( QToolBar* bar ) |
7 | : QToolButton( bar ) | 9 | : QToolButton( bar ) |
8 | { | 10 | { |
9 | setIconSet( Resource::loadIconSet( "toys" ) ); | 11 | slotChange( 1 ); |
10 | QPopupMenu *pop= new QPopupMenu( this ); | 12 | QPopupMenu *pop= new QPopupMenu( this ); |
11 | pop->setCheckable( true ); | 13 | pop->setCheckable( true ); |
12 | pop->insertItem( tr("Thumbnail and Imageinfo"), 0 ); | 14 | pop->insertItem( tr("Thumbnail and Imageinfo"), 1 ); |
13 | pop->insertItem( tr("Thumbnail and Name" ), 1 ); | 15 | pop->insertItem( tr("Thumbnail and Name" ), 2 ); |
14 | pop->insertItem( tr("Name Only" ), 2 ); | 16 | pop->insertItem( tr("Name Only" ), 3 ); |
15 | connect(pop, SIGNAL(activated(int)), | 17 | connect(pop, SIGNAL(activated(int)), |
16 | this, SIGNAL(changeMode(int)) ); | 18 | this, SIGNAL(changeMode(int)) ); |
19 | connect(pop, SIGNAL(activated(int)), | ||
20 | this, SLOT(slotChange(int)) ); | ||
17 | 21 | ||
18 | 22 | ||
19 | setPopup( pop ); | 23 | setPopup( pop ); |
20 | } | 24 | } |
21 | 25 | ||
22 | ViewModeButton::~ViewModeButton() { | 26 | ViewModeButton::~ViewModeButton() { |
27 | } | ||
28 | |||
29 | void ViewModeButton::slotChange( int i ) { | ||
30 | QString name; | ||
31 | switch( i ) { | ||
32 | case 1: | ||
33 | name = "opie-eye/opie-eye-thumb"; | ||
34 | break; | ||
35 | case 2: | ||
36 | name = "opie-eye/opie-eye-thumbonly"; | ||
37 | break; | ||
38 | case 3: | ||
39 | name = "opie-eye/opie-eye-textview"; | ||
40 | break; | ||
41 | } | ||
23 | 42 | ||
43 | qWarning("foo %d" +name, i ); | ||
44 | setIconSet( Resource::loadIconSet( name ) ); | ||
24 | } | 45 | } |
diff --git a/noncore/graphics/opie-eye/gui/viewmodebutton.h b/noncore/graphics/opie-eye/gui/viewmodebutton.h index 44f2228..3247114 100644 --- a/noncore/graphics/opie-eye/gui/viewmodebutton.h +++ b/noncore/graphics/opie-eye/gui/viewmodebutton.h | |||
@@ -1,23 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 only | 2 | * GPLv2 only |
3 | * zecke@handhelds.org | 3 | * zecke@handhelds.org |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #ifndef PHUNK_VIEW_MODE_BUTTON_H | 6 | #ifndef PHUNK_VIEW_MODE_BUTTON_H |
7 | #define PHUNK_VIEW_MODE_BUTTON_H | 7 | #define PHUNK_VIEW_MODE_BUTTON_H |
8 | 8 | ||
9 | #include <qpe/resource.h> | 9 | #include <qpe/resource.h> |
10 | 10 | ||
11 | #include <qtoolbutton.h> | 11 | #include <qtoolbutton.h> |
12 | 12 | ||
13 | class ViewModeButton : public QToolButton { | 13 | class ViewModeButton : public QToolButton { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | public: | 15 | public: |
16 | ViewModeButton( QToolBar* ); | 16 | ViewModeButton( QToolBar* ); |
17 | ~ViewModeButton(); | 17 | ~ViewModeButton(); |
18 | 18 | ||
19 | signals: | 19 | signals: |
20 | void changeMode( int ); | 20 | void changeMode( int ); |
21 | private slots: | ||
22 | void slotChange( int i ); | ||
21 | }; | 23 | }; |
22 | 24 | ||
23 | #endif | 25 | #endif |
diff --git a/noncore/graphics/opie-eye/lib/oimagezoomer.cpp b/noncore/graphics/opie-eye/lib/oimagezoomer.cpp index 4df5dcc..00b93e2 100644 --- a/noncore/graphics/opie-eye/lib/oimagezoomer.cpp +++ b/noncore/graphics/opie-eye/lib/oimagezoomer.cpp | |||
@@ -1,210 +1,219 @@ | |||
1 | #include "oimagezoomer.h" | 1 | #include "oimagezoomer.h" |
2 | 2 | ||
3 | #include <qimage.h> | 3 | #include <qimage.h> |
4 | #include <qpixmap.h> | 4 | #include <qpixmap.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qrect.h> | 6 | #include <qrect.h> |
7 | #include <qpoint.h> | 7 | #include <qpoint.h> |
8 | #include <qsize.h> | 8 | #include <qsize.h> |
9 | 9 | ||
10 | namespace Opie { | 10 | namespace Opie { |
11 | namespace MM { | 11 | namespace MM { |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * \brief The most simple c'tor | 14 | * \brief The most simple c'tor |
15 | * The main c'tor. You still need to set a QPixmap/QIMage, | 15 | * The main c'tor. You still need to set a QPixmap/QIMage, |
16 | * setImageSize,setViewPortSize,setVisiblePoint | 16 | * setImageSize,setViewPortSize,setVisiblePoint |
17 | * | 17 | * |
18 | * @param parent The parent widget | 18 | * @param parent The parent widget |
19 | * @param name A name for this widget | 19 | * @param name A name for this widget |
20 | * @param fl The widget flags | 20 | * @param fl The widget flags |
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | OImageZoomer::OImageZoomer( QWidget* parent, const char* name, WFlags fl ) | 23 | OImageZoomer::OImageZoomer( QWidget* parent, const char* name, WFlags fl ) |
24 | : QFrame( parent, name, fl ) { | 24 | : QFrame( parent, name, fl ) { |
25 | init(); | 25 | init(); |
26 | } | 26 | } |
27 | 27 | ||
28 | 28 | ||
29 | /** | 29 | /** |
30 | * \brief This c'tor takes a QPixmap additional | 30 | * \brief This c'tor takes a QPixmap additional |
31 | * | 31 | * |
32 | * You initially set the QPixmap but you still need to provide | 32 | * You initially set the QPixmap but you still need to provide |
33 | * the additional data to make this widget useful | 33 | * the additional data to make this widget useful |
34 | * | 34 | * |
35 | * @param pix A Pixmap it'll be converted to a QImage later! | 35 | * @param pix A Pixmap it'll be converted to a QImage later! |
36 | * @param par The parent widget | 36 | * @param par The parent widget |
37 | * @param name The name of this widget | 37 | * @param name The name of this widget |
38 | * @param fl The widget flags | 38 | * @param fl The widget flags |
39 | */ | 39 | */ |
40 | OImageZoomer::OImageZoomer( const QPixmap& pix, QWidget* par, const char* name, WFlags fl ) | 40 | OImageZoomer::OImageZoomer( const QPixmap& pix, QWidget* par, const char* name, WFlags fl ) |
41 | : QFrame( par, name, fl ) { | 41 | : QFrame( par, name, fl ) { |
42 | init(); | 42 | init(); |
43 | setImage( pix ); | 43 | setImage( pix ); |
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
47 | /** | 47 | /** |
48 | * \brief This c'tor takes a QImage instead | 48 | * \brief This c'tor takes a QImage instead |
49 | * You just provide a QImage which is saved. It behaves the same as the others. | 49 | * You just provide a QImage which is saved. It behaves the same as the others. |
50 | * | 50 | * |
51 | * @param img A Image which will be used for the zoomer content | 51 | * @param img A Image which will be used for the zoomer content |
52 | * @param par The parent of the widget | 52 | * @param par The parent of the widget |
53 | * @param name The name of the widget | 53 | * @param name The name of the widget |
54 | * @param fl The widgets flags | 54 | * @param fl The widgets flags |
55 | */ | 55 | */ |
56 | OImageZoomer::OImageZoomer( const QImage& img, QWidget* par, const char* name, WFlags fl) | 56 | OImageZoomer::OImageZoomer( const QImage& img, QWidget* par, const char* name, WFlags fl) |
57 | : QFrame( par, name, fl ) { | 57 | : QFrame( par, name, fl ) { |
58 | init(); | 58 | init(); |
59 | setImage( img ); | 59 | setImage( img ); |
60 | } | 60 | } |
61 | 61 | ||
62 | 62 | ||
63 | /** | 63 | /** |
64 | * \brief overloaded c'tor | 64 | * \brief overloaded c'tor |
65 | * | 65 | * |
66 | * This differs only in the arguments it takes | 66 | * This differs only in the arguments it takes |
67 | * | 67 | * |
68 | * | 68 | * |
69 | * @param pSize The size of the Page you show | 69 | * @param pSize The size of the Page you show |
70 | * @param vSize The size of the viewport. The size of the visible part of the widget | 70 | * @param vSize The size of the viewport. The size of the visible part of the widget |
71 | * @param par The parent of the widget | 71 | * @param par The parent of the widget |
72 | * @param name The name | 72 | * @param name The name |
73 | * @param fl The window flags | 73 | * @param fl The window flags |
74 | */ | 74 | */ |
75 | OImageZoomer::OImageZoomer( const QSize& pSize, const QSize& vSize, QWidget* par, | 75 | OImageZoomer::OImageZoomer( const QSize& pSize, const QSize& vSize, QWidget* par, |
76 | const char* name, WFlags fl ) | 76 | const char* name, WFlags fl ) |
77 | : QFrame( par, name, fl ), m_imgSize( pSize ),m_visSize( vSize ) { | 77 | : QFrame( par, name, fl ), m_imgSize( pSize ),m_visSize( vSize ) { |
78 | init(); | 78 | init(); |
79 | } | 79 | } |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * d'tor | 82 | * d'tor |
83 | */ | 83 | */ |
84 | OImageZoomer::~OImageZoomer() { | 84 | OImageZoomer::~OImageZoomer() { |
85 | 85 | ||
86 | } | 86 | } |
87 | 87 | ||
88 | void OImageZoomer::init() { | 88 | void OImageZoomer::init() { |
89 | setFrameStyle( Panel | Sunken ); | 89 | setFrameStyle( Panel | Sunken ); |
90 | } | 90 | } |
91 | 91 | ||
92 | 92 | ||
93 | /** | 93 | /** |
94 | * \brief set the page/image size | 94 | * \brief set the page/image size |
95 | * Tell us the QSize of the Data you show to the user. We need this | 95 | * Tell us the QSize of the Data you show to the user. We need this |
96 | * to do the calculations | 96 | * to do the calculations |
97 | * | 97 | * |
98 | * @param size The size of the stuff you want to zoom on | 98 | * @param size The size of the stuff you want to zoom on |
99 | */ | 99 | */ |
100 | void OImageZoomer::setImageSize( const QSize& size ) { | 100 | void OImageZoomer::setImageSize( const QSize& size ) { |
101 | m_imgSize = size; | 101 | m_imgSize = size; |
102 | repaint(); | 102 | repaint(); |
103 | } | 103 | } |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * \brief Set the size of the viewport | 106 | * \brief Set the size of the viewport |
107 | * Tell us the QSize of the viewport. The viewport is the part | 107 | * Tell us the QSize of the viewport. The viewport is the part |
108 | * of the widget which is exposed on the screen | 108 | * of the widget which is exposed on the screen |
109 | * | 109 | * |
110 | * @param size Te size of the viewport | 110 | * @param size Te size of the viewport |
111 | * | 111 | * |
112 | * @see QScrollView::viewport() | 112 | * @see QScrollView::viewport() |
113 | */ | 113 | */ |
114 | void OImageZoomer::setViewPortSize( const QSize& size ) { | 114 | void OImageZoomer::setViewPortSize( const QSize& size ) { |
115 | m_visSize = size; | 115 | m_visSize = size; |
116 | repaint(); | 116 | repaint(); |
117 | } | 117 | } |
118 | 118 | ||
119 | /** | 119 | /** |
120 | * \brief the point in the topleft corner which is currently visible | 120 | * \brief the point in the topleft corner which is currently visible |
121 | * Set the visible point. This most of the times relate to QScrollView::contentsX() | 121 | * Set the visible point. This most of the times relate to QScrollView::contentsX() |
122 | * and QScrollView::contentsY() | 122 | * and QScrollView::contentsY() |
123 | * | 123 | * |
124 | * @see setVisiblePoint(int,int) | 124 | * @see setVisiblePoint(int,int) |
125 | */ | 125 | */ |
126 | void OImageZoomer::setVisiblePoint( const QPoint& pt ) { | 126 | void OImageZoomer::setVisiblePoint( const QPoint& pt ) { |
127 | m_visPt = pt; | 127 | m_visPt = pt; |
128 | repaint(); | 128 | repaint(); |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
132 | /** | 132 | /** |
133 | * Set the Image. The image will be resized on resizeEvent | 133 | * Set the Image. The image will be resized on resizeEvent |
134 | * and it'll set the QPixmap background | 134 | * and it'll set the QPixmap background |
135 | * | 135 | * |
136 | * @param img The image will be stored internally and used as the background | 136 | * @param img The image will be stored internally and used as the background |
137 | */ | 137 | */ |
138 | void OImageZoomer::setImage( const QImage& img) { | 138 | void OImageZoomer::setImage( const QImage& img) { |
139 | m_img = img; | 139 | m_img = img; |
140 | resizeEvent( 0 ); | 140 | resizeEvent( 0 ); |
141 | repaint(); | 141 | repaint(); |
142 | } | 142 | } |
143 | 143 | ||
144 | /** | 144 | /** |
145 | * overloaded function it calls the QImage version | 145 | * overloaded function it calls the QImage version |
146 | */ | 146 | */ |
147 | void OImageZoomer::setImage( const QPixmap& pix) { | 147 | void OImageZoomer::setImage( const QPixmap& pix) { |
148 | setImage( pix.convertToImage() ); | 148 | setImage( pix.convertToImage() ); |
149 | } | 149 | } |
150 | 150 | ||
151 | void OImageZoomer::resizeEvent( QResizeEvent* ev ) { | 151 | void OImageZoomer::resizeEvent( QResizeEvent* ev ) { |
152 | QFrame::resizeEvent( ev ); | 152 | QFrame::resizeEvent( ev ); |
153 | setBackgroundOrigin( QWidget::WidgetOrigin ); | 153 | setBackgroundOrigin( QWidget::WidgetOrigin ); |
154 | // TODO Qt3 use PalettePixmap and use size | 154 | // TODO Qt3 use PalettePixmap and use size |
155 | QPixmap pix; pix.convertFromImage( m_img.smoothScale( size().width(), size().height() ) ); | 155 | QPixmap pix; pix.convertFromImage( m_img.smoothScale( size().width(), size().height() ) ); |
156 | setBackgroundPixmap( pix); | 156 | setBackgroundPixmap( pix); |
157 | } | 157 | } |
158 | 158 | ||
159 | void OImageZoomer::drawContents( QPainter* p ) { | 159 | void OImageZoomer::drawContents( QPainter* p ) { |
160 | /* | 160 | /* |
161 | * if the page size | 161 | * if the page size |
162 | */ | 162 | */ |
163 | if ( m_imgSize.isEmpty() ) | 163 | if ( m_imgSize.isEmpty() ) |
164 | return; | 164 | return; |
165 | 165 | ||
166 | /* | 166 | /* |
167 | * paint a red rect which represents the visible size | 167 | * paint a red rect which represents the visible size |
168 | * | 168 | * |
169 | * We need to recalculate x,y and width and height of the | 169 | * We need to recalculate x,y and width and height of the |
170 | * rect. So image size relates to contentRect | 170 | * rect. So image size relates to contentRect |
171 | * | 171 | * |
172 | */ | 172 | */ |
173 | QRect c( contentsRect() ); | 173 | QRect c( contentsRect() ); |
174 | p->setPen( Qt::red ); | 174 | p->setPen( Qt::red ); |
175 | 175 | ||
176 | /* | ||
177 | * the contentRect is set equal to the size of the image | ||
178 | * Rect/Original = NewRectORWidth/OriginalVisibleStuff and then simply we | ||
179 | * need to add the c.y/x due usage of QFrame | ||
180 | * For x and y we use the visiblePoint | ||
181 | * For height and width we use the size of the viewport | ||
182 | * if width/height would be bigger than our widget we use this width/height | ||
183 | * | ||
184 | */ | ||
176 | int len = m_imgSize.width(); | 185 | int len = m_imgSize.width(); |
177 | int x = (c.width()*m_visPt.x())/len + c.x(); | 186 | int x = (c.width()*m_visPt.x())/len + c.x(); |
178 | int w = (c.width()*m_visSize.width() )/len + c.x(); | 187 | int w = (c.width()*m_visSize.width() )/len + c.x(); |
179 | if ( w > c.width() ) w = c.width(); | 188 | if ( w > c.width() ) w = c.width(); |
180 | 189 | ||
181 | len = m_imgSize.height(); | 190 | len = m_imgSize.height(); |
182 | int y = (c.height()*m_visPt.y() )/len + c.y(); | 191 | int y = (c.height()*m_visPt.y() )/len + c.y(); |
183 | int h = (c.height()*m_visSize.height() )/len + c.y(); | 192 | int h = (c.height()*m_visSize.height() )/len + c.y(); |
184 | if ( h > c.height() ) h = c.height(); | 193 | if ( h > c.height() ) h = c.height(); |
185 | 194 | ||
186 | p->drawRect( x, y, w, h ); | 195 | p->drawRect( x, y, w, h ); |
187 | } | 196 | } |
188 | 197 | ||
189 | void OImageZoomer::mousePressEvent( QMouseEvent* ) { | 198 | void OImageZoomer::mousePressEvent( QMouseEvent* ) { |
190 | m_mouseX = m_mouseY = -1; | 199 | m_mouseX = m_mouseY = -1; |
191 | } | 200 | } |
192 | 201 | ||
193 | void OImageZoomer::mouseMoveEvent( QMouseEvent* ev ) { | 202 | void OImageZoomer::mouseMoveEvent( QMouseEvent* ev ) { |
194 | int mx, my; | 203 | int mx, my; |
195 | mx = ev->x(); | 204 | mx = ev->x(); |
196 | my = ev->y(); | 205 | my = ev->y(); |
197 | 206 | ||
198 | if ( m_mouseX != -1 && m_mouseY != -1 ) { | 207 | if ( m_mouseX != -1 && m_mouseY != -1 ) { |
199 | int diffx = ( mx - m_mouseX ) * m_imgSize.width() / width(); | 208 | int diffx = ( mx - m_mouseX ) * m_imgSize.width() / width(); |
200 | int diffy = ( my - m_mouseY ) * m_imgSize.height() / height(); | 209 | int diffy = ( my - m_mouseY ) * m_imgSize.height() / height(); |
201 | emit zoomAreaRel( diffx, diffy ); | 210 | emit zoomAreaRel( diffx, diffy ); |
202 | emit zoomArea(m_visPt.x()+diffx, m_visPt.y()+diffy ); | 211 | emit zoomArea(m_visPt.x()+diffx, m_visPt.y()+diffy ); |
203 | } | 212 | } |
204 | m_mouseX = mx; | 213 | m_mouseX = mx; |
205 | m_mouseY = my; | 214 | m_mouseY = my; |
206 | } | 215 | } |
207 | 216 | ||
208 | 217 | ||
209 | } | 218 | } |
210 | } | 219 | } |