author | zecke <zecke> | 2004-04-07 23:57:11 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-04-07 23:57:11 (UTC) |
commit | c968f44205a5da7dc37029e701f527450692e39a (patch) (unidiff) | |
tree | 2739918a38d2b12c446c34b77ee9d74425fdf51c | |
parent | 10ec13c9068e7e4ca0acf75e5843ebd91e4e8566 (diff) | |
download | opie-c968f44205a5da7dc37029e701f527450692e39a.zip opie-c968f44205a5da7dc37029e701f527450692e39a.tar.gz opie-c968f44205a5da7dc37029e701f527450692e39a.tar.bz2 |
Enter folders on Return
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index c07a1e5..7e4164b 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -1,456 +1,457 @@ | |||
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::Ui::OKeyConfigItem; | 36 | using Opie::Ui::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 | class IconViewItem : public QIconViewItem { | 44 | class IconViewItem : public QIconViewItem { |
45 | public: | 45 | public: |
46 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); | 46 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); |
47 | QPixmap* pixmap()const; | 47 | QPixmap* pixmap()const; |
48 | QString path()const { return m_path; } | 48 | QString path()const { return m_path; } |
49 | bool isDir()const { return m_isDir; } | 49 | bool isDir()const { return m_isDir; } |
50 | void setText( const QString& ); | 50 | void setText( const QString& ); |
51 | 51 | ||
52 | 52 | ||
53 | private: | 53 | private: |
54 | mutable QPixmap* m_pix; | 54 | mutable QPixmap* m_pix; |
55 | QString m_path; | 55 | QString m_path; |
56 | bool m_isDir : 1; | 56 | bool m_isDir : 1; |
57 | bool m_noInfo :1; | 57 | bool m_noInfo :1; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | 60 | ||
61 | /* | 61 | /* |
62 | * If we request an Image or String | 62 | * If we request an Image or String |
63 | * we add it to the map | 63 | * we add it to the map |
64 | */ | 64 | */ |
65 | static QMap<QString, IconViewItem*> g_stringInf; | 65 | static QMap<QString, IconViewItem*> g_stringInf; |
66 | static QMap<QString, IconViewItem*> g_stringPix; | 66 | static QMap<QString, IconViewItem*> g_stringPix; |
67 | 67 | ||
68 | IconViewItem::IconViewItem( QIconView* view,const QString& path, | 68 | IconViewItem::IconViewItem( QIconView* view,const QString& path, |
69 | const QString& name, bool isDir ) | 69 | const QString& name, bool isDir ) |
70 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), | 70 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), |
71 | m_noInfo( false ) | 71 | m_noInfo( false ) |
72 | { | 72 | { |
73 | if ( isDir && !_dirPix ) | 73 | if ( isDir && !_dirPix ) |
74 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); | 74 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); |
75 | else if ( !isDir && !_unkPix ) | 75 | else if ( !isDir && !_unkPix ) |
76 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); | 76 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); |
77 | } | 77 | } |
78 | inline QPixmap* IconViewItem::pixmap()const { | 78 | inline QPixmap* IconViewItem::pixmap()const { |
79 | // qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", | 79 | // qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", |
80 | // rect().x(),rect().y(),rect().width(),rect().height(), | 80 | // rect().x(),rect().y(),rect().width(),rect().height(), |
81 | // iconView()->contentsX(), iconView()->contentsY()); | 81 | // iconView()->contentsX(), iconView()->contentsY()); |
82 | 82 | ||
83 | if ( m_isDir ) | 83 | if ( m_isDir ) |
84 | return _dirPix; | 84 | return _dirPix; |
85 | else{ | 85 | else{ |
86 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { | 86 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { |
87 | currentView()->dirLister()->imageInfo( m_path ); | 87 | currentView()->dirLister()->imageInfo( m_path ); |
88 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); | 88 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); |
89 | } | 89 | } |
90 | 90 | ||
91 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); | 91 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); |
92 | if ( !m_pix && !g_stringPix.contains( m_path )) { | 92 | if ( !m_pix && !g_stringPix.contains( m_path )) { |
93 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); | 93 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); |
94 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); | 94 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); |
95 | } | 95 | } |
96 | return m_pix ? m_pix : _unkPix; | 96 | return m_pix ? m_pix : _unkPix; |
97 | } | 97 | } |
98 | } | 98 | } |
99 | inline void IconViewItem::setText( const QString& str ) { | 99 | inline void IconViewItem::setText( const QString& str ) { |
100 | QString text = QIconViewItem::text()+"\n"+str; | 100 | QString text = QIconViewItem::text()+"\n"+str; |
101 | m_noInfo = true; | 101 | m_noInfo = true; |
102 | QIconViewItem::setText( text ); | 102 | QIconViewItem::setText( text ); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | 106 | ||
107 | /* | 107 | /* |
108 | * Set up the GUI.. initialize the slave set up gui | 108 | * Set up the GUI.. initialize the slave set up gui |
109 | * and also load a dir | 109 | * and also load a dir |
110 | */ | 110 | */ |
111 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | 111 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) |
112 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) | 112 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) |
113 | { | 113 | { |
114 | { | 114 | { |
115 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 115 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
116 | } | 116 | } |
117 | m_path = QDir::homeDirPath(); | 117 | m_path = QDir::homeDirPath(); |
118 | 118 | ||
119 | QHBox *hbox = new QHBox( this ); | 119 | QHBox *hbox = new QHBox( this ); |
120 | QLabel* lbl = new QLabel( hbox ); | 120 | QLabel* lbl = new QLabel( hbox ); |
121 | lbl->setText( tr("View as" ) ); | 121 | lbl->setText( tr("View as" ) ); |
122 | 122 | ||
123 | m_views = new QComboBox( hbox, "View As" ); | 123 | m_views = new QComboBox( hbox, "View As" ); |
124 | connect( m_views, SIGNAL(activated(int)), | 124 | connect( m_views, SIGNAL(activated(int)), |
125 | this, SLOT(slotViewChanged(int)) ); | 125 | this, SLOT(slotViewChanged(int)) ); |
126 | 126 | ||
127 | m_view= new QIconView( this ); | 127 | m_view= new QIconView( this ); |
128 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), | 128 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), |
129 | this, SLOT(slotClicked(QIconViewItem*)) ); | 129 | this, SLOT(slotClicked(QIconViewItem*)) ); |
130 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), | ||
131 | this, SLOT(slotClicked(QIconViewItem*)) ); | ||
130 | 132 | ||
131 | m_view->setArrangement( QIconView::LeftToRight ); | 133 | m_view->setArrangement( QIconView::LeftToRight ); |
132 | m_view->setItemTextPos( QIconView::Right ); | 134 | m_view->setItemTextPos( QIconView::Right ); |
133 | 135 | ||
134 | int dw = QApplication::desktop()->width(); | 136 | int dw = QApplication::desktop()->width(); |
135 | int viewerWidth = dw-style().scrollBarExtent().width(); | 137 | int viewerWidth = dw-style().scrollBarExtent().width(); |
136 | m_view->setGridX( viewerWidth-3*m_view->spacing()); | 138 | m_view->setGridX( viewerWidth-3*m_view->spacing()); |
137 | m_view->setGridY( fontMetrics().height()*2+40 ); | 139 | m_view->setGridY( fontMetrics().height()*2+40 ); |
138 | 140 | ||
139 | 141 | ||
140 | initKeys(); | 142 | initKeys(); |
141 | 143 | ||
142 | loadViews(); | 144 | loadViews(); |
143 | slotViewChanged( m_views->currentItem() ); | 145 | slotViewChanged( m_views->currentItem() ); |
144 | } | 146 | } |
145 | 147 | ||
146 | /* | 148 | /* |
147 | * Unref the slave and save the keyboard manager | 149 | * Unref the slave and save the keyboard manager |
148 | */ | 150 | */ |
149 | PIconView::~PIconView() { | 151 | PIconView::~PIconView() { |
150 | { | 152 | { |
151 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 153 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
152 | } | 154 | } |
153 | m_viewManager->save(); | 155 | m_viewManager->save(); |
154 | delete m_viewManager; | 156 | delete m_viewManager; |
155 | } | 157 | } |
156 | 158 | ||
157 | Opie::Ui::OKeyConfigManager* PIconView::manager() { | 159 | Opie::Ui::OKeyConfigManager* PIconView::manager() { |
158 | return m_viewManager; | 160 | return m_viewManager; |
159 | } | 161 | } |
160 | 162 | ||
161 | 163 | ||
162 | /* | 164 | /* |
163 | * init the KeyBoard Shortcuts | 165 | * init the KeyBoard Shortcuts |
164 | * called from the c'tor | 166 | * called from the c'tor |
165 | */ | 167 | */ |
166 | void PIconView::initKeys() { | 168 | void PIconView::initKeys() { |
167 | Opie::Ui::OKeyPair::List lst; | 169 | Opie::Ui::OKeyPair::List lst; |
168 | lst.append( Opie::Ui::OKeyPair::upArrowKey() ); | 170 | lst.append( Opie::Ui::OKeyPair::upArrowKey() ); |
169 | lst.append( Opie::Ui::OKeyPair::downArrowKey() ); | 171 | lst.append( Opie::Ui::OKeyPair::downArrowKey() ); |
170 | lst.append( Opie::Ui::OKeyPair::leftArrowKey() ); | 172 | lst.append( Opie::Ui::OKeyPair::leftArrowKey() ); |
171 | lst.append( Opie::Ui::OKeyPair::rightArrowKey() ); | 173 | lst.append( Opie::Ui::OKeyPair::rightArrowKey() ); |
172 | lst.append( Opie::Ui::OKeyPair::returnKey() ); | 174 | lst.append( Opie::Ui::OKeyPair::returnKey() ); |
173 | 175 | ||
174 | m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", | 176 | m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", |
175 | lst, false,this, "keyconfig name" ); | 177 | lst, false,this, "keyconfig name" ); |
176 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", | 178 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", |
177 | Resource::loadPixmap("beam"), BeamItem, | 179 | Resource::loadPixmap("beam"), BeamItem, |
178 | Opie::Ui::OKeyPair(Qt::Key_B, Qt::ShiftButton), | 180 | Opie::Ui::OKeyPair(Qt::Key_B, Qt::ShiftButton), |
179 | this, SLOT(slotBeam())) ); | 181 | this, SLOT(slotBeam())) ); |
180 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", | 182 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", |
181 | Resource::loadPixmap("trash"), DeleteItem, | 183 | Resource::loadPixmap("trash"), DeleteItem, |
182 | Opie::Ui::OKeyPair(Qt::Key_D, Qt::ShiftButton), | 184 | Opie::Ui::OKeyPair(Qt::Key_D, Qt::ShiftButton), |
183 | this, SLOT(slotTrash())) ); | 185 | this, SLOT(slotTrash())) ); |
184 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", | 186 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", |
185 | Resource::loadPixmap("1to1"), ViewItem, | 187 | Resource::loadPixmap("1to1"), ViewItem, |
186 | Opie::Ui::OKeyPair(Qt::Key_V, Qt::ShiftButton), | 188 | Opie::Ui::OKeyPair(Qt::Key_V, Qt::ShiftButton), |
187 | this, SLOT(slotShowImage()))); | 189 | this, SLOT(slotShowImage()))); |
188 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", | 190 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", |
189 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, | 191 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, |
190 | Opie::Ui::OKeyPair(Qt::Key_I, Qt::ShiftButton ), | 192 | Opie::Ui::OKeyPair(Qt::Key_I, Qt::ShiftButton ), |
191 | this, SLOT(slotImageInfo()) ) ); | 193 | this, SLOT(slotImageInfo()) ) ); |
192 | m_viewManager->load(); | 194 | m_viewManager->load(); |
193 | m_viewManager->handleWidget( m_view ); | 195 | m_viewManager->handleWidget( m_view ); |
194 | } | 196 | } |
195 | 197 | ||
196 | 198 | ||
197 | /* | 199 | /* |
198 | * change one dir up | 200 | * change one dir up |
199 | */ | 201 | */ |
200 | void PIconView::slotDirUp() { | 202 | void PIconView::slotDirUp() { |
201 | QDir dir( m_path ); | 203 | QDir dir( m_path ); |
202 | dir.cdUp(); | 204 | dir.cdUp(); |
203 | slotChangeDir( dir.absPath() ); | 205 | slotChangeDir( dir.absPath() ); |
204 | } | 206 | } |
205 | 207 | ||
206 | /* | 208 | /* |
207 | * change the dir | 209 | * change the dir |
208 | */ | 210 | */ |
209 | void PIconView::slotChangeDir(const QString& path) { | 211 | void PIconView::slotChangeDir(const QString& path) { |
210 | if ( !currentView() ) | 212 | if ( !currentView() ) |
211 | return; | 213 | return; |
212 | 214 | ||
213 | PDirLister *lister = currentView()->dirLister(); | 215 | PDirLister *lister = currentView()->dirLister(); |
214 | if (!lister ) | 216 | if (!lister ) |
215 | return; | 217 | return; |
216 | 218 | ||
217 | /* | 219 | /* |
218 | * Say what we want and take what we get | 220 | * Say what we want and take what we get |
219 | */ | 221 | */ |
220 | lister->setStartPath( path ); | 222 | lister->setStartPath( path ); |
221 | m_path = lister->currentPath(); | 223 | m_path = lister->currentPath(); |
222 | 224 | ||
223 | m_view->viewport()->setUpdatesEnabled( false ); | 225 | m_view->viewport()->setUpdatesEnabled( false ); |
224 | m_view->clear(); | 226 | m_view->clear(); |
225 | 227 | ||
226 | /* | 228 | /* |
227 | * add files and folders | 229 | * add files and folders |
228 | */ | 230 | */ |
229 | addFolders( lister->folders() ); | 231 | addFolders( lister->folders() ); |
230 | addFiles( lister->files() ); | 232 | addFiles( lister->files() ); |
231 | m_view->viewport()->setUpdatesEnabled( true ); | 233 | m_view->viewport()->setUpdatesEnabled( true ); |
232 | 234 | ||
233 | // Also invalidate the cache. We can't cancel the operations anyway | 235 | // Also invalidate the cache. We can't cancel the operations anyway |
234 | g_stringPix.clear(); | 236 | g_stringPix.clear(); |
235 | g_stringInf.clear(); | 237 | g_stringInf.clear(); |
236 | 238 | ||
237 | // looks ugly | 239 | // looks ugly |
238 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); | 240 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); |
239 | } | 241 | } |
240 | 242 | ||
241 | /** | 243 | /** |
242 | * get the current file name | 244 | * get the current file name |
243 | * @param isDir see if this is a dir or real file | 245 | * @param isDir see if this is a dir or real file |
244 | */ | 246 | */ |
245 | QString PIconView::currentFileName(bool &isDir)const { | 247 | QString PIconView::currentFileName(bool &isDir)const { |
246 | isDir = false; | 248 | isDir = false; |
247 | QIconViewItem* _it = m_view->currentItem(); | 249 | QIconViewItem* _it = m_view->currentItem(); |
248 | if ( !_it ) | 250 | if ( !_it ) |
249 | return QString::null; | 251 | return QString::null; |
250 | 252 | ||
251 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 253 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
252 | isDir = it->isDir(); | 254 | isDir = it->isDir(); |
253 | return it->path(); | 255 | return it->path(); |
254 | } | 256 | } |
255 | 257 | ||
256 | void PIconView::slotTrash() { | 258 | void PIconView::slotTrash() { |
257 | bool isDir; | 259 | bool isDir; |
258 | QString pa = currentFileName( isDir ); | 260 | QString pa = currentFileName( isDir ); |
259 | if ( isDir && pa.isEmpty() ) | 261 | if ( isDir && pa.isEmpty() ) |
260 | return; | 262 | return; |
261 | 263 | ||
262 | if (!QPEMessageBox::confirmDelete( this, | 264 | if (!QPEMessageBox::confirmDelete( this, |
263 | tr("Delete Image" ), | 265 | tr("Delete Image" ), |
264 | tr("the Image %1" ).arg(pa))) | 266 | tr("the Image %1" ).arg(pa))) |
265 | return | 267 | return |
266 | 268 | ||
267 | 269 | ||
268 | currentView()->dirLister()->deleteImage( pa ); | 270 | currentView()->dirLister()->deleteImage( pa ); |
269 | delete m_view->currentItem(); | 271 | delete m_view->currentItem(); |
270 | } | 272 | } |
271 | 273 | ||
272 | /* | 274 | /* |
273 | * see what views are available | 275 | * see what views are available |
274 | */ | 276 | */ |
275 | void PIconView::loadViews() { | 277 | void PIconView::loadViews() { |
276 | ViewMap::Iterator it; | 278 | ViewMap::Iterator it; |
277 | ViewMap* map = viewMap(); | 279 | ViewMap* map = viewMap(); |
278 | for ( it = map->begin(); it != map->end(); ++it ) | 280 | for ( it = map->begin(); it != map->end(); ++it ) |
279 | m_views->insertItem( QObject::tr(it.key() ) ); | 281 | m_views->insertItem( QObject::tr(it.key() ) ); |
280 | } | 282 | } |
281 | 283 | ||
282 | void PIconView::resetView() { | 284 | void PIconView::resetView() { |
283 | slotViewChanged(m_views->currentItem()); | 285 | slotViewChanged(m_views->currentItem()); |
284 | } | 286 | } |
285 | 287 | ||
286 | /* | 288 | /* |
287 | *swicth view reloadDir and connect signals | 289 | *swicth view reloadDir and connect signals |
288 | */ | 290 | */ |
289 | void PIconView::slotViewChanged( int i) { | 291 | void PIconView::slotViewChanged( int i) { |
290 | if (!m_views->count() ) { | 292 | if (!m_views->count() ) { |
291 | setCurrentView( 0l); | 293 | setCurrentView( 0l); |
292 | return; | 294 | return; |
293 | } | 295 | } |
294 | 296 | ||
295 | PDirView* cur = currentView(); | 297 | PDirView* cur = currentView(); |
296 | delete cur; | 298 | delete cur; |
297 | QString str = m_views->text(i); | 299 | QString str = m_views->text(i); |
298 | cur = (*(*viewMap())[str])(*m_cfg); | 300 | cur = (*(*viewMap())[str])(*m_cfg); |
299 | setCurrentView( cur ); | 301 | setCurrentView( cur ); |
300 | 302 | ||
301 | /* connect to the signals of the lister */ | 303 | /* connect to the signals of the lister */ |
302 | PDirLister* lis = cur->dirLister(); | 304 | PDirLister* lis = cur->dirLister(); |
303 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), | 305 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), |
304 | this, SLOT( slotThumbInfo(const QString&, const QString&))); | 306 | this, SLOT( slotThumbInfo(const QString&, const QString&))); |
305 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 307 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
306 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 308 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
307 | connect(lis, SIGNAL(sig_start()), | 309 | connect(lis, SIGNAL(sig_start()), |
308 | this, SLOT(slotStart())); | 310 | this, SLOT(slotStart())); |
309 | connect(lis, SIGNAL(sig_end()) , | 311 | connect(lis, SIGNAL(sig_end()) , |
310 | this, SLOT(slotEnd()) ); | 312 | this, SLOT(slotEnd()) ); |
311 | 313 | ||
312 | 314 | ||
313 | /* reload now */ | 315 | /* reload now */ |
314 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); | 316 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); |
315 | } | 317 | } |
316 | 318 | ||
317 | 319 | ||
318 | void PIconView::slotReloadDir() { | 320 | void PIconView::slotReloadDir() { |
319 | slotChangeDir( m_path ); | 321 | slotChangeDir( m_path ); |
320 | } | 322 | } |
321 | 323 | ||
322 | 324 | ||
323 | /* | 325 | /* |
324 | * add files and folders | 326 | * add files and folders |
325 | */ | 327 | */ |
326 | void PIconView::addFolders( const QStringList& lst) { | 328 | void PIconView::addFolders( const QStringList& lst) { |
327 | QStringList::ConstIterator it; | 329 | QStringList::ConstIterator it; |
328 | 330 | ||
329 | for(it=lst.begin(); it != lst.end(); ++it ) | 331 | for(it=lst.begin(); it != lst.end(); ++it ) |
330 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); | 332 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); |
331 | 333 | ||
332 | 334 | ||
333 | } | 335 | } |
334 | 336 | ||
335 | void PIconView::addFiles( const QStringList& lst) { | 337 | void PIconView::addFiles( const QStringList& lst) { |
336 | QStringList::ConstIterator it; | 338 | QStringList::ConstIterator it; |
337 | for (it=lst.begin(); it!= lst.end(); ++it ) | 339 | for (it=lst.begin(); it!= lst.end(); ++it ) |
338 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); | 340 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); |
339 | 341 | ||
340 | } | 342 | } |
341 | 343 | ||
342 | /* | 344 | /* |
343 | * user clicked on the item. Change dir or view | 345 | * user clicked on the item. Change dir or view |
344 | */ | 346 | */ |
345 | void PIconView::slotClicked(QIconViewItem* _it) { | 347 | void PIconView::slotClicked(QIconViewItem* _it) { |
346 | if(!_it ) | 348 | if(!_it ) |
347 | return; | 349 | return; |
348 | 350 | ||
349 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 351 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
350 | if( it->isDir() ) | 352 | if( it->isDir() ) |
351 | slotChangeDir( it->path() ); | 353 | slotChangeDir( it->path() ); |
352 | else // view image | 354 | else // view image |
353 | slotShowImage(); | 355 | slotShowImage(); |
354 | } | 356 | } |
355 | 357 | ||
356 | /* | 358 | /* |
357 | * got thumb info add to the cache if items is visible | 359 | * got thumb info add to the cache if items is visible |
358 | * we later need update after processing of slave is done | 360 | * we later need update after processing of slave is done |
359 | */ | 361 | */ |
360 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { | 362 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { |
361 | IconViewItem* item = g_stringInf[_path]; | 363 | IconViewItem* item = g_stringInf[_path]; |
362 | if (!item ) | 364 | if (!item ) |
363 | return; | 365 | return; |
364 | 366 | ||
365 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 367 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
366 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 368 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
367 | m_updatet = true; | 369 | m_updatet = true; |
368 | 370 | ||
369 | item->setText( str ); | 371 | item->setText( str ); |
370 | g_stringInf.remove( _path ); | 372 | g_stringInf.remove( _path ); |
371 | } | 373 | } |
372 | 374 | ||
373 | /* | 375 | /* |
374 | * got thumbnail and see if it is visible so we need to update later | 376 | * got thumbnail and see if it is visible so we need to update later |
375 | */ | 377 | */ |
376 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { | 378 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { |
377 | IconViewItem* item = g_stringPix[_path]; | 379 | IconViewItem* item = g_stringPix[_path]; |
378 | if (!item ) | 380 | if (!item ) |
379 | return; | 381 | return; |
380 | 382 | ||
381 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 383 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
382 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 384 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
383 | m_updatet = true; | 385 | m_updatet = true; |
384 | 386 | ||
385 | if (pix.width()>0) | 387 | if (pix.width()>0) |
386 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); | 388 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); |
387 | 389 | ||
388 | 390 | ||
389 | g_stringPix.remove( _path ); | 391 | g_stringPix.remove( _path ); |
390 | } | 392 | } |
391 | 393 | ||
392 | 394 | ||
393 | /* | 395 | /* |
394 | * FIXME rename | 396 | * FIXME rename |
395 | */ | 397 | */ |
396 | void PIconView::slotRename() { | 398 | void PIconView::slotRename() { |
397 | 399 | ||
398 | } | 400 | } |
399 | 401 | ||
400 | 402 | ||
401 | /* | 403 | /* |
402 | * BEAM the current file | 404 | * BEAM the current file |
403 | */ | 405 | */ |
404 | void PIconView::slotBeam() { | 406 | void PIconView::slotBeam() { |
405 | bool isDir; | 407 | bool isDir; |
406 | QString pa = currentFileName( isDir ); | 408 | QString pa = currentFileName( isDir ); |
407 | if ( isDir && pa.isEmpty() ) | 409 | if ( isDir && pa.isEmpty() ) |
408 | return; | 410 | return; |
409 | 411 | ||
410 | Ir* ir = new Ir( this ); | 412 | Ir* ir = new Ir( this ); |
411 | connect( ir, SIGNAL(done(Ir*)), | 413 | connect( ir, SIGNAL(done(Ir*)), |
412 | this, SLOT(slotBeamDone(Ir*))); | 414 | this, SLOT(slotBeamDone(Ir*))); |
413 | ir->send(pa, tr( "Image" ) ); | 415 | ir->send(pa, tr( "Image" ) ); |
414 | |||
415 | } | 416 | } |
416 | 417 | ||
417 | /* | 418 | /* |
418 | * BEAM done clean up | 419 | * BEAM done clean up |
419 | */ | 420 | */ |
420 | void PIconView::slotBeamDone( Ir* ir) { | 421 | void PIconView::slotBeamDone( Ir* ir) { |
421 | delete ir; | 422 | delete ir; |
422 | } | 423 | } |
423 | 424 | ||
424 | void PIconView::slotStart() { | 425 | void PIconView::slotStart() { |
425 | m_view->viewport()->setUpdatesEnabled( false ); | 426 | m_view->viewport()->setUpdatesEnabled( false ); |
426 | } | 427 | } |
427 | 428 | ||
428 | void PIconView::slotEnd() { | 429 | void PIconView::slotEnd() { |
429 | if ( m_updatet ) | 430 | if ( m_updatet ) |
430 | m_view->arrangeItemsInGrid( ); | 431 | m_view->arrangeItemsInGrid( ); |
431 | m_view->viewport()->setUpdatesEnabled( true ); | 432 | m_view->viewport()->setUpdatesEnabled( true ); |
432 | m_updatet = false; | 433 | m_updatet = false; |
433 | } | 434 | } |
434 | 435 | ||
435 | void PIconView::slotShowImage() | 436 | void PIconView::slotShowImage() |
436 | { | 437 | { |
437 | bool isDir = false; | 438 | bool isDir = false; |
438 | QString name = currentFileName(isDir); | 439 | QString name = currentFileName(isDir); |
439 | if (isDir) return; | 440 | if (isDir) return; |
440 | 441 | ||
441 | slotShowImage( name ); | 442 | slotShowImage( name ); |
442 | } | 443 | } |
443 | void PIconView::slotShowImage( const QString& name) { | 444 | void PIconView::slotShowImage( const QString& name) { |
444 | emit sig_display( name ); | 445 | emit sig_display( name ); |
445 | } | 446 | } |
446 | void PIconView::slotImageInfo() { | 447 | void PIconView::slotImageInfo() { |
447 | bool isDir = false; | 448 | bool isDir = false; |
448 | QString name = currentFileName(isDir); | 449 | QString name = currentFileName(isDir); |
449 | if (isDir) return; | 450 | if (isDir) return; |
450 | 451 | ||
451 | slotImageInfo( name ); | 452 | slotImageInfo( name ); |
452 | } | 453 | } |
453 | 454 | ||
454 | void PIconView::slotImageInfo( const QString& name) { | 455 | void PIconView::slotImageInfo( const QString& name) { |
455 | emit sig_showInfo( name ); | 456 | emit sig_showInfo( name ); |
456 | } | 457 | } |