-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 22 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.h | 2 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/iface/dirlister.h | 1 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/iface/dirview.h | 2 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/dcim/dcim_dirview.cpp | 5 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/dcim/dcim_dirview.h | 2 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp | 5 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/dir/dir_dirview.h | 1 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_dirview.cpp | 7 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_dirview.h | 4 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_lister.cpp | 41 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/impl/doc/doc_lister.h | 7 |
12 files changed, 91 insertions, 8 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 5472ead..948477c 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -1,884 +1,896 @@ | |||
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 | 10 | ||
11 | #include <iface/dirview.h> | 11 | #include <iface/dirview.h> |
12 | #include <iface/dirlister.h> | 12 | #include <iface/dirlister.h> |
13 | 13 | ||
14 | #include <opie2/oconfig.h> | 14 | #include <opie2/oconfig.h> |
15 | #include <opie2/okeyconfigwidget.h> | 15 | #include <opie2/okeyconfigwidget.h> |
16 | #include <opie2/odebug.h> | 16 | #include <opie2/odebug.h> |
17 | #include <opie2/oimagescrollview.h> | 17 | #include <opie2/oimagescrollview.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* _cpyPix = 0; | 44 | static QPixmap* _cpyPix = 0; |
45 | static QPixmap* _emptyPix = 0; | 45 | static QPixmap* _emptyPix = 0; |
46 | class IconViewItem : public QIconViewItem { | 46 | class IconViewItem : public QIconViewItem { |
47 | public: | 47 | public: |
48 | IconViewItem( QIconView*, const QString& path, const QString& name,int a_iconsize, bool isDir = false); | 48 | IconViewItem( QIconView*, const QString& path, const QString& name,int a_iconsize, bool isDir = false); |
49 | QPixmap* pixmap()const; | 49 | QPixmap* pixmap()const; |
50 | QString path()const { return m_path; } | 50 | QString path()const { return m_path; } |
51 | bool isDir()const { return m_isDir; } | 51 | bool isDir()const { return m_isDir; } |
52 | void setText( const QString& ); | 52 | void setText( const QString& ); |
53 | bool textOnly()const{return m_textOnly;} | 53 | bool textOnly()const{return m_textOnly;} |
54 | void setTextOnly(bool how){m_textOnly=how;} | 54 | void setTextOnly(bool how){m_textOnly=how;} |
55 | /* just for starting recalc of item rect! */ | 55 | /* just for starting recalc of item rect! */ |
56 | virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); | 56 | virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); |
57 | /* just for starting recalc of item rect! */ | 57 | /* just for starting recalc of item rect! */ |
58 | virtual void setPixmap( const QPixmap & icon); | 58 | virtual void setPixmap( const QPixmap & icon); |
59 | 59 | ||
60 | protected: | 60 | protected: |
61 | mutable QPixmap* m_pix; | 61 | mutable QPixmap* m_pix; |
62 | int m_iconsize; | 62 | int m_iconsize; |
63 | void check_pix()const; | 63 | void check_pix()const; |
64 | 64 | ||
65 | private: | 65 | private: |
66 | QString m_path; | 66 | QString m_path; |
67 | bool m_isDir : 1; | 67 | bool m_isDir : 1; |
68 | bool m_noInfo :1; | 68 | bool m_noInfo :1; |
69 | bool m_textOnly:1; | 69 | bool m_textOnly:1; |
70 | bool m_NameOnly:1; | 70 | bool m_NameOnly:1; |
71 | bool m_Pixset:1; | 71 | bool m_Pixset:1; |
72 | }; | 72 | }; |
73 | class TextViewItem : public IconViewItem { | 73 | class TextViewItem : public IconViewItem { |
74 | TextViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize , bool isDir = false); | 74 | TextViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize , bool isDir = false); |
75 | QPixmap *pixmap()const; | 75 | QPixmap *pixmap()const; |
76 | void setText( const QString& ); | 76 | void setText( const QString& ); |
77 | }; | 77 | }; |
78 | class ThumbViewItem : public IconViewItem { | 78 | class ThumbViewItem : public IconViewItem { |
79 | ThumbViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize, bool isDir = false ); | 79 | ThumbViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize, bool isDir = false ); |
80 | QPixmap *pixmap()const; | 80 | QPixmap *pixmap()const; |
81 | void setText( const QString& ); | 81 | void setText( const QString& ); |
82 | }; | 82 | }; |
83 | 83 | ||
84 | 84 | ||
85 | /* | 85 | /* |
86 | * If we request an Image or String | 86 | * If we request an Image or String |
87 | * we add it to the map | 87 | * we add it to the map |
88 | */ | 88 | */ |
89 | static QMap<QString, IconViewItem*> g_stringInf; | 89 | static QMap<QString, IconViewItem*> g_stringInf; |
90 | static QMap<QString, IconViewItem*> g_stringPix; | 90 | static QMap<QString, IconViewItem*> g_stringPix; |
91 | 91 | ||
92 | IconViewItem::IconViewItem( QIconView* view,const QString& path, | 92 | IconViewItem::IconViewItem( QIconView* view,const QString& path, |
93 | const QString& name, int a_iconsize, bool isDir) | 93 | const QString& name, int a_iconsize, bool isDir) |
94 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), | 94 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), |
95 | m_noInfo( false ),m_textOnly(false),m_Pixset(false) | 95 | m_noInfo( false ),m_textOnly(false),m_Pixset(false) |
96 | { | 96 | { |
97 | m_iconsize = a_iconsize; | 97 | m_iconsize = a_iconsize; |
98 | if ( isDir ) { | 98 | if ( isDir ) { |
99 | if (!_dirPix ) { | 99 | if (!_dirPix ) { |
100 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); | 100 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); |
101 | } | 101 | } |
102 | } else { | 102 | } else { |
103 | if (!_unkPix ) { | 103 | if (!_unkPix ) { |
104 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); | 104 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); |
105 | } | 105 | } |
106 | } | 106 | } |
107 | check_pix(); | 107 | check_pix(); |
108 | } | 108 | } |
109 | 109 | ||
110 | inline void IconViewItem::check_pix()const | 110 | inline void IconViewItem::check_pix()const |
111 | { | 111 | { |
112 | if (_dirPix && _dirPix->width()>m_iconsize) { | 112 | if (_dirPix && _dirPix->width()>m_iconsize) { |
113 | QImage Pix = _dirPix->convertToImage(); | 113 | QImage Pix = _dirPix->convertToImage(); |
114 | *_dirPix = Pix.smoothScale(m_iconsize,m_iconsize); | 114 | *_dirPix = Pix.smoothScale(m_iconsize,m_iconsize); |
115 | } | 115 | } |
116 | if (!_cpyPix && _unkPix) { | 116 | if (!_cpyPix && _unkPix) { |
117 | if (_unkPix->width()>=m_iconsize) { | 117 | if (_unkPix->width()>=m_iconsize) { |
118 | QImage Pix = _unkPix->convertToImage(); | 118 | QImage Pix = _unkPix->convertToImage(); |
119 | _cpyPix = new QPixmap(); | 119 | _cpyPix = new QPixmap(); |
120 | if (_unkPix->width()>m_iconsize) { | 120 | if (_unkPix->width()>m_iconsize) { |
121 | *_cpyPix = Pix.smoothScale(m_iconsize,m_iconsize); | 121 | *_cpyPix = Pix.smoothScale(m_iconsize,m_iconsize); |
122 | } else { | 122 | } else { |
123 | _cpyPix->convertFromImage(Pix); | 123 | _cpyPix->convertFromImage(Pix); |
124 | } | 124 | } |
125 | 125 | ||
126 | } else { | 126 | } else { |
127 | _cpyPix = new QPixmap(m_iconsize,m_iconsize); | 127 | _cpyPix = new QPixmap(m_iconsize,m_iconsize); |
128 | _cpyPix->fill(); | 128 | _cpyPix->fill(); |
129 | QPainter pa(_cpyPix); | 129 | QPainter pa(_cpyPix); |
130 | int offset = (m_iconsize-_unkPix->width())/2; | 130 | int offset = (m_iconsize-_unkPix->width())/2; |
131 | int offy = (m_iconsize-_unkPix->height())/2; | 131 | int offy = (m_iconsize-_unkPix->height())/2; |
132 | if (offy<0) offy=0; | 132 | if (offy<0) offy=0; |
133 | pa.drawPixmap(offset,offy,*_unkPix); | 133 | pa.drawPixmap(offset,offy,*_unkPix); |
134 | pa.end(); | 134 | pa.end(); |
135 | } | 135 | } |
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
139 | inline void IconViewItem::setPixmap( const QPixmap & , bool, bool ) | 139 | inline void IconViewItem::setPixmap( const QPixmap & , bool, bool ) |
140 | { | 140 | { |
141 | m_Pixset = true; | 141 | m_Pixset = true; |
142 | calcRect(text()); | 142 | calcRect(text()); |
143 | } | 143 | } |
144 | inline void IconViewItem::setPixmap( const QPixmap & ) | 144 | inline void IconViewItem::setPixmap( const QPixmap & ) |
145 | { | 145 | { |
146 | m_Pixset = true; | 146 | m_Pixset = true; |
147 | calcRect(text()); | 147 | calcRect(text()); |
148 | } | 148 | } |
149 | 149 | ||
150 | inline QPixmap* IconViewItem::pixmap()const { | 150 | inline QPixmap* IconViewItem::pixmap()const { |
151 | // owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y() | 151 | // owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y() |
152 | // << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX() | 152 | // << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX() |
153 | // << " " << iconView()->contentsY() << oendl; | 153 | // << " " << iconView()->contentsY() << oendl; |
154 | 154 | ||
155 | if (textOnly()&&!m_isDir) { | 155 | if (textOnly()&&!m_isDir) { |
156 | if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); | 156 | if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); |
157 | return _emptyPix; | 157 | return _emptyPix; |
158 | } | 158 | } |
159 | if ( m_isDir ) | 159 | if ( m_isDir ) |
160 | return _dirPix; | 160 | return _dirPix; |
161 | else{ | 161 | else{ |
162 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { | 162 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { |
163 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); | 163 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); |
164 | currentView()->dirLister()->imageInfo( m_path ); | 164 | currentView()->dirLister()->imageInfo( m_path ); |
165 | } | 165 | } |
166 | 166 | ||
167 | m_pix = PPixmapCache::self()->cachedImage( m_path, m_iconsize, m_iconsize ); | 167 | m_pix = PPixmapCache::self()->cachedImage( m_path, m_iconsize, m_iconsize ); |
168 | if (!m_pix && !g_stringPix.contains( m_path )) { | 168 | if (!m_pix && !g_stringPix.contains( m_path )) { |
169 | check_pix(); | 169 | check_pix(); |
170 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); | 170 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); |
171 | currentView()->dirLister()->thumbNail( m_path, m_iconsize, m_iconsize); | 171 | currentView()->dirLister()->thumbNail( m_path, m_iconsize, m_iconsize); |
172 | } | 172 | } |
173 | return m_pix ? m_pix : _cpyPix; | 173 | return m_pix ? m_pix : _cpyPix; |
174 | } | 174 | } |
175 | } | 175 | } |
176 | inline void IconViewItem::setText( const QString& str ) { | 176 | inline void IconViewItem::setText( const QString& str ) { |
177 | QString text = QIconViewItem::text()+"\n"+str; | 177 | QString text = QIconViewItem::text()+"\n"+str; |
178 | m_noInfo = true; | 178 | m_noInfo = true; |
179 | QIconViewItem::setText( text ); | 179 | QIconViewItem::setText( text ); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | 182 | ||
183 | 183 | ||
184 | /* | 184 | /* |
185 | * Set up the GUI.. initialize the slave set up gui | 185 | * Set up the GUI.. initialize the slave set up gui |
186 | * and also load a dir | 186 | * and also load a dir |
187 | */ | 187 | */ |
188 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | 188 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) |
189 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) | 189 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) |
190 | { | 190 | { |
191 | { | 191 | { |
192 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 192 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
193 | } | 193 | } |
194 | m_path = QDir::homeDirPath(); | 194 | m_path = QDir::homeDirPath(); |
195 | m_mode = 0; | 195 | m_mode = 0; |
196 | m_iconsize = 32; | 196 | m_iconsize = 32; |
197 | m_internalReset = false; | 197 | m_internalReset = false; |
198 | m_customWidget = 0; | ||
198 | 199 | ||
199 | QHBox *hbox = new QHBox( this ); | 200 | m_hbox = new QHBox( this ); |
200 | QLabel* lbl = new QLabel( hbox ); | 201 | QLabel* lbl = new QLabel( m_hbox ); |
201 | lbl->setText( tr("View as" ) ); | 202 | lbl->setText( tr("View as" ) ); |
202 | 203 | ||
203 | m_views = new QComboBox( hbox, "View As" ); | 204 | m_views = new QComboBox( m_hbox, "View As" ); |
204 | 205 | ||
205 | m_view= new QIconView( this ); | 206 | m_view= new QIconView( this ); |
206 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), | 207 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), |
207 | this, SLOT(slotClicked(QIconViewItem*)) ); | 208 | this, SLOT(slotClicked(QIconViewItem*)) ); |
208 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), | 209 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), |
209 | this, SLOT(slotClicked(QIconViewItem*)) ); | 210 | this, SLOT(slotClicked(QIconViewItem*)) ); |
210 | 211 | ||
211 | m_view->setArrangement( QIconView::LeftToRight ); | 212 | m_view->setArrangement( QIconView::LeftToRight ); |
212 | 213 | ||
213 | m_mode = m_cfg->readNumEntry("ListViewMode", 1); | 214 | m_mode = m_cfg->readNumEntry("ListViewMode", 1); |
214 | QString lastView = m_cfg->readEntry("LastView",""); | 215 | QString lastView = m_cfg->readEntry("LastView",""); |
215 | 216 | ||
216 | if (m_mode < 1 || m_mode>3) m_mode = 1; | 217 | if (m_mode < 1 || m_mode>3) m_mode = 1; |
217 | 218 | ||
218 | m_view->setItemTextPos( QIconView::Right ); | 219 | m_view->setItemTextPos( QIconView::Right ); |
219 | if (m_mode >1) { | 220 | if (m_mode >1) { |
220 | m_view->setResizeMode(QIconView::Adjust); | 221 | m_view->setResizeMode(QIconView::Adjust); |
221 | } else { | 222 | } else { |
222 | m_view->setResizeMode(QIconView::Fixed); | 223 | m_view->setResizeMode(QIconView::Fixed); |
223 | } | 224 | } |
224 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); | 225 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); |
225 | if (m_iconsize<12)m_iconsize = 12; | 226 | if (m_iconsize<12)m_iconsize = 12; |
226 | if (m_iconsize>64)m_iconsize = 64; | 227 | if (m_iconsize>64)m_iconsize = 64; |
227 | 228 | ||
228 | calculateGrid(); | 229 | calculateGrid(); |
229 | 230 | ||
230 | initKeys(); | 231 | initKeys(); |
231 | 232 | ||
232 | loadViews(); | 233 | loadViews(); |
233 | int cc=0; | 234 | int cc=0; |
234 | for (; cc<m_views->count();++cc) { | 235 | for (; cc<m_views->count();++cc) { |
235 | if (m_views->text(cc)==lastView) { | 236 | if (m_views->text(cc)==lastView) { |
236 | break; | 237 | break; |
237 | } | 238 | } |
238 | } | 239 | } |
239 | if (cc<m_views->count()) { | 240 | if (cc<m_views->count()) { |
240 | m_views->setCurrentItem(cc); | 241 | m_views->setCurrentItem(cc); |
241 | slotViewChanged(cc); | 242 | slotViewChanged(cc); |
242 | } else { | 243 | } else { |
243 | slotViewChanged(m_views->currentItem()); | 244 | slotViewChanged(m_views->currentItem()); |
244 | } | 245 | } |
245 | connect( m_views, SIGNAL(activated(int)), | 246 | connect( m_views, SIGNAL(activated(int)), |
246 | this, SLOT(slotViewChanged(int)) ); | 247 | this, SLOT(slotViewChanged(int)) ); |
247 | } | 248 | } |
248 | 249 | ||
249 | /* | 250 | /* |
250 | * Unref the slave and save the keyboard manager | 251 | * Unref the slave and save the keyboard manager |
251 | */ | 252 | */ |
252 | PIconView::~PIconView() { | 253 | PIconView::~PIconView() { |
253 | { | 254 | { |
254 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 255 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
255 | } | 256 | } |
256 | m_viewManager->save(); | 257 | m_viewManager->save(); |
257 | delete m_viewManager; | 258 | delete m_viewManager; |
258 | } | 259 | } |
259 | 260 | ||
260 | Opie::Core::OKeyConfigManager* PIconView::manager() { | 261 | Opie::Core::OKeyConfigManager* PIconView::manager() { |
261 | return m_viewManager; | 262 | return m_viewManager; |
262 | } | 263 | } |
263 | 264 | ||
264 | 265 | ||
265 | /* | 266 | /* |
266 | * init the KeyBoard Shortcuts | 267 | * init the KeyBoard Shortcuts |
267 | * called from the c'tor | 268 | * called from the c'tor |
268 | */ | 269 | */ |
269 | void PIconView::initKeys() { | 270 | void PIconView::initKeys() { |
270 | Opie::Core::OKeyPair::List lst; | 271 | Opie::Core::OKeyPair::List lst; |
271 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); | 272 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); |
272 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | 273 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); |
273 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | 274 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); |
274 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 275 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
275 | lst.append( Opie::Core::OKeyPair::returnKey() ); | 276 | lst.append( Opie::Core::OKeyPair::returnKey() ); |
276 | 277 | ||
277 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", | 278 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", |
278 | lst, false,this, "keyconfig name" ); | 279 | lst, false,this, "keyconfig name" ); |
279 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", | 280 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", |
280 | Resource::loadPixmap("beam"), BeamItem, | 281 | Resource::loadPixmap("beam"), BeamItem, |
281 | Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), | 282 | Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), |
282 | this, SLOT(slotBeam())) ); | 283 | this, SLOT(slotBeam())) ); |
283 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", | 284 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", |
284 | Resource::loadPixmap("trash"), DeleteItem, | 285 | Resource::loadPixmap("trash"), DeleteItem, |
285 | Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), | 286 | Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), |
286 | this, SLOT(slotTrash())) ); | 287 | this, SLOT(slotTrash())) ); |
287 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", | 288 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", |
288 | Resource::loadPixmap("1to1"), ViewItem, | 289 | Resource::loadPixmap("1to1"), ViewItem, |
289 | Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), | 290 | Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), |
290 | this, SLOT(slotShowImage()))); | 291 | this, SLOT(slotShowImage()))); |
291 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", | 292 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", |
292 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, | 293 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, |
293 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), | 294 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), |
294 | this, SLOT(slotImageInfo()) ) ); | 295 | this, SLOT(slotImageInfo()) ) ); |
295 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow", | 296 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow", |
296 | Resource::loadPixmap("1to1"), SlideItem, | 297 | Resource::loadPixmap("1to1"), SlideItem, |
297 | Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton), | 298 | Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton), |
298 | this, SLOT(slotStartSlide()))); | 299 | this, SLOT(slotStartSlide()))); |
299 | m_viewManager->load(); | 300 | m_viewManager->load(); |
300 | m_viewManager->handleWidget( m_view ); | 301 | m_viewManager->handleWidget( m_view ); |
301 | } | 302 | } |
302 | 303 | ||
303 | 304 | ||
304 | /* | 305 | /* |
305 | * change one dir up | 306 | * change one dir up |
306 | */ | 307 | */ |
307 | void PIconView::slotDirUp() | 308 | void PIconView::slotDirUp() |
308 | { | 309 | { |
309 | slotChangeDir( currentView()->dirLister()->dirUp( m_path ) ); | 310 | slotChangeDir( currentView()->dirLister()->dirUp( m_path ) ); |
310 | } | 311 | } |
311 | 312 | ||
312 | /* | 313 | /* |
313 | * change the dir | 314 | * change the dir |
314 | */ | 315 | */ |
315 | void PIconView::slotChangeDir(const QString& path) { | 316 | void PIconView::slotChangeDir(const QString& path) { |
316 | if ( !currentView() ) | 317 | if ( !currentView() ) |
317 | return; | 318 | return; |
318 | 319 | ||
319 | PDirLister *lister = currentView()->dirLister(); | 320 | PDirLister *lister = currentView()->dirLister(); |
320 | if (!lister ) | 321 | if (!lister ) |
321 | return; | 322 | return; |
322 | 323 | ||
323 | /* | 324 | /* |
324 | * Say what we want and take what we get | 325 | * Say what we want and take what we get |
325 | */ | 326 | */ |
326 | lister->setStartPath( path ); | 327 | lister->setStartPath( path ); |
327 | m_path = lister->currentPath(); | 328 | m_path = lister->currentPath(); |
328 | 329 | ||
329 | m_view->viewport()->setUpdatesEnabled( false ); | 330 | m_view->viewport()->setUpdatesEnabled( false ); |
330 | m_view->clear(); | 331 | m_view->clear(); |
331 | 332 | ||
332 | // Also invalidate the cache. We can't cancel the operations anyway | 333 | // Also invalidate the cache. We can't cancel the operations anyway |
333 | g_stringPix.clear(); | 334 | g_stringPix.clear(); |
334 | g_stringInf.clear(); | 335 | g_stringInf.clear(); |
335 | 336 | ||
336 | /* | 337 | /* |
337 | * add files and folders | 338 | * add files and folders |
338 | */ | 339 | */ |
339 | addFolders( lister->folders() ); | 340 | addFolders( lister->folders() ); |
340 | addFiles( lister->files() ); | 341 | addFiles( lister->files() ); |
341 | m_view->viewport()->setUpdatesEnabled( true ); | 342 | m_view->viewport()->setUpdatesEnabled( true ); |
342 | 343 | ||
343 | // looks ugly | 344 | // looks ugly |
344 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); | 345 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); |
345 | } | 346 | } |
346 | 347 | ||
347 | /** | 348 | /** |
348 | * get the current file name | 349 | * get the current file name |
349 | * @param isDir see if this is a dir or real file | 350 | * @param isDir see if this is a dir or real file |
350 | */ | 351 | */ |
351 | QString PIconView::currentFileName(bool &isDir)const { | 352 | QString PIconView::currentFileName(bool &isDir)const { |
352 | isDir = false; | 353 | isDir = false; |
353 | QIconViewItem* _it = m_view->currentItem(); | 354 | QIconViewItem* _it = m_view->currentItem(); |
354 | if ( !_it ) | 355 | if ( !_it ) |
355 | return QString::null; | 356 | return QString::null; |
356 | 357 | ||
357 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 358 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
358 | isDir = it->isDir(); | 359 | isDir = it->isDir(); |
359 | return it->path(); | 360 | return it->path(); |
360 | } | 361 | } |
361 | 362 | ||
362 | QString PIconView::nextFileName(bool &isDir)const | 363 | QString PIconView::nextFileName(bool &isDir)const |
363 | { | 364 | { |
364 | isDir = false; | 365 | isDir = false; |
365 | QIconViewItem* _it1 = m_view->currentItem(); | 366 | QIconViewItem* _it1 = m_view->currentItem(); |
366 | if ( !_it1 ) | 367 | if ( !_it1 ) |
367 | return QString::null; | 368 | return QString::null; |
368 | QIconViewItem* _it = _it1->nextItem(); | 369 | QIconViewItem* _it = _it1->nextItem(); |
369 | if ( !_it ) | 370 | if ( !_it ) |
370 | return QString::null; | 371 | return QString::null; |
371 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 372 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
372 | isDir = it->isDir(); | 373 | isDir = it->isDir(); |
373 | return it->path(); | 374 | return it->path(); |
374 | } | 375 | } |
375 | 376 | ||
376 | QString PIconView::prevFileName(bool &isDir)const{ | 377 | QString PIconView::prevFileName(bool &isDir)const{ |
377 | isDir = false; | 378 | isDir = false; |
378 | QIconViewItem* _it = m_view->currentItem(); | 379 | QIconViewItem* _it = m_view->currentItem(); |
379 | if ( !_it ) | 380 | if ( !_it ) |
380 | return QString::null; | 381 | return QString::null; |
381 | _it = _it->prevItem(); | 382 | _it = _it->prevItem(); |
382 | if ( !_it ) | 383 | if ( !_it ) |
383 | return QString::null; | 384 | return QString::null; |
384 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 385 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
385 | isDir = it->isDir(); | 386 | isDir = it->isDir(); |
386 | return it->path(); | 387 | return it->path(); |
387 | } | 388 | } |
388 | 389 | ||
389 | void PIconView::slotTrash() { | 390 | void PIconView::slotTrash() { |
390 | bool isDir; | 391 | bool isDir; |
391 | QString pa = currentFileName( isDir ); | 392 | QString pa = currentFileName( isDir ); |
392 | if ( isDir && pa.isEmpty() ) | 393 | if ( isDir && pa.isEmpty() ) |
393 | return; | 394 | return; |
394 | 395 | ||
395 | if (!QPEMessageBox::confirmDelete( this, | 396 | if (!QPEMessageBox::confirmDelete( this, |
396 | tr("Delete Image" ), | 397 | tr("Delete Image" ), |
397 | tr("the Image %1" ).arg(pa))) | 398 | tr("the Image %1" ).arg(pa))) |
398 | return | 399 | return |
399 | 400 | ||
400 | 401 | ||
401 | currentView()->dirLister()->deleteImage( pa ); | 402 | currentView()->dirLister()->deleteImage( pa ); |
402 | delete m_view->currentItem(); | 403 | delete m_view->currentItem(); |
403 | } | 404 | } |
404 | 405 | ||
405 | /* | 406 | /* |
406 | * see what views are available | 407 | * see what views are available |
407 | */ | 408 | */ |
408 | void PIconView::loadViews() { | 409 | void PIconView::loadViews() { |
409 | ViewMap::Iterator it; | 410 | ViewMap::Iterator it; |
410 | ViewMap* map = viewMap(); | 411 | ViewMap* map = viewMap(); |
411 | for ( it = map->begin(); it != map->end(); ++it ) | 412 | for ( it = map->begin(); it != map->end(); ++it ) |
412 | m_views->insertItem( it.key() ); | 413 | m_views->insertItem( it.key() ); |
413 | } | 414 | } |
414 | 415 | ||
415 | void PIconView::resetView() { | 416 | void PIconView::resetView() { |
416 | m_internalReset = true; | 417 | m_internalReset = true; |
417 | // Also invalidate the cache. We can't cancel the operations anyway | 418 | // Also invalidate the cache. We can't cancel the operations anyway |
418 | g_stringPix.clear(); | 419 | g_stringPix.clear(); |
419 | g_stringInf.clear(); | 420 | g_stringInf.clear(); |
420 | if (m_mode>1) { | 421 | if (m_mode>1) { |
421 | int osize = m_iconsize; | 422 | int osize = m_iconsize; |
422 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); | 423 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); |
423 | if (m_iconsize<12)m_iconsize = 12; | 424 | if (m_iconsize<12)m_iconsize = 12; |
424 | if (m_iconsize>64)m_iconsize = 64; | 425 | if (m_iconsize>64)m_iconsize = 64; |
425 | if (osize != m_iconsize) { | 426 | if (osize != m_iconsize) { |
426 | if (_dirPix){ | 427 | if (_dirPix){ |
427 | delete _dirPix; | 428 | delete _dirPix; |
428 | _dirPix = 0; | 429 | _dirPix = 0; |
429 | } | 430 | } |
430 | if (_cpyPix){ | 431 | if (_cpyPix){ |
431 | delete _cpyPix; | 432 | delete _cpyPix; |
432 | _cpyPix = 0; | 433 | _cpyPix = 0; |
433 | } | 434 | } |
434 | calculateGrid(); | 435 | calculateGrid(); |
435 | } | 436 | } |
436 | } else { | 437 | } else { |
437 | m_iconsize = 64; | 438 | m_iconsize = 64; |
438 | } | 439 | } |
439 | slotViewChanged(m_views->currentItem()); | 440 | slotViewChanged(m_views->currentItem()); |
440 | m_internalReset = false; | 441 | m_internalReset = false; |
441 | } | 442 | } |
442 | 443 | ||
443 | /* | 444 | /* |
444 | *swicth view reloadDir and connect signals | 445 | *swicth view reloadDir and connect signals |
445 | */ | 446 | */ |
446 | void PIconView::slotViewChanged( int i) { | 447 | void PIconView::slotViewChanged( int i) { |
447 | if (!m_views->count() ) { | 448 | if (!m_views->count() ) { |
448 | setCurrentView( 0l); | 449 | setCurrentView( 0l); |
449 | return; | 450 | return; |
450 | } | 451 | } |
451 | 452 | ||
453 | if (m_customWidget) { | ||
454 | delete m_customWidget; | ||
455 | m_customWidget = 0; | ||
456 | } | ||
452 | PDirView* cur = currentView(); | 457 | PDirView* cur = currentView(); |
453 | if (cur) delete cur; | 458 | if (cur) { |
459 | delete cur; | ||
460 | } | ||
454 | QString str = m_views->text(i); | 461 | QString str = m_views->text(i); |
455 | ViewMap* map = viewMap(); | 462 | ViewMap* map = viewMap(); |
456 | if (!map) { | 463 | if (!map) { |
457 | setCurrentView(0l); | 464 | setCurrentView(0l); |
458 | return; | 465 | return; |
459 | } | 466 | } |
460 | 467 | ||
461 | if (map->find(str) == map->end()) { | 468 | if (map->find(str) == map->end()) { |
462 | owarn << "Key not found" << oendl; | 469 | owarn << "Key not found" << oendl; |
463 | setCurrentView(0l); | 470 | setCurrentView(0l); |
464 | return; | 471 | return; |
465 | } | 472 | } |
466 | 473 | ||
467 | m_cfg->writeEntry("LastView",str); | 474 | m_cfg->writeEntry("LastView",str); |
468 | m_cfg->write(); | 475 | m_cfg->write(); |
469 | cur = (*(*map)[str])(*m_cfg); | 476 | cur = (*(*map)[str])(*m_cfg); |
470 | setCurrentView( cur ); | 477 | setCurrentView( cur ); |
478 | m_customWidget = cur->widget(m_hbox); | ||
479 | if (m_customWidget) { | ||
480 | odebug << "Got a widget" << oendl; | ||
481 | m_customWidget->show(); | ||
482 | } | ||
471 | 483 | ||
472 | /* connect to the signals of the lister */ | 484 | /* connect to the signals of the lister */ |
473 | PDirLister* lis = cur->dirLister(); | 485 | PDirLister* lis = cur->dirLister(); |
474 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), | 486 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), |
475 | this, SLOT( slotThumbInfo(const QString&, const QString&))); | 487 | this, SLOT( slotThumbInfo(const QString&, const QString&))); |
476 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 488 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
477 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 489 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
478 | connect(lis, SIGNAL(sig_start()), | 490 | connect(lis, SIGNAL(sig_start()), |
479 | this, SLOT(slotStart())); | 491 | this, SLOT(slotStart())); |
480 | connect(lis, SIGNAL(sig_end()) , | 492 | connect(lis, SIGNAL(sig_end()) , |
481 | this, SLOT(slotEnd()) ); | 493 | this, SLOT(slotEnd()) ); |
482 | 494 | connect(lis,SIGNAL(sig_reloadDir()),this,SLOT(slotReloadDir())); | |
483 | 495 | ||
484 | /* reload now with default Path | 496 | /* reload now with default Path |
485 | * but only if it isn't a reset like from setupdlg | 497 | * but only if it isn't a reset like from setupdlg |
486 | */ | 498 | */ |
487 | if (!m_internalReset) { | 499 | if (!m_internalReset) { |
488 | m_path = lis->defaultPath(); | 500 | m_path = lis->defaultPath(); |
489 | } | 501 | } |
490 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); | 502 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); |
491 | } | 503 | } |
492 | 504 | ||
493 | 505 | ||
494 | void PIconView::slotReloadDir() { | 506 | void PIconView::slotReloadDir() { |
495 | slotChangeDir( m_path ); | 507 | slotChangeDir( m_path ); |
496 | } | 508 | } |
497 | 509 | ||
498 | 510 | ||
499 | /* | 511 | /* |
500 | * add files and folders | 512 | * add files and folders |
501 | */ | 513 | */ |
502 | void PIconView::addFolders( const QStringList& lst) { | 514 | void PIconView::addFolders( const QStringList& lst) { |
503 | QStringList::ConstIterator it; | 515 | QStringList::ConstIterator it; |
504 | IconViewItem * _iv; | 516 | IconViewItem * _iv; |
505 | 517 | ||
506 | for(it=lst.begin(); it != lst.end(); ++it ) { | 518 | for(it=lst.begin(); it != lst.end(); ++it ) { |
507 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it),m_iconsize, true ); | 519 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it),m_iconsize, true ); |
508 | if (m_mode==3) _iv->setTextOnly(true); | 520 | if (m_mode==3) _iv->setTextOnly(true); |
509 | } | 521 | } |
510 | } | 522 | } |
511 | 523 | ||
512 | void PIconView::addFiles( const QStringList& lst) { | 524 | void PIconView::addFiles( const QStringList& lst) { |
513 | QStringList::ConstIterator it; | 525 | QStringList::ConstIterator it; |
514 | IconViewItem * _iv; | 526 | IconViewItem * _iv; |
515 | QPixmap*m_pix = 0; | 527 | QPixmap*m_pix = 0; |
516 | QString pre = ""; | 528 | QString pre = ""; |
517 | if (!m_path.isEmpty()) { | 529 | if (!m_path.isEmpty()) { |
518 | pre = m_path+"/"; | 530 | pre = m_path+"/"; |
519 | } | 531 | } |
520 | for (it=lst.begin(); it!= lst.end(); ++it ) { | 532 | for (it=lst.begin(); it!= lst.end(); ++it ) { |
521 | m_pix = PPixmapCache::self()->cachedImage( pre+(*it), m_iconsize, m_iconsize ); | 533 | m_pix = PPixmapCache::self()->cachedImage( pre+(*it), m_iconsize, m_iconsize ); |
522 | _iv = new IconViewItem( m_view, pre+(*it), (*it),m_iconsize ); | 534 | _iv = new IconViewItem( m_view, pre+(*it), (*it),m_iconsize ); |
523 | if (m_mode==3) { | 535 | if (m_mode==3) { |
524 | _iv->setTextOnly(true); | 536 | _iv->setTextOnly(true); |
525 | _iv->setPixmap(QPixmap()); | 537 | _iv->setPixmap(QPixmap()); |
526 | 538 | ||
527 | 539 | ||
528 | 540 | ||
529 | } else { | 541 | } else { |
530 | if (m_pix) _iv->setPixmap(*m_pix); | 542 | if (m_pix) _iv->setPixmap(*m_pix); |
531 | } | 543 | } |
532 | } | 544 | } |
533 | 545 | ||
534 | } | 546 | } |
535 | 547 | ||
536 | /* | 548 | /* |
537 | * user clicked on the item. Change dir or view | 549 | * user clicked on the item. Change dir or view |
538 | */ | 550 | */ |
539 | void PIconView::slotClicked(QIconViewItem* _it) { | 551 | void PIconView::slotClicked(QIconViewItem* _it) { |
540 | if(!_it ) | 552 | if(!_it ) |
541 | return; | 553 | return; |
542 | 554 | ||
543 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 555 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
544 | if( it->isDir() ) | 556 | if( it->isDir() ) |
545 | slotChangeDir( it->path() ); | 557 | slotChangeDir( it->path() ); |
546 | else // view image | 558 | else // view image |
547 | slotShowImage(); | 559 | slotShowImage(); |
548 | } | 560 | } |
549 | 561 | ||
550 | /* | 562 | /* |
551 | * Return was pressed. which is triggered by the keydown | 563 | * Return was pressed. which is triggered by the keydown |
552 | * handler. The problem is that the key up will be handled | 564 | * handler. The problem is that the key up will be handled |
553 | * by the ImageDisplayer and goes to the next image | 565 | * by the ImageDisplayer and goes to the next image |
554 | */ | 566 | */ |
555 | void PIconView::slotRetrun( QIconViewItem *_it ) { | 567 | void PIconView::slotRetrun( QIconViewItem *_it ) { |
556 | if(!_it ) | 568 | if(!_it ) |
557 | return; | 569 | return; |
558 | 570 | ||
559 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 571 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
560 | if( it->isDir() ) | 572 | if( it->isDir() ) |
561 | slotChangeDir( it->path() ); | 573 | slotChangeDir( it->path() ); |
562 | else | 574 | else |
563 | QTimer::singleShot(0, this, SLOT(slotShowImage()) ); | 575 | QTimer::singleShot(0, this, SLOT(slotShowImage()) ); |
564 | } | 576 | } |
565 | 577 | ||
566 | /* | 578 | /* |
567 | * got thumb info add to the cache if items is visible | 579 | * got thumb info add to the cache if items is visible |
568 | * we later need update after processing of slave is done | 580 | * we later need update after processing of slave is done |
569 | */ | 581 | */ |
570 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { | 582 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { |
571 | IconViewItem* item = g_stringInf[_path]; | 583 | IconViewItem* item = g_stringInf[_path]; |
572 | if (!item ) | 584 | if (!item ) |
573 | return; | 585 | return; |
574 | 586 | ||
575 | if (m_mode == 2) { | 587 | if (m_mode == 2) { |
576 | return; | 588 | return; |
577 | } | 589 | } |
578 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 590 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
579 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 591 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
580 | m_updatet = true; | 592 | m_updatet = true; |
581 | 593 | ||
582 | item->setText( str ); | 594 | item->setText( str ); |
583 | g_stringInf.remove( _path ); | 595 | g_stringInf.remove( _path ); |
584 | } | 596 | } |
585 | 597 | ||
586 | /* | 598 | /* |
587 | * got thumbnail and see if it is visible so we need to update later | 599 | * got thumbnail and see if it is visible so we need to update later |
588 | */ | 600 | */ |
589 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { | 601 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { |
590 | IconViewItem* item = g_stringPix[_path]; | 602 | IconViewItem* item = g_stringPix[_path]; |
591 | if (!item ) | 603 | if (!item ) |
592 | return; | 604 | return; |
593 | 605 | ||
594 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 606 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
595 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 607 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
596 | m_updatet = true; | 608 | m_updatet = true; |
597 | 609 | ||
598 | if (pix.width()>0) { | 610 | if (pix.width()>0) { |
599 | if (pix.width()<m_iconsize) { | 611 | if (pix.width()<m_iconsize) { |
600 | QPixmap p(m_iconsize,m_iconsize); | 612 | QPixmap p(m_iconsize,m_iconsize); |
601 | p.fill(); | 613 | p.fill(); |
602 | QPainter pa(&p); | 614 | QPainter pa(&p); |
603 | int offset = (m_iconsize-pix.width())/2; | 615 | int offset = (m_iconsize-pix.width())/2; |
604 | int offy = (m_iconsize-pix.height())/2; | 616 | int offy = (m_iconsize-pix.height())/2; |
605 | if (offy<0) offy=0; | 617 | if (offy<0) offy=0; |
606 | pa.drawPixmap(offset,offy,pix); | 618 | pa.drawPixmap(offset,offy,pix); |
607 | pa.end(); | 619 | pa.end(); |
608 | PPixmapCache::self()->insertImage( _path, p, m_iconsize, m_iconsize ); | 620 | PPixmapCache::self()->insertImage( _path, p, m_iconsize, m_iconsize ); |
609 | item->setPixmap(p,true); | 621 | item->setPixmap(p,true); |
610 | } else { | 622 | } else { |
611 | PPixmapCache::self()->insertImage( _path, pix, m_iconsize, m_iconsize ); | 623 | PPixmapCache::self()->insertImage( _path, pix, m_iconsize, m_iconsize ); |
612 | item->setPixmap(pix,true); | 624 | item->setPixmap(pix,true); |
613 | } | 625 | } |
614 | 626 | ||
615 | } else { | 627 | } else { |
616 | PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), m_iconsize, m_iconsize ); | 628 | PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), m_iconsize, m_iconsize ); |
617 | } | 629 | } |
618 | g_stringPix.remove( _path ); | 630 | g_stringPix.remove( _path ); |
619 | m_view->arrangeItemsInGrid(true); | 631 | m_view->arrangeItemsInGrid(true); |
620 | } | 632 | } |
621 | 633 | ||
622 | 634 | ||
623 | /* | 635 | /* |
624 | * FIXME rename | 636 | * FIXME rename |
625 | */ | 637 | */ |
626 | void PIconView::slotRename() { | 638 | void PIconView::slotRename() { |
627 | 639 | ||
628 | } | 640 | } |
629 | 641 | ||
630 | 642 | ||
631 | /* | 643 | /* |
632 | * BEAM the current file | 644 | * BEAM the current file |
633 | */ | 645 | */ |
634 | void PIconView::slotBeam() { | 646 | void PIconView::slotBeam() { |
635 | bool isDir; | 647 | bool isDir; |
636 | QString pa = currentFileName( isDir ); | 648 | QString pa = currentFileName( isDir ); |
637 | if ( isDir && pa.isEmpty() ) | 649 | if ( isDir && pa.isEmpty() ) |
638 | return; | 650 | return; |
639 | 651 | ||
640 | Ir* ir = new Ir( this ); | 652 | Ir* ir = new Ir( this ); |
641 | connect( ir, SIGNAL(done(Ir*)), | 653 | connect( ir, SIGNAL(done(Ir*)), |
642 | this, SLOT(slotBeamDone(Ir*))); | 654 | this, SLOT(slotBeamDone(Ir*))); |
643 | ir->send(pa, tr( "Image" ) ); | 655 | ir->send(pa, tr( "Image" ) ); |
644 | } | 656 | } |
645 | 657 | ||
646 | /* | 658 | /* |
647 | * BEAM done clean up | 659 | * BEAM done clean up |
648 | */ | 660 | */ |
649 | void PIconView::slotBeamDone( Ir* ir) { | 661 | void PIconView::slotBeamDone( Ir* ir) { |
650 | delete ir; | 662 | delete ir; |
651 | } | 663 | } |
652 | 664 | ||
653 | void PIconView::slotStart() { | 665 | void PIconView::slotStart() { |
654 | m_view->viewport()->setUpdatesEnabled( false ); | 666 | m_view->viewport()->setUpdatesEnabled( false ); |
655 | } | 667 | } |
656 | 668 | ||
657 | void PIconView::slotEnd() { | 669 | void PIconView::slotEnd() { |
658 | if ( m_updatet ) | 670 | if ( m_updatet ) |
659 | m_view->arrangeItemsInGrid( ); | 671 | m_view->arrangeItemsInGrid( ); |
660 | m_view->viewport()->setUpdatesEnabled( true ); | 672 | m_view->viewport()->setUpdatesEnabled( true ); |
661 | m_updatet = false; | 673 | m_updatet = false; |
662 | } | 674 | } |
663 | 675 | ||
664 | void PIconView::slotShowLast() | 676 | void PIconView::slotShowLast() |
665 | { | 677 | { |
666 | QIconViewItem* last_it = m_view->lastItem(); | 678 | QIconViewItem* last_it = m_view->lastItem(); |
667 | if (!last_it) return; | 679 | if (!last_it) return; |
668 | m_view->setCurrentItem(last_it); | 680 | m_view->setCurrentItem(last_it); |
669 | IconViewItem* it = static_cast<IconViewItem*>( last_it ); | 681 | IconViewItem* it = static_cast<IconViewItem*>( last_it ); |
670 | bool isDir = it->isDir(); | 682 | bool isDir = it->isDir(); |
671 | QString name = it->path(); | 683 | QString name = it->path(); |
672 | if (!isDir && !name.isEmpty()) { | 684 | if (!isDir && !name.isEmpty()) { |
673 | slotShowImage(name); | 685 | slotShowImage(name); |
674 | return; | 686 | return; |
675 | } | 687 | } |
676 | bool first_loop = true; | 688 | bool first_loop = true; |
677 | while(isDir==true) { | 689 | while(isDir==true) { |
678 | if (!first_loop) { | 690 | if (!first_loop) { |
679 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | 691 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); |
680 | } else { | 692 | } else { |
681 | first_loop = false; | 693 | first_loop = false; |
682 | } | 694 | } |
683 | name = prevFileName(isDir); | 695 | name = prevFileName(isDir); |
684 | } | 696 | } |
685 | 697 | ||
686 | if (name.isEmpty()) return; | 698 | if (name.isEmpty()) return; |
687 | /* if we got a name we have a prev item */ | 699 | /* if we got a name we have a prev item */ |
688 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | 700 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); |
689 | slotShowImage(name); | 701 | slotShowImage(name); |
690 | } | 702 | } |
691 | 703 | ||
692 | bool PIconView::slotShowFirst() | 704 | bool PIconView::slotShowFirst() |
693 | { | 705 | { |
694 | /* stop when reached - otherwise we may get an endless loop */ | 706 | /* stop when reached - otherwise we may get an endless loop */ |
695 | QIconViewItem* first_it = m_view->firstItem(); | 707 | QIconViewItem* first_it = m_view->firstItem(); |
696 | if (!first_it) return false; | 708 | if (!first_it) return false; |
697 | m_view->setCurrentItem(first_it); | 709 | m_view->setCurrentItem(first_it); |
698 | IconViewItem* it = static_cast<IconViewItem*>( first_it ); | 710 | IconViewItem* it = static_cast<IconViewItem*>( first_it ); |
699 | bool isDir = it->isDir(); | 711 | bool isDir = it->isDir(); |
700 | QString name = it->path(); | 712 | QString name = it->path(); |
701 | if (!isDir && !name.isEmpty()) { | 713 | if (!isDir && !name.isEmpty()) { |
702 | slotShowImage(name); | 714 | slotShowImage(name); |
703 | return false; | 715 | return false; |
704 | } | 716 | } |
705 | bool first_loop = true; | 717 | bool first_loop = true; |
706 | while(isDir==true) { | 718 | while(isDir==true) { |
707 | /* if name is empty isDir is false, too. */ | 719 | /* if name is empty isDir is false, too. */ |
708 | if (!first_loop) { | 720 | if (!first_loop) { |
709 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 721 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
710 | } else { | 722 | } else { |
711 | first_loop = false; | 723 | first_loop = false; |
712 | } | 724 | } |
713 | name = nextFileName(isDir); | 725 | name = nextFileName(isDir); |
714 | } | 726 | } |
715 | if (name.isEmpty()) return false; | 727 | if (name.isEmpty()) return false; |
716 | /* if we got a name we have a next item */ | 728 | /* if we got a name we have a next item */ |
717 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 729 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
718 | slotShowImage(name); | 730 | slotShowImage(name); |
719 | return true; | 731 | return true; |
720 | } | 732 | } |
721 | 733 | ||
722 | void PIconView::slotShowNext() | 734 | void PIconView::slotShowNext() |
723 | { | 735 | { |
724 | bool isDir = false; | 736 | bool isDir = false; |
725 | QString name = nextFileName(isDir); | 737 | QString name = nextFileName(isDir); |
726 | while (isDir==true) { | 738 | while (isDir==true) { |
727 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 739 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
728 | name = nextFileName(isDir); | 740 | name = nextFileName(isDir); |
729 | } | 741 | } |
730 | if (name.isEmpty()) { | 742 | if (name.isEmpty()) { |
731 | slotShowFirst(); | 743 | slotShowFirst(); |
732 | return; | 744 | return; |
733 | } | 745 | } |
734 | if (isDir) return; | 746 | if (isDir) return; |
735 | /* if we got a name we have a next item */ | 747 | /* if we got a name we have a next item */ |
736 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); | 748 | m_view->setCurrentItem(m_view->currentItem()->nextItem()); |
737 | slotShowImage(name); | 749 | slotShowImage(name); |
738 | } | 750 | } |
739 | 751 | ||
740 | void PIconView::slotShowPrev() | 752 | void PIconView::slotShowPrev() |
741 | { | 753 | { |
742 | bool isDir = false; | 754 | bool isDir = false; |
743 | QString name = prevFileName(isDir); | 755 | QString name = prevFileName(isDir); |
744 | while (isDir==true) { | 756 | while (isDir==true) { |
745 | /* if name is empty isDir is false, too. */ | 757 | /* if name is empty isDir is false, too. */ |
746 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | 758 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); |
747 | name = prevFileName(isDir); | 759 | name = prevFileName(isDir); |
748 | } | 760 | } |
749 | if (name.isEmpty()) { | 761 | if (name.isEmpty()) { |
750 | slotShowLast(); | 762 | slotShowLast(); |
751 | return; | 763 | return; |
752 | } | 764 | } |
753 | if (isDir) return; | 765 | if (isDir) return; |
754 | /* if we got a name we have a prev item */ | 766 | /* if we got a name we have a prev item */ |
755 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); | 767 | m_view->setCurrentItem(m_view->currentItem()->prevItem()); |
756 | slotShowImage(name); | 768 | slotShowImage(name); |
757 | } | 769 | } |
758 | 770 | ||
759 | void PIconView::slotShowImage() | 771 | void PIconView::slotShowImage() |
760 | { | 772 | { |
761 | bool isDir = false; | 773 | bool isDir = false; |
762 | QString name = currentFileName(isDir); | 774 | QString name = currentFileName(isDir); |
763 | if (isDir) return; | 775 | if (isDir) return; |
764 | slotShowImage( name ); | 776 | slotShowImage( name ); |
765 | } | 777 | } |
766 | void PIconView::slotShowImage( const QString& name) { | 778 | void PIconView::slotShowImage( const QString& name) { |
767 | PDirLister *lister = currentView()->dirLister(); | 779 | PDirLister *lister = currentView()->dirLister(); |
768 | QString r_name = lister->nameToFname(name); | 780 | QString r_name = lister->nameToFname(name); |
769 | emit sig_display(r_name); | 781 | emit sig_display(r_name); |
770 | } | 782 | } |
771 | 783 | ||
772 | void PIconView::slotStartSlide() { | 784 | void PIconView::slotStartSlide() { |
773 | bool isDir = false; | 785 | bool isDir = false; |
774 | QString name = currentFileName(isDir); | 786 | QString name = currentFileName(isDir); |
775 | if (isDir) { | 787 | if (isDir) { |
776 | if (!slotShowFirst()) | 788 | if (!slotShowFirst()) |
777 | return; | 789 | return; |
778 | } else { | 790 | } else { |
779 | slotShowImage( name ); | 791 | slotShowImage( name ); |
780 | } | 792 | } |
781 | int t = m_cfg->readNumEntry("slideshowtimeout", 2); | 793 | int t = m_cfg->readNumEntry("slideshowtimeout", 2); |
782 | emit sig_startslide(t); | 794 | emit sig_startslide(t); |
783 | } | 795 | } |
784 | 796 | ||
785 | void PIconView::slotImageInfo() { | 797 | void PIconView::slotImageInfo() { |
786 | bool isDir = false; | 798 | bool isDir = false; |
787 | QString name = currentFileName(isDir); | 799 | QString name = currentFileName(isDir); |
788 | if (isDir) return; | 800 | if (isDir) return; |
789 | slotImageInfo( name ); | 801 | slotImageInfo( name ); |
790 | } | 802 | } |
791 | 803 | ||
792 | void PIconView::slotImageInfo( const QString& name) { | 804 | void PIconView::slotImageInfo( const QString& name) { |
793 | PDirLister *lister = currentView()->dirLister(); | 805 | PDirLister *lister = currentView()->dirLister(); |
794 | QString r_name = lister->nameToFname(name); | 806 | QString r_name = lister->nameToFname(name); |
795 | emit sig_showInfo(r_name ); | 807 | emit sig_showInfo(r_name ); |
796 | } | 808 | } |
797 | 809 | ||
798 | 810 | ||
799 | void PIconView::slotChangeMode( int mode ) { | 811 | void PIconView::slotChangeMode( int mode ) { |
800 | if ( mode >= 1 && mode <= 3 ) { | 812 | if ( mode >= 1 && mode <= 3 ) { |
801 | m_mode = mode; | 813 | m_mode = mode; |
802 | m_cfg->writeEntry("ListViewMode", m_mode); | 814 | m_cfg->writeEntry("ListViewMode", m_mode); |
803 | /* performance! */ | 815 | /* performance! */ |
804 | m_view->clear(); | 816 | m_view->clear(); |
805 | if (m_mode >1) { | 817 | if (m_mode >1) { |
806 | m_view->setResizeMode(QIconView::Adjust); | 818 | m_view->setResizeMode(QIconView::Adjust); |
807 | } else { | 819 | } else { |
808 | m_view->setResizeMode(QIconView::Fixed); | 820 | m_view->setResizeMode(QIconView::Fixed); |
809 | } | 821 | } |
810 | if (m_mode==1) { | 822 | if (m_mode==1) { |
811 | m_iconsize = 64; | 823 | m_iconsize = 64; |
812 | } else { | 824 | } else { |
813 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); | 825 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); |
814 | if (m_iconsize<12)m_iconsize = 12; | 826 | if (m_iconsize<12)m_iconsize = 12; |
815 | if (m_iconsize>64)m_iconsize = 64; | 827 | if (m_iconsize>64)m_iconsize = 64; |
816 | } | 828 | } |
817 | if (_dirPix){ | 829 | if (_dirPix){ |
818 | delete _dirPix; | 830 | delete _dirPix; |
819 | _dirPix = 0; | 831 | _dirPix = 0; |
820 | } | 832 | } |
821 | if (_cpyPix){ | 833 | if (_cpyPix){ |
822 | delete _cpyPix; | 834 | delete _cpyPix; |
823 | _cpyPix = 0; | 835 | _cpyPix = 0; |
824 | } | 836 | } |
825 | calculateGrid(); | 837 | calculateGrid(); |
826 | slotReloadDir(); | 838 | slotReloadDir(); |
827 | } | 839 | } |
828 | } | 840 | } |
829 | 841 | ||
830 | 842 | ||
831 | void PIconView::resizeEvent( QResizeEvent* re ) { | 843 | void PIconView::resizeEvent( QResizeEvent* re ) { |
832 | calculateGrid(re); | 844 | calculateGrid(re); |
833 | QVBox::resizeEvent( re ); | 845 | QVBox::resizeEvent( re ); |
834 | //calculateGrid(); | 846 | //calculateGrid(); |
835 | } | 847 | } |
836 | 848 | ||
837 | 849 | ||
838 | void PIconView::calculateGrid(QResizeEvent* re) | 850 | void PIconView::calculateGrid(QResizeEvent* re) |
839 | { | 851 | { |
840 | int viewerWidth; | 852 | int viewerWidth; |
841 | if (re) { | 853 | if (re) { |
842 | viewerWidth=re->size().width(); | 854 | viewerWidth=re->size().width(); |
843 | } else { | 855 | } else { |
844 | int dw = QApplication::desktop()->width(); | 856 | int dw = QApplication::desktop()->width(); |
845 | viewerWidth = dw-style().scrollBarExtent().width(); | 857 | viewerWidth = dw-style().scrollBarExtent().width(); |
846 | } | 858 | } |
847 | 859 | ||
848 | QIconView::ItemTextPos pos; | 860 | QIconView::ItemTextPos pos; |
849 | switch( m_mode ) { | 861 | switch( m_mode ) { |
850 | case 2: | 862 | case 2: |
851 | pos = QIconView::Bottom; | 863 | pos = QIconView::Bottom; |
852 | break; | 864 | break; |
853 | case 3: | 865 | case 3: |
854 | case 1: | 866 | case 1: |
855 | default: | 867 | default: |
856 | pos = QIconView::Right; | 868 | pos = QIconView::Right; |
857 | break; | 869 | break; |
858 | } | 870 | } |
859 | int cache = 0; | 871 | int cache = 0; |
860 | m_view->setItemTextPos( pos ); | 872 | m_view->setItemTextPos( pos ); |
861 | switch (m_mode) { | 873 | switch (m_mode) { |
862 | case 2: | 874 | case 2: |
863 | m_view->setSpacing(2); | 875 | m_view->setSpacing(2); |
864 | m_view->setGridX(m_iconsize); | 876 | m_view->setGridX(m_iconsize); |
865 | m_view->setGridY(-1); | 877 | m_view->setGridY(-1); |
866 | cache = (int)((double)64/(double)m_iconsize*40.0); | 878 | cache = (int)((double)64/(double)m_iconsize*40.0); |
867 | odebug << "cache size: " << cache << oendl; | 879 | odebug << "cache size: " << cache << oendl; |
868 | PPixmapCache::self()->setMaxImages(cache); | 880 | PPixmapCache::self()->setMaxImages(cache); |
869 | break; | 881 | break; |
870 | case 3: | 882 | case 3: |
871 | m_view->setSpacing(10); | 883 | m_view->setSpacing(10); |
872 | m_view->setGridX( fontMetrics().width("testimage.jpg")+20); | 884 | m_view->setGridX( fontMetrics().width("testimage.jpg")+20); |
873 | m_view->setGridY(8); | 885 | m_view->setGridY(8); |
874 | PPixmapCache::self()->setMaxImages(2); | 886 | PPixmapCache::self()->setMaxImages(2); |
875 | break; | 887 | break; |
876 | case 1: | 888 | case 1: |
877 | default: | 889 | default: |
878 | m_view->setSpacing(10); | 890 | m_view->setSpacing(10); |
879 | m_view->setGridX( viewerWidth-3*m_view->spacing()); | 891 | m_view->setGridX( viewerWidth-3*m_view->spacing()); |
880 | m_view->setGridY( fontMetrics().height()*2+40 ); | 892 | m_view->setGridY( fontMetrics().height()*2+40 ); |
881 | PPixmapCache::self()->setMaxImages(20); | 893 | PPixmapCache::self()->setMaxImages(20); |
882 | break; | 894 | break; |
883 | } | 895 | } |
884 | } | 896 | } |
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h index b018c51..78dda58 100644 --- a/noncore/graphics/opie-eye/gui/iconview.h +++ b/noncore/graphics/opie-eye/gui/iconview.h | |||
@@ -1,102 +1,104 @@ | |||
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,SlideItem | 30 | BeamItem, DeleteItem, ViewItem, InfoItem,SlideItem |
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 | void sig_startslide(int timeout); | 41 | void sig_startslide(int timeout); |
42 | 42 | ||
43 | public slots: | 43 | public slots: |
44 | virtual void slotShowNext(); | 44 | virtual void slotShowNext(); |
45 | virtual void slotShowPrev(); | 45 | virtual void slotShowPrev(); |
46 | virtual void slotShowLast(); | 46 | virtual void slotShowLast(); |
47 | virtual bool slotShowFirst(); | 47 | virtual bool slotShowFirst(); |
48 | 48 | ||
49 | protected: | 49 | protected: |
50 | void resizeEvent( QResizeEvent* ); | 50 | void resizeEvent( QResizeEvent* ); |
51 | 51 | ||
52 | private: | 52 | private: |
53 | void initKeys(); | 53 | void initKeys(); |
54 | QString currentFileName(bool &isDir)const; | 54 | QString currentFileName(bool &isDir)const; |
55 | QString nextFileName(bool &isDir)const; | 55 | QString nextFileName(bool &isDir)const; |
56 | QString prevFileName(bool &isDir)const; | 56 | QString prevFileName(bool &isDir)const; |
57 | void loadViews(); | 57 | void loadViews(); |
58 | void calculateGrid(QResizeEvent*e = 0); | 58 | void calculateGrid(QResizeEvent*e = 0); |
59 | 59 | ||
60 | private slots: | 60 | private slots: |
61 | void slotDirUp(); | 61 | void slotDirUp(); |
62 | void slotChangeDir(const QString&); | 62 | void slotChangeDir(const QString&); |
63 | void slotTrash(); | 63 | void slotTrash(); |
64 | void slotViewChanged( int ); | 64 | void slotViewChanged( int ); |
65 | void slotReloadDir(); | 65 | void slotReloadDir(); |
66 | void slotRename(); | 66 | void slotRename(); |
67 | void slotBeam(); | 67 | void slotBeam(); |
68 | void slotBeamDone( Ir* ); | 68 | void slotBeamDone( Ir* ); |
69 | 69 | ||
70 | void slotShowImage(); | 70 | void slotShowImage(); |
71 | void slotShowImage( const QString& ); | 71 | void slotShowImage( const QString& ); |
72 | void slotImageInfo(); | 72 | void slotImageInfo(); |
73 | void slotImageInfo( const QString& ); | 73 | void slotImageInfo( const QString& ); |
74 | void slotStartSlide(); | 74 | void slotStartSlide(); |
75 | 75 | ||
76 | void slotStart(); | 76 | void slotStart(); |
77 | void slotEnd(); | 77 | void slotEnd(); |
78 | 78 | ||
79 | /* for performance reasons make it inline in the future */ | 79 | /* for performance reasons make it inline in the future */ |
80 | void addFolders( const QStringList& ); | 80 | void addFolders( const QStringList& ); |
81 | void addFiles( const QStringList& ); | 81 | void addFiles( const QStringList& ); |
82 | void slotClicked(QIconViewItem* ); | 82 | void slotClicked(QIconViewItem* ); |
83 | void slotRetrun(QIconViewItem* ); | 83 | void slotRetrun(QIconViewItem* ); |
84 | 84 | ||
85 | /**/ | 85 | /**/ |
86 | void slotThumbInfo(const QString&, const QString&); | 86 | void slotThumbInfo(const QString&, const QString&); |
87 | void slotThumbNail(const QString&, const QPixmap&); | 87 | void slotThumbNail(const QString&, const QPixmap&); |
88 | 88 | ||
89 | void slotChangeMode( int ); | 89 | void slotChangeMode( int ); |
90 | private: | 90 | private: |
91 | Opie::Core::OKeyConfigManager *m_viewManager; | 91 | Opie::Core::OKeyConfigManager *m_viewManager; |
92 | Opie::Core::OConfig *m_cfg; | 92 | Opie::Core::OConfig *m_cfg; |
93 | QComboBox* m_views; | 93 | QComboBox* m_views; |
94 | QIconView* m_view; | 94 | QIconView* m_view; |
95 | QString m_path; | 95 | QString m_path; |
96 | bool m_updatet : 1; | 96 | bool m_updatet : 1; |
97 | int m_mode; | 97 | int m_mode; |
98 | bool m_internalReset:1; | 98 | bool m_internalReset:1; |
99 | int m_iconsize; | 99 | int m_iconsize; |
100 | QHBox*m_hbox; | ||
101 | QWidget*m_customWidget; | ||
100 | }; | 102 | }; |
101 | 103 | ||
102 | #endif | 104 | #endif |
diff --git a/noncore/graphics/opie-eye/iface/dirlister.h b/noncore/graphics/opie-eye/iface/dirlister.h index 68e8495..6997f52 100644 --- a/noncore/graphics/opie-eye/iface/dirlister.h +++ b/noncore/graphics/opie-eye/iface/dirlister.h | |||
@@ -1,52 +1,53 @@ | |||
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_DIR_LISTER_H | 6 | #ifndef PHUNK_DIR_LISTER_H |
7 | #define PHUNK_DIR_LISTER_H | 7 | #define PHUNK_DIR_LISTER_H |
8 | 8 | ||
9 | #include <qobject.h> | 9 | #include <qobject.h> |
10 | #include <qstring.h> | 10 | #include <qstring.h> |
11 | #include <qstringlist.h> | 11 | #include <qstringlist.h> |
12 | 12 | ||
13 | 13 | ||
14 | class PDirLister : public QObject { | 14 | class PDirLister : public QObject { |
15 | Q_OBJECT | 15 | Q_OBJECT |
16 | public: | 16 | public: |
17 | enum Factor { Width, Height, None }; | 17 | enum Factor { Width, Height, None }; |
18 | 18 | ||
19 | PDirLister( const char* name ); | 19 | PDirLister( const char* name ); |
20 | 20 | ||
21 | virtual QString defaultPath()const = 0; | 21 | virtual QString defaultPath()const = 0; |
22 | virtual QString setStartPath( const QString& ) = 0; | 22 | virtual QString setStartPath( const QString& ) = 0; |
23 | virtual QString currentPath()const = 0; | 23 | virtual QString currentPath()const = 0; |
24 | virtual QStringList folders()const = 0; | 24 | virtual QStringList folders()const = 0; |
25 | virtual QStringList files()const = 0; | 25 | virtual QStringList files()const = 0; |
26 | virtual QString nameToFname(const QString&name)const = 0; | 26 | virtual QString nameToFname(const QString&name)const = 0; |
27 | virtual QString dirUp(const QString&)const ; | 27 | virtual QString dirUp(const QString&)const ; |
28 | 28 | ||
29 | 29 | ||
30 | public slots: | 30 | public slots: |
31 | virtual void deleteImage( const QString& ) = 0; | 31 | virtual void deleteImage( const QString& ) = 0; |
32 | virtual void imageInfo( const QString&) = 0; | 32 | virtual void imageInfo( const QString&) = 0; |
33 | virtual void fullImageInfo( const QString& ) = 0; | 33 | virtual void fullImageInfo( const QString& ) = 0; |
34 | virtual void thumbNail( const QString&, int max_wid, int max_h ) = 0; | 34 | virtual void thumbNail( const QString&, int max_wid, int max_h ) = 0; |
35 | virtual QImage image( const QString&, Factor, int max = 0) = 0; | 35 | virtual QImage image( const QString&, Factor, int max = 0) = 0; |
36 | 36 | ||
37 | 37 | ||
38 | signals: | 38 | signals: |
39 | void sig_dirchanged(); | 39 | void sig_dirchanged(); |
40 | void sig_filechanged(); | 40 | void sig_filechanged(); |
41 | void sig_start(); | 41 | void sig_start(); |
42 | void sig_end(); | 42 | void sig_end(); |
43 | // If this app ever happens to get multithreaded... | 43 | // If this app ever happens to get multithreaded... |
44 | void sig_thumbInfo( const QString&, const QString& ); | 44 | void sig_thumbInfo( const QString&, const QString& ); |
45 | void sig_fullInfo( const QString&, const QString& ); | 45 | void sig_fullInfo( const QString&, const QString& ); |
46 | void sig_thumbNail( const QString&, const QPixmap& ); | 46 | void sig_thumbNail( const QString&, const QPixmap& ); |
47 | void sig_reloadDir(); | ||
47 | 48 | ||
48 | protected: | 49 | protected: |
49 | virtual ~PDirLister(); | 50 | virtual ~PDirLister(); |
50 | }; | 51 | }; |
51 | 52 | ||
52 | #endif | 53 | #endif |
diff --git a/noncore/graphics/opie-eye/iface/dirview.h b/noncore/graphics/opie-eye/iface/dirview.h index 20d9062..3c05b60 100644 --- a/noncore/graphics/opie-eye/iface/dirview.h +++ b/noncore/graphics/opie-eye/iface/dirview.h | |||
@@ -1,40 +1,42 @@ | |||
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_DIR_VIEW_H | 6 | #ifndef PHUNK_DIR_VIEW_H |
7 | #define PHUNK_DIR_VIEW_H | 7 | #define PHUNK_DIR_VIEW_H |
8 | 8 | ||
9 | #include <qmap.h> | 9 | #include <qmap.h> |
10 | 10 | ||
11 | #include <qpe/config.h> | 11 | #include <qpe/config.h> |
12 | 12 | ||
13 | class PInterfaceInfo; | 13 | class PInterfaceInfo; |
14 | class PDirLister; | 14 | class PDirLister; |
15 | class QWidget; | ||
15 | 16 | ||
16 | struct PDirView { | 17 | struct PDirView { |
17 | PDirView( const Config& ); | 18 | PDirView( const Config& ); |
18 | virtual ~PDirView(); | 19 | virtual ~PDirView(); |
19 | virtual PInterfaceInfo* interfaceInfo()const = 0; | 20 | virtual PInterfaceInfo* interfaceInfo()const = 0; |
20 | virtual PDirLister* dirLister()const = 0; | 21 | virtual PDirLister* dirLister()const = 0; |
22 | virtual QWidget* widget(QWidget*)=0; | ||
21 | }; | 23 | }; |
22 | 24 | ||
23 | typedef PDirView* (*phunkViewCreateFunc )(const Config& ); | 25 | typedef PDirView* (*phunkViewCreateFunc )(const Config& ); |
24 | typedef QMap<QString,phunkViewCreateFunc> ViewMap; | 26 | typedef QMap<QString,phunkViewCreateFunc> ViewMap; |
25 | 27 | ||
26 | ViewMap* viewMap(); | 28 | ViewMap* viewMap(); |
27 | PDirView* currentView(); | 29 | PDirView* currentView(); |
28 | void setCurrentView( PDirView* ); | 30 | void setCurrentView( PDirView* ); |
29 | 31 | ||
30 | 32 | ||
31 | 33 | ||
32 | #define PHUNK_VIEW_INTERFACE( NAME, IMPL ) \ | 34 | #define PHUNK_VIEW_INTERFACE( NAME, IMPL ) \ |
33 | static PDirView *create_ ## IMPL( const Config& cfg ) { \ | 35 | static PDirView *create_ ## IMPL( const Config& cfg ) { \ |
34 | return new IMPL( cfg ); \ | 36 | return new IMPL( cfg ); \ |
35 | } \ | 37 | } \ |
36 | static ViewMap::Iterator dummy_ ## IMPL = viewMap()->insert( NAME, create_ ## IMPL ); | 38 | static ViewMap::Iterator dummy_ ## IMPL = viewMap()->insert( NAME, create_ ## IMPL ); |
37 | 39 | ||
38 | 40 | ||
39 | 41 | ||
40 | #endif | 42 | #endif |
diff --git a/noncore/graphics/opie-eye/impl/dcim/dcim_dirview.cpp b/noncore/graphics/opie-eye/impl/dcim/dcim_dirview.cpp index e55c27a..3f6044f 100644 --- a/noncore/graphics/opie-eye/impl/dcim/dcim_dirview.cpp +++ b/noncore/graphics/opie-eye/impl/dcim/dcim_dirview.cpp | |||
@@ -1,28 +1,33 @@ | |||
1 | #include "dcim_dirview.h" | 1 | #include "dcim_dirview.h" |
2 | 2 | ||
3 | #include "dcim_lister.h" | 3 | #include "dcim_lister.h" |
4 | #include "dcim_ifaceinfo.h" | 4 | #include "dcim_ifaceinfo.h" |
5 | 5 | ||
6 | PHUNK_VIEW_INTERFACE( "Digital Camera", DCIM_DirView ); | 6 | PHUNK_VIEW_INTERFACE( "Digital Camera", DCIM_DirView ); |
7 | 7 | ||
8 | DCIM_DirView::DCIM_DirView( const Config& cfg ) | 8 | DCIM_DirView::DCIM_DirView( const Config& cfg ) |
9 | : PDirView( cfg ), m_lister( 0l ), m_info( 0l ) | 9 | : PDirView( cfg ), m_lister( 0l ), m_info( 0l ) |
10 | {} | 10 | {} |
11 | 11 | ||
12 | DCIM_DirView::~DCIM_DirView() | 12 | DCIM_DirView::~DCIM_DirView() |
13 | {} | 13 | {} |
14 | 14 | ||
15 | PInterfaceInfo* DCIM_DirView::interfaceInfo()const { | 15 | PInterfaceInfo* DCIM_DirView::interfaceInfo()const { |
16 | if ( !m_info ) | 16 | if ( !m_info ) |
17 | m_info = new DCIM_InterfaceInfo; | 17 | m_info = new DCIM_InterfaceInfo; |
18 | 18 | ||
19 | return m_info; | 19 | return m_info; |
20 | } | 20 | } |
21 | 21 | ||
22 | 22 | ||
23 | PDirLister* DCIM_DirView::dirLister()const { | 23 | PDirLister* DCIM_DirView::dirLister()const { |
24 | if ( !m_lister ) | 24 | if ( !m_lister ) |
25 | m_lister = new DCIM_DirLister(); | 25 | m_lister = new DCIM_DirLister(); |
26 | 26 | ||
27 | return m_lister; | 27 | return m_lister; |
28 | } | 28 | } |
29 | |||
30 | QWidget* DCIM_DirView::widget(QWidget*) | ||
31 | { | ||
32 | return 0L; | ||
33 | } | ||
diff --git a/noncore/graphics/opie-eye/impl/dcim/dcim_dirview.h b/noncore/graphics/opie-eye/impl/dcim/dcim_dirview.h index 7fc38ec..8394b34 100644 --- a/noncore/graphics/opie-eye/impl/dcim/dcim_dirview.h +++ b/noncore/graphics/opie-eye/impl/dcim/dcim_dirview.h | |||
@@ -1,26 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 only zecke@handhelds.org | 2 | * GPLv2 only zecke@handhelds.org |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #ifndef DCIM_DIR_VIEW_H | 5 | #ifndef DCIM_DIR_VIEW_H |
6 | #define DCIM_DIR_VIEW_H | 6 | #define DCIM_DIR_VIEW_H |
7 | 7 | ||
8 | #include <iface/dirview.h> | 8 | #include <iface/dirview.h> |
9 | 9 | ||
10 | /* | 10 | /* |
11 | * Implementation for USB Host Digital Cameras | 11 | * Implementation for USB Host Digital Cameras |
12 | * like my Casio QV 500 and boring Yakumo | 12 | * like my Casio QV 500 and boring Yakumo |
13 | */ | 13 | */ |
14 | struct DCIM_DirView : public PDirView { | 14 | struct DCIM_DirView : public PDirView { |
15 | DCIM_DirView( const Config& ); | 15 | DCIM_DirView( const Config& ); |
16 | ~DCIM_DirView(); | 16 | ~DCIM_DirView(); |
17 | 17 | ||
18 | PInterfaceInfo* interfaceInfo()const; | 18 | PInterfaceInfo* interfaceInfo()const; |
19 | PDirLister * dirLister ()const; | 19 | PDirLister * dirLister ()const; |
20 | 20 | virtual QWidget* widget(QWidget*); | |
21 | private: | 21 | private: |
22 | mutable PDirLister *m_lister; | 22 | mutable PDirLister *m_lister; |
23 | mutable PInterfaceInfo *m_info ; | 23 | mutable PInterfaceInfo *m_info ; |
24 | }; | 24 | }; |
25 | 25 | ||
26 | #endif | 26 | #endif |
diff --git a/noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp b/noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp index fc502d4..9c2c840 100644 --- a/noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp +++ b/noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp | |||
@@ -1,33 +1,38 @@ | |||
1 | #include "dir_lister.h" | 1 | #include "dir_lister.h" |
2 | #include "dir_ifaceinfo.h" | 2 | #include "dir_ifaceinfo.h" |
3 | #include "dir_dirview.h" | 3 | #include "dir_dirview.h" |
4 | 4 | ||
5 | PHUNK_VIEW_INTERFACE("Dir View", Dir_DirView ); | 5 | PHUNK_VIEW_INTERFACE("Dir View", Dir_DirView ); |
6 | 6 | ||
7 | 7 | ||
8 | Dir_DirView::Dir_DirView( const Config& cfg) | 8 | Dir_DirView::Dir_DirView( const Config& cfg) |
9 | : PDirView(cfg) | 9 | : PDirView(cfg) |
10 | { | 10 | { |
11 | m_cfg = cfg.readBoolEntry( "Dir_Check_All_Files", false); | 11 | m_cfg = cfg.readBoolEntry( "Dir_Check_All_Files", false); |
12 | m_recursive = cfg.readBoolEntry( "Dir_Check_Recursive_Files", false); | 12 | m_recursive = cfg.readBoolEntry( "Dir_Check_Recursive_Files", false); |
13 | m_recursive_depth = cfg.readNumEntry("Dir_Recursive_Files_Depth",10); | 13 | m_recursive_depth = cfg.readNumEntry("Dir_Recursive_Files_Depth",10); |
14 | m_lister = 0; | 14 | m_lister = 0; |
15 | m_info = 0; | 15 | m_info = 0; |
16 | } | 16 | } |
17 | 17 | ||
18 | Dir_DirView::~Dir_DirView() { | 18 | Dir_DirView::~Dir_DirView() { |
19 | } | 19 | } |
20 | 20 | ||
21 | PInterfaceInfo* Dir_DirView::interfaceInfo()const{ | 21 | PInterfaceInfo* Dir_DirView::interfaceInfo()const{ |
22 | if (!m_info ) { | 22 | if (!m_info ) { |
23 | m_info = new DirInterfaceInfo; | 23 | m_info = new DirInterfaceInfo; |
24 | } | 24 | } |
25 | return m_info; | 25 | return m_info; |
26 | } | 26 | } |
27 | 27 | ||
28 | PDirLister* Dir_DirView::dirLister()const{ | 28 | PDirLister* Dir_DirView::dirLister()const{ |
29 | if (!m_lister ) { | 29 | if (!m_lister ) { |
30 | m_lister = new Dir_DirLister(m_cfg,m_recursive,m_recursive_depth); | 30 | m_lister = new Dir_DirLister(m_cfg,m_recursive,m_recursive_depth); |
31 | } | 31 | } |
32 | return m_lister; | 32 | return m_lister; |
33 | } | 33 | } |
34 | |||
35 | QWidget* Dir_DirView::widget(QWidget*) | ||
36 | { | ||
37 | return 0L; | ||
38 | } \ No newline at end of file | ||
diff --git a/noncore/graphics/opie-eye/impl/dir/dir_dirview.h b/noncore/graphics/opie-eye/impl/dir/dir_dirview.h index 89cf6c9..ae53a5c 100644 --- a/noncore/graphics/opie-eye/impl/dir/dir_dirview.h +++ b/noncore/graphics/opie-eye/impl/dir/dir_dirview.h | |||
@@ -1,26 +1,27 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 only zecke@handhelds.org | 2 | * GPLv2 only zecke@handhelds.org |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #ifndef DIR_DIR_VIEW_H | 5 | #ifndef DIR_DIR_VIEW_H |
6 | #define DIR_DIR_VIEW_H | 6 | #define DIR_DIR_VIEW_H |
7 | 7 | ||
8 | #include <iface/dirview.h> | 8 | #include <iface/dirview.h> |
9 | 9 | ||
10 | 10 | ||
11 | struct Dir_DirView : public PDirView { | 11 | struct Dir_DirView : public PDirView { |
12 | Dir_DirView( const Config& ); | 12 | Dir_DirView( const Config& ); |
13 | ~Dir_DirView(); | 13 | ~Dir_DirView(); |
14 | 14 | ||
15 | PInterfaceInfo* interfaceInfo()const; | 15 | PInterfaceInfo* interfaceInfo()const; |
16 | PDirLister* dirLister()const; | 16 | PDirLister* dirLister()const; |
17 | virtual QWidget* widget(QWidget*); | ||
17 | private: | 18 | private: |
18 | bool m_cfg : 1; | 19 | bool m_cfg : 1; |
19 | bool m_recursive:1; | 20 | bool m_recursive:1; |
20 | int m_recursive_depth; | 21 | int m_recursive_depth; |
21 | mutable PDirLister* m_lister; | 22 | mutable PDirLister* m_lister; |
22 | mutable PInterfaceInfo *m_info; | 23 | mutable PInterfaceInfo *m_info; |
23 | }; | 24 | }; |
24 | 25 | ||
25 | 26 | ||
26 | #endif | 27 | #endif |
diff --git a/noncore/graphics/opie-eye/impl/doc/doc_dirview.cpp b/noncore/graphics/opie-eye/impl/doc/doc_dirview.cpp index 0d6e25f..2cc897b 100644 --- a/noncore/graphics/opie-eye/impl/doc/doc_dirview.cpp +++ b/noncore/graphics/opie-eye/impl/doc/doc_dirview.cpp | |||
@@ -1,28 +1,35 @@ | |||
1 | #include "doc_lister.h" | 1 | #include "doc_lister.h" |
2 | #include "doc_ifaceinfo.h" | 2 | #include "doc_ifaceinfo.h" |
3 | #include "doc_dirview.h" | 3 | #include "doc_dirview.h" |
4 | 4 | ||
5 | PHUNK_VIEW_INTERFACE("Document View", Doc_DirView ); | 5 | PHUNK_VIEW_INTERFACE("Document View", Doc_DirView ); |
6 | 6 | ||
7 | 7 | ||
8 | Doc_DirView::Doc_DirView( const Config& cfg) | 8 | Doc_DirView::Doc_DirView( const Config& cfg) |
9 | : PDirView(cfg) | 9 | : PDirView(cfg) |
10 | { | 10 | { |
11 | m_lister = 0; | 11 | m_lister = 0; |
12 | m_info = 0; | 12 | m_info = 0; |
13 | } | 13 | } |
14 | 14 | ||
15 | Doc_DirView::~Doc_DirView() { | 15 | Doc_DirView::~Doc_DirView() { |
16 | } | 16 | } |
17 | 17 | ||
18 | PInterfaceInfo* Doc_DirView::interfaceInfo()const{ | 18 | PInterfaceInfo* Doc_DirView::interfaceInfo()const{ |
19 | if (!m_info ) | 19 | if (!m_info ) |
20 | m_info =new DocInterfaceInfo; | 20 | m_info =new DocInterfaceInfo; |
21 | return m_info; | 21 | return m_info; |
22 | } | 22 | } |
23 | 23 | ||
24 | PDirLister* Doc_DirView::dirLister()const{ | 24 | PDirLister* Doc_DirView::dirLister()const{ |
25 | if (!m_lister ) | 25 | if (!m_lister ) |
26 | m_lister = new Doc_DirLister(); | 26 | m_lister = new Doc_DirLister(); |
27 | return m_lister; | 27 | return m_lister; |
28 | } | 28 | } |
29 | |||
30 | QWidget* Doc_DirView::widget(QWidget*parent) | ||
31 | { | ||
32 | if (!m_lister) | ||
33 | dirLister(); | ||
34 | return m_lister->widget(parent); | ||
35 | } | ||
diff --git a/noncore/graphics/opie-eye/impl/doc/doc_dirview.h b/noncore/graphics/opie-eye/impl/doc/doc_dirview.h index 3a2fd71..55ba6f2 100644 --- a/noncore/graphics/opie-eye/impl/doc/doc_dirview.h +++ b/noncore/graphics/opie-eye/impl/doc/doc_dirview.h | |||
@@ -1,24 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 only zecke@handhelds.org | 2 | * GPLv2 only zecke@handhelds.org |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #ifndef DOC_DIR_VIEW_H | 5 | #ifndef DOC_DIR_VIEW_H |
6 | #define DOC_DIR_VIEW_H | 6 | #define DOC_DIR_VIEW_H |
7 | 7 | ||
8 | #include <iface/dirview.h> | 8 | #include <iface/dirview.h> |
9 | 9 | ||
10 | class Doc_DirLister; | ||
10 | 11 | ||
11 | struct Doc_DirView : public PDirView { | 12 | struct Doc_DirView : public PDirView { |
12 | Doc_DirView( const Config& ); | 13 | Doc_DirView( const Config& ); |
13 | ~Doc_DirView(); | 14 | ~Doc_DirView(); |
14 | 15 | ||
15 | PInterfaceInfo* interfaceInfo()const; | 16 | PInterfaceInfo* interfaceInfo()const; |
16 | PDirLister* dirLister()const; | 17 | PDirLister* dirLister()const; |
18 | QWidget* widget(QWidget*parent); | ||
17 | private: | 19 | private: |
18 | bool m_cfg : 1; | 20 | bool m_cfg : 1; |
19 | mutable PDirLister* m_lister; | 21 | mutable Doc_DirLister* m_lister; |
20 | mutable PInterfaceInfo *m_info; | 22 | mutable PInterfaceInfo *m_info; |
21 | }; | 23 | }; |
22 | 24 | ||
23 | 25 | ||
24 | #endif | 26 | #endif |
diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp index 722fb95..d60149f 100644 --- a/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp +++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.cpp | |||
@@ -1,149 +1,188 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include "doc_lister.h" | 5 | #include "doc_lister.h" |
6 | 6 | ||
7 | #include <lib/slavemaster.h> | 7 | #include <lib/slavemaster.h> |
8 | 8 | ||
9 | /* OPIE */ | 9 | /* OPIE */ |
10 | #include <opie2/odebug.h> | 10 | #include <opie2/odebug.h> |
11 | #include <qpe/config.h> | 11 | #include <qpe/config.h> |
12 | #include <qpe/qpeapplication.h> | 12 | #include <qpe/qpeapplication.h> |
13 | #include <qpe/applnk.h> | 13 | #include <qpe/applnk.h> |
14 | 14 | ||
15 | #include <qtopia/private/categories.h> | ||
16 | #include <qtopia/categoryselect.h> | ||
17 | |||
15 | using namespace Opie::Core; | 18 | using namespace Opie::Core; |
16 | 19 | ||
17 | /* QT */ | 20 | /* QT */ |
18 | #include <qdir.h> | 21 | #include <qdir.h> |
19 | #include <qfileinfo.h> | 22 | #include <qfileinfo.h> |
20 | 23 | ||
21 | Doc_DirLister::Doc_DirLister() | 24 | Doc_DirLister::Doc_DirLister() |
22 | : PDirLister( "doc_dir_lister" ) | 25 | : PDirLister( "doc_dir_lister" ) |
23 | { | 26 | { |
24 | /* connect the signals */ | 27 | /* connect the signals */ |
28 | m_catFilter = 0; | ||
25 | SlaveMaster* master = SlaveMaster::self(); | 29 | SlaveMaster* master = SlaveMaster::self(); |
26 | connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) ); | 30 | connect( master, SIGNAL(sig_start()), this, SIGNAL(sig_start()) ); |
27 | connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) ); | 31 | connect( master, SIGNAL(sig_end()), this, SIGNAL(sig_end()) ); |
28 | connect( master, SIGNAL(sig_thumbInfo(const QString&, const QString&)), | 32 | connect( master, SIGNAL(sig_thumbInfo(const QString&, const QString&)), |
29 | this, SLOT(slotThumbInfo(const QString&, const QString&)) ); | 33 | this, SLOT(slotThumbInfo(const QString&, const QString&)) ); |
30 | connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), | 34 | connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)), |
31 | this, SLOT(slotFullInfo(const QString&, const QString&)) ); | 35 | this, SLOT(slotFullInfo(const QString&, const QString&)) ); |
32 | connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)), | 36 | connect( master, SIGNAL(sig_thumbNail(const QString&, const QPixmap&)), |
33 | this, SLOT(slotThumbNail(const QString&, const QPixmap&)) ); | 37 | this, SLOT(slotThumbNail(const QString&, const QPixmap&)) ); |
34 | 38 | ||
35 | m_namemap.clear(); | 39 | m_namemap.clear(); |
36 | m_filemap.clear(); | 40 | m_filemap.clear(); |
37 | } | 41 | } |
38 | 42 | ||
39 | QString Doc_DirLister::defaultPath()const { | 43 | QString Doc_DirLister::defaultPath()const { |
40 | return QString::null; | 44 | return QString::null; |
41 | } | 45 | } |
42 | 46 | ||
47 | bool Doc_DirLister::matchCat(const AppLnk* app) | ||
48 | { | ||
49 | if (!app) return false; | ||
50 | if (m_catFilter==0 || app->categories().contains(m_catFilter) || m_catFilter == -1 && app->categories().count() == 0 ) { | ||
51 | return true; | ||
52 | } | ||
53 | return false; | ||
54 | } | ||
55 | |||
43 | QString Doc_DirLister::setStartPath(const QString&) { | 56 | QString Doc_DirLister::setStartPath(const QString&) { |
44 | static const QString Mtype_str("image/jpeg;image/gif;image/bmp;image/png"); | 57 | static const QString Mtype_str("image/jpeg;image/gif;image/bmp;image/png"); |
45 | if (m_namemap.isEmpty()) { | 58 | if (m_namemap.isEmpty()) { |
46 | DocLnkSet ds; | 59 | DocLnkSet ds; |
47 | Global::findDocuments(&ds,Mtype_str); | 60 | Global::findDocuments(&ds,Mtype_str); |
48 | QListIterator<DocLnk> dit(ds.children()); | 61 | QListIterator<DocLnk> dit(ds.children()); |
49 | for( ; dit.current(); ++dit) { | 62 | for( ; dit.current(); ++dit) { |
50 | // if (! (*dit)->isValid()) continue; | 63 | if (! (*dit)->isValid()) continue; |
64 | if (!matchCat((*dit))) continue; | ||
51 | m_namemap[(*dit)->name()]=(*dit)->file(); | 65 | m_namemap[(*dit)->name()]=(*dit)->file(); |
52 | m_filemap[(*dit)->file()]=(*dit)->name(); | 66 | m_filemap[(*dit)->file()]=(*dit)->name(); |
53 | } | 67 | } |
54 | } | 68 | } |
55 | return QString::null; | 69 | return QString::null; |
56 | } | 70 | } |
57 | 71 | ||
58 | QString Doc_DirLister::currentPath()const { | 72 | QString Doc_DirLister::currentPath()const { |
59 | return QString::null; | 73 | return QString::null; |
60 | } | 74 | } |
61 | 75 | ||
62 | 76 | ||
63 | QStringList Doc_DirLister::folders()const { | 77 | QStringList Doc_DirLister::folders()const { |
64 | return QStringList(); | 78 | return QStringList(); |
65 | } | 79 | } |
66 | 80 | ||
67 | QStringList Doc_DirLister::files()const { | 81 | QStringList Doc_DirLister::files()const { |
68 | QStringList out; | 82 | QStringList out; |
69 | QMap<QString,QString>::ConstIterator it; | 83 | QMap<QString,QString>::ConstIterator it; |
70 | for (it = m_namemap.begin();it != m_namemap.end();++it) { | 84 | for (it = m_namemap.begin();it != m_namemap.end();++it) { |
71 | out.append(it.key()); | 85 | out.append(it.key()); |
72 | } | 86 | } |
73 | return out; | 87 | return out; |
74 | } | 88 | } |
75 | 89 | ||
76 | void Doc_DirLister::deleteImage( const QString& ) | 90 | void Doc_DirLister::deleteImage( const QString& ) |
77 | { | 91 | { |
78 | } | 92 | } |
79 | 93 | ||
80 | void Doc_DirLister::thumbNail( const QString& str, int w, int h) { | 94 | void Doc_DirLister::thumbNail( const QString& str, int w, int h) { |
81 | if (m_namemap.find(str)==m_namemap.end()) { | 95 | if (m_namemap.find(str)==m_namemap.end()) { |
82 | return; | 96 | return; |
83 | } | 97 | } |
84 | QString fname = m_namemap[str]; | 98 | QString fname = m_namemap[str]; |
85 | SlaveMaster::self()->thumbNail( fname, w, h ); | 99 | SlaveMaster::self()->thumbNail( fname, w, h ); |
86 | } | 100 | } |
87 | 101 | ||
88 | QImage Doc_DirLister::image( const QString& str, Factor f, int m) { | 102 | QImage Doc_DirLister::image( const QString& str, Factor f, int m) { |
89 | if (m_namemap.find(str)==m_namemap.end()) { | 103 | if (m_namemap.find(str)==m_namemap.end()) { |
90 | return QImage(); | 104 | return QImage(); |
91 | } | 105 | } |
92 | QString fname = m_namemap[str]; | 106 | QString fname = m_namemap[str]; |
93 | return SlaveMaster::self()->image( fname, f, m ); | 107 | return SlaveMaster::self()->image( fname, f, m ); |
94 | } | 108 | } |
95 | 109 | ||
96 | void Doc_DirLister::imageInfo( const QString& str) { | 110 | void Doc_DirLister::imageInfo( const QString& str) { |
97 | if (m_namemap.find(str)==m_namemap.end()) { | 111 | if (m_namemap.find(str)==m_namemap.end()) { |
98 | return; | 112 | return; |
99 | } | 113 | } |
100 | QString fname = m_namemap[str]; | 114 | QString fname = m_namemap[str]; |
101 | SlaveMaster::self()->thumbInfo( fname ); | 115 | SlaveMaster::self()->thumbInfo( fname ); |
102 | } | 116 | } |
103 | 117 | ||
104 | void Doc_DirLister::fullImageInfo( const QString& str) { | 118 | void Doc_DirLister::fullImageInfo( const QString& str) { |
105 | if (m_namemap.find(str)==m_namemap.end()) { | 119 | if (m_namemap.find(str)==m_namemap.end()) { |
106 | return; | 120 | return; |
107 | } | 121 | } |
108 | QString fname = m_namemap[str]; | 122 | QString fname = m_namemap[str]; |
109 | SlaveMaster::self()->imageInfo( fname ); | 123 | SlaveMaster::self()->imageInfo( fname ); |
110 | } | 124 | } |
111 | 125 | ||
112 | void Doc_DirLister::slotFullInfo(const QString&f, const QString&t) | 126 | void Doc_DirLister::slotFullInfo(const QString&f, const QString&t) |
113 | { | 127 | { |
114 | if (m_filemap.find(f)==m_filemap.end()) { | 128 | if (m_filemap.find(f)==m_filemap.end()) { |
115 | return; | 129 | return; |
116 | } | 130 | } |
117 | QString name = m_filemap[f]; | 131 | QString name = m_filemap[f]; |
118 | emit sig_fullInfo(name, t); | 132 | emit sig_fullInfo(name, t); |
119 | } | 133 | } |
120 | 134 | ||
121 | void Doc_DirLister::slotThumbInfo(const QString&f, const QString&t) | 135 | void Doc_DirLister::slotThumbInfo(const QString&f, const QString&t) |
122 | { | 136 | { |
123 | if (m_filemap.find(f)==m_filemap.end()) { | 137 | if (m_filemap.find(f)==m_filemap.end()) { |
124 | return; | 138 | return; |
125 | } | 139 | } |
126 | QString name = m_filemap[f]; | 140 | QString name = m_filemap[f]; |
127 | emit sig_thumbInfo(name, t); | 141 | emit sig_thumbInfo(name, t); |
128 | } | 142 | } |
129 | 143 | ||
130 | void Doc_DirLister::slotThumbNail(const QString&f, const QPixmap&p) | 144 | void Doc_DirLister::slotThumbNail(const QString&f, const QPixmap&p) |
131 | { | 145 | { |
132 | if (m_filemap.find(f)==m_filemap.end()) { | 146 | if (m_filemap.find(f)==m_filemap.end()) { |
133 | return; | 147 | return; |
134 | } | 148 | } |
135 | QString name = m_filemap[f]; | 149 | QString name = m_filemap[f]; |
136 | emit sig_thumbNail(name, p); | 150 | emit sig_thumbNail(name, p); |
137 | } | 151 | } |
138 | 152 | ||
139 | QString Doc_DirLister::nameToFname(const QString&name)const | 153 | QString Doc_DirLister::nameToFname(const QString&name)const |
140 | { | 154 | { |
141 | if (m_namemap.find(name)==m_namemap.end()) { | 155 | if (m_namemap.find(name)==m_namemap.end()) { |
142 | return QString::null; | 156 | return QString::null; |
143 | } | 157 | } |
144 | return m_namemap[name]; | 158 | return m_namemap[name]; |
145 | } | 159 | } |
146 | 160 | ||
147 | QString Doc_DirLister::dirUp( const QString& p ) const{ | 161 | QString Doc_DirLister::dirUp( const QString& p ) const{ |
148 | return p; | 162 | return p; |
149 | } | 163 | } |
164 | |||
165 | QWidget* Doc_DirLister::widget(QWidget*parent) | ||
166 | { | ||
167 | CategorySelect * catmb = new CategorySelect(parent); | ||
168 | Categories cats( 0 ); | ||
169 | cats.load( categoryFileName() ); | ||
170 | QArray<int> vl( 0 ); | ||
171 | catmb->setCategories( vl, "Document View", // No tr | ||
172 | "Document View" ); | ||
173 | catmb->setRemoveCategoryEdit( TRUE ); | ||
174 | catmb->setAllCategories( TRUE ); | ||
175 | connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); | ||
176 | catmb->setCurrentCategory(-2); | ||
177 | return catmb; | ||
178 | } | ||
179 | |||
180 | void Doc_DirLister::showCategory(int which) | ||
181 | { | ||
182 | Categories cat; | ||
183 | cat.load( categoryFileName() ); | ||
184 | m_catFilter = which==-2?0:which; | ||
185 | m_namemap.clear(); | ||
186 | setStartPath(""); | ||
187 | emit sig_reloadDir(); | ||
188 | } | ||
diff --git a/noncore/graphics/opie-eye/impl/doc/doc_lister.h b/noncore/graphics/opie-eye/impl/doc/doc_lister.h index 5884a35..e148ac0 100644 --- a/noncore/graphics/opie-eye/impl/doc/doc_lister.h +++ b/noncore/graphics/opie-eye/impl/doc/doc_lister.h | |||
@@ -1,42 +1,49 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #ifndef DOC_LISTER_INTERFACE_LISTER_H | 5 | #ifndef DOC_LISTER_INTERFACE_LISTER_H |
6 | #define DOC_LISTER_INTERFACE_LISTER_H | 6 | #define DOC_LISTER_INTERFACE_LISTER_H |
7 | 7 | ||
8 | #include <iface/dirlister.h> | 8 | #include <iface/dirlister.h> |
9 | 9 | ||
10 | #include <qstring.h> | 10 | #include <qstring.h> |
11 | #include <qmap.h> | 11 | #include <qmap.h> |
12 | 12 | ||
13 | class Config; | 13 | class Config; |
14 | class AppLnk; | ||
15 | |||
14 | class Doc_DirLister : public PDirLister { | 16 | class Doc_DirLister : public PDirLister { |
15 | Q_OBJECT | 17 | Q_OBJECT |
16 | public: | 18 | public: |
17 | Doc_DirLister(); | 19 | Doc_DirLister(); |
18 | virtual ~Doc_DirLister(){} | 20 | virtual ~Doc_DirLister(){} |
19 | 21 | ||
20 | QString defaultPath()const; | 22 | QString defaultPath()const; |
21 | QString setStartPath( const QString& ); | 23 | QString setStartPath( const QString& ); |
22 | QString currentPath()const; | 24 | QString currentPath()const; |
23 | QStringList folders()const; | 25 | QStringList folders()const; |
24 | QStringList files()const; | 26 | QStringList files()const; |
25 | 27 | ||
26 | void deleteImage( const QString& ); | 28 | void deleteImage( const QString& ); |
27 | void thumbNail( const QString&, int, int ); | 29 | void thumbNail( const QString&, int, int ); |
28 | QImage image( const QString&, Factor, int ); | 30 | QImage image( const QString&, Factor, int ); |
29 | void imageInfo( const QString& ); | 31 | void imageInfo( const QString& ); |
30 | void fullImageInfo( const QString& ); | 32 | void fullImageInfo( const QString& ); |
31 | virtual QString nameToFname(const QString&name)const; | 33 | virtual QString nameToFname(const QString&name)const; |
32 | QString dirUp( const QString& )const; | 34 | QString dirUp( const QString& )const; |
35 | QWidget* widget(QWidget*parent); | ||
33 | 36 | ||
34 | private: | 37 | private: |
35 | QMap<QString,QString> m_namemap,m_filemap; | 38 | QMap<QString,QString> m_namemap,m_filemap; |
39 | int m_catFilter; | ||
40 | bool matchCat(const AppLnk* app); | ||
41 | |||
36 | protected slots: | 42 | protected slots: |
37 | virtual void slotFullInfo(const QString&, const QString&); | 43 | virtual void slotFullInfo(const QString&, const QString&); |
38 | virtual void slotThumbInfo(const QString&, const QString&); | 44 | virtual void slotThumbInfo(const QString&, const QString&); |
39 | virtual void slotThumbNail(const QString&, const QPixmap&); | 45 | virtual void slotThumbNail(const QString&, const QPixmap&); |
46 | virtual void showCategory(int); | ||
40 | }; | 47 | }; |
41 | 48 | ||
42 | #endif | 49 | #endif |