summaryrefslogtreecommitdiff
authorzecke <zecke>2005-02-05 15:47:16 (UTC)
committer zecke <zecke>2005-02-05 15:47:16 (UTC)
commit8ba13dd38e7da296177719dcc8fddbbe978a4b9a (patch) (unidiff)
treefdba0d440e7b462faa2b845a0f4364cff134166f
parent28c5c88c3535c035bd26abd988ef7fb0e098143f (diff)
downloadopie-8ba13dd38e7da296177719dcc8fddbbe978a4b9a.zip
opie-8ba13dd38e7da296177719dcc8fddbbe978a4b9a.tar.gz
opie-8ba13dd38e7da296177719dcc8fddbbe978a4b9a.tar.bz2
Add a special MessageBox to squeeze the path to fit onto the screen.
This is a fix for #1539
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/gui.pro6
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp13
-rw-r--r--noncore/graphics/opie-eye/gui/messagebox.cpp119
-rw-r--r--noncore/graphics/opie-eye/gui/messagebox.h57
4 files changed, 185 insertions, 10 deletions
diff --git a/noncore/graphics/opie-eye/gui/gui.pro b/noncore/graphics/opie-eye/gui/gui.pro
index 2759dd5..250c8b1 100644
--- a/noncore/graphics/opie-eye/gui/gui.pro
+++ b/noncore/graphics/opie-eye/gui/gui.pro
@@ -1,17 +1,19 @@
1HEADERS += gui/filesystem.h \ 1HEADERS += gui/filesystem.h \
2 gui/iconview.h \ 2 gui/iconview.h \
3 gui/imageinfoui.h \ 3 gui/imageinfoui.h \
4 gui/imageview.h \ 4 gui/imageview.h \
5 gui/mainwindow.h \ 5 gui/mainwindow.h \
6 gui/viewmodebutton.h \ 6 gui/viewmodebutton.h \
7 gui/basesetup.h 7 gui/basesetup.h \
8 gui/messagebox.h
8 9
9SOURCES += gui/filesystem.cpp \ 10SOURCES += gui/filesystem.cpp \
10 gui/iconview.cpp \ 11 gui/iconview.cpp \
11 gui/imageinfoui.cpp \ 12 gui/imageinfoui.cpp \
12 gui/imageview.cpp \ 13 gui/imageview.cpp \
13 gui/mainwindow.cpp \ 14 gui/mainwindow.cpp \
14 gui/viewmodebutton.cpp \ 15 gui/viewmodebutton.cpp \
15 gui/basesetup.cpp 16 gui/basesetup.cpp \
17 gui/messagebox.cpp
16 18
17 19
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index 138e661..b2443e8 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -1,912 +1,909 @@
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#include "messagebox.h"
7 8
8#include <lib/imagecache.h> 9#include <lib/imagecache.h>
9#include <gui/imageinfoui.h> 10#include <gui/imageinfoui.h>
10 11
11#include <iface/dirview.h> 12#include <iface/dirview.h>
12#include <iface/dirlister.h> 13#include <iface/dirlister.h>
13 14
14#include <opie2/oconfig.h> 15#include <opie2/oconfig.h>
15#include <opie2/okeyconfigwidget.h> 16#include <opie2/okeyconfigwidget.h>
16#include <opie2/odebug.h> 17#include <opie2/odebug.h>
17#include <opie2/oimagescrollview.h> 18#include <opie2/oimagescrollview.h>
18 19
19#include <qpe/resource.h> 20#include <qpe/resource.h>
20#include <qpe/qpemessagebox.h> 21#include <qpe/qpemessagebox.h>
21#include <qpe/ir.h> 22#include <qpe/ir.h>
22#include <qpe/qcopenvelope_qws.h> 23#include <qpe/qcopenvelope_qws.h>
23#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
24 25
25#include <qiconview.h> 26#include <qiconview.h>
26#include <qlabel.h> 27#include <qlabel.h>
27#include <qhbox.h> 28#include <qhbox.h>
28#include <qcombobox.h> 29#include <qcombobox.h>
29#include <qdir.h> 30#include <qdir.h>
30#include <qapplication.h> 31#include <qapplication.h>
31#include <qmainwindow.h> 32#include <qmainwindow.h>
32#include <qtimer.h> 33#include <qtimer.h>
33#include <qstyle.h> 34#include <qstyle.h>
34 35
35 36
36using Opie::Core::OKeyConfigItem; 37using Opie::Core::OKeyConfigItem;
37 38
38/* 39/*
39 * The Icons, Request Cache and IconViewItem for the IconView 40 * The Icons, Request Cache and IconViewItem for the IconView
40 */ 41 */
41namespace { 42namespace {
42 static QPixmap* _dirPix = 0; 43 static QPixmap* _dirPix = 0;
43 static QPixmap* _unkPix = 0; 44 static QPixmap* _unkPix = 0;
44 static QPixmap* _cpyPix = 0; 45 static QPixmap* _cpyPix = 0;
45 static QPixmap* _emptyPix = 0; 46 static QPixmap* _emptyPix = 0;
46 class IconViewItem : public QIconViewItem { 47 class IconViewItem : public QIconViewItem {
47 public: 48 public:
48 IconViewItem( QIconView*, const QString& path, const QString& name,int a_iconsize, bool isDir = false); 49 IconViewItem( QIconView*, const QString& path, const QString& name,int a_iconsize, bool isDir = false);
49 QPixmap* pixmap()const; 50 QPixmap* pixmap()const;
50 QString path()const { return m_path; } 51 QString path()const { return m_path; }
51 bool isDir()const { return m_isDir; } 52 bool isDir()const { return m_isDir; }
52 void setText( const QString& ); 53 void setText( const QString& );
53 bool textOnly()const{return m_textOnly;} 54 bool textOnly()const{return m_textOnly;}
54 void setTextOnly(bool how){m_textOnly=how;} 55 void setTextOnly(bool how){m_textOnly=how;}
55 /* just for starting recalc of item rect! */ 56 /* just for starting recalc of item rect! */
56 virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); 57 virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE );
57 /* just for starting recalc of item rect! */ 58 /* just for starting recalc of item rect! */
58 virtual void setPixmap( const QPixmap & icon); 59 virtual void setPixmap( const QPixmap & icon);
59 60
60 protected: 61 protected:
61 mutable QPixmap* m_pix; 62 mutable QPixmap* m_pix;
62 int m_iconsize; 63 int m_iconsize;
63 void check_pix()const; 64 void check_pix()const;
64 65
65 private: 66 private:
66 QString m_path; 67 QString m_path;
67 bool m_isDir : 1; 68 bool m_isDir : 1;
68 bool m_noInfo :1; 69 bool m_noInfo :1;
69 bool m_textOnly:1; 70 bool m_textOnly:1;
70 bool m_NameOnly:1; 71 bool m_NameOnly:1;
71 bool m_Pixset:1; 72 bool m_Pixset:1;
72 }; 73 };
73 class TextViewItem : public IconViewItem { 74 class TextViewItem : public IconViewItem {
74 TextViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize , bool isDir = false); 75 TextViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize , bool isDir = false);
75 QPixmap *pixmap()const; 76 QPixmap *pixmap()const;
76 void setText( const QString& ); 77 void setText( const QString& );
77 }; 78 };
78 class ThumbViewItem : public IconViewItem { 79 class ThumbViewItem : public IconViewItem {
79 ThumbViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize, bool isDir = false ); 80 ThumbViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize, bool isDir = false );
80 QPixmap *pixmap()const; 81 QPixmap *pixmap()const;
81 void setText( const QString& ); 82 void setText( const QString& );
82 }; 83 };
83 84
84 85
85/* 86/*
86 * If we request an Image or String 87 * If we request an Image or String
87 * we add it to the map 88 * we add it to the map
88 */ 89 */
89 static QMap<QString, IconViewItem*> g_stringInf; 90 static QMap<QString, IconViewItem*> g_stringInf;
90 static QMap<QString, IconViewItem*> g_stringPix; 91 static QMap<QString, IconViewItem*> g_stringPix;
91 92
92 IconViewItem::IconViewItem( QIconView* view,const QString& path, 93 IconViewItem::IconViewItem( QIconView* view,const QString& path,
93 const QString& name, int a_iconsize, bool isDir) 94 const QString& name, int a_iconsize, bool isDir)
94 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), 95 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ),
95 m_noInfo( false ),m_textOnly(false),m_Pixset(false) 96 m_noInfo( false ),m_textOnly(false),m_Pixset(false)
96 { 97 {
97 m_iconsize = a_iconsize; 98 m_iconsize = a_iconsize;
98 if ( isDir ) { 99 if ( isDir ) {
99 if (!_dirPix ) { 100 if (!_dirPix ) {
100 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); 101 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser"));
101 } 102 }
102 } else { 103 } else {
103 if (!_unkPix ) { 104 if (!_unkPix ) {
104 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); 105 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) );
105 } 106 }
106 } 107 }
107 check_pix(); 108 check_pix();
108 } 109 }
109 110
110 inline void IconViewItem::check_pix()const 111 inline void IconViewItem::check_pix()const
111 { 112 {
112 if (_dirPix && _dirPix->width()>m_iconsize) { 113 if (_dirPix && _dirPix->width()>m_iconsize) {
113 QImage Pix = _dirPix->convertToImage(); 114 QImage Pix = _dirPix->convertToImage();
114 *_dirPix = Pix.smoothScale(m_iconsize,m_iconsize); 115 *_dirPix = Pix.smoothScale(m_iconsize,m_iconsize);
115 } 116 }
116 if (!_cpyPix && _unkPix) { 117 if (!_cpyPix && _unkPix) {
117 if (_unkPix->width()>=m_iconsize) { 118 if (_unkPix->width()>=m_iconsize) {
118 QImage Pix = _unkPix->convertToImage(); 119 QImage Pix = _unkPix->convertToImage();
119 _cpyPix = new QPixmap(); 120 _cpyPix = new QPixmap();
120 if (_unkPix->width()>m_iconsize) { 121 if (_unkPix->width()>m_iconsize) {
121 *_cpyPix = Pix.smoothScale(m_iconsize,m_iconsize); 122 *_cpyPix = Pix.smoothScale(m_iconsize,m_iconsize);
122 } else { 123 } else {
123 _cpyPix->convertFromImage(Pix); 124 _cpyPix->convertFromImage(Pix);
124 } 125 }
125 126
126 } else { 127 } else {
127 _cpyPix = new QPixmap(m_iconsize,m_iconsize); 128 _cpyPix = new QPixmap(m_iconsize,m_iconsize);
128 _cpyPix->fill(); 129 _cpyPix->fill();
129 QPainter pa(_cpyPix); 130 QPainter pa(_cpyPix);
130 int offset = (m_iconsize-_unkPix->width())/2; 131 int offset = (m_iconsize-_unkPix->width())/2;
131 int offy = (m_iconsize-_unkPix->height())/2; 132 int offy = (m_iconsize-_unkPix->height())/2;
132 if (offy<0) offy=0; 133 if (offy<0) offy=0;
133 pa.drawPixmap(offset,offy,*_unkPix); 134 pa.drawPixmap(offset,offy,*_unkPix);
134 pa.end(); 135 pa.end();
135 } 136 }
136 } 137 }
137 } 138 }
138 139
139 inline void IconViewItem::setPixmap( const QPixmap & , bool, bool ) 140 inline void IconViewItem::setPixmap( const QPixmap & , bool, bool )
140 { 141 {
141 m_Pixset = true; 142 m_Pixset = true;
142 calcRect(text()); 143 calcRect(text());
143 } 144 }
144 inline void IconViewItem::setPixmap( const QPixmap & ) 145 inline void IconViewItem::setPixmap( const QPixmap & )
145 { 146 {
146 m_Pixset = true; 147 m_Pixset = true;
147 calcRect(text()); 148 calcRect(text());
148 } 149 }
149 150
150 inline QPixmap* IconViewItem::pixmap()const { 151 inline QPixmap* IconViewItem::pixmap()const {
151// owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y() 152// owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y()
152// << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX() 153// << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX()
153// << " " << iconView()->contentsY() << oendl; 154// << " " << iconView()->contentsY() << oendl;
154 155
155 if (textOnly()&&!m_isDir) { 156 if (textOnly()&&!m_isDir) {
156 if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); 157 if (!_emptyPix) _emptyPix = new QPixmap(0,0,1);
157 return _emptyPix; 158 return _emptyPix;
158 } 159 }
159 if ( m_isDir ) 160 if ( m_isDir )
160 return _dirPix; 161 return _dirPix;
161 else{ 162 else{
162 if (!m_noInfo && !g_stringInf.contains( m_path ) ) { 163 if (!m_noInfo && !g_stringInf.contains( m_path ) ) {
163 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); 164 g_stringInf.insert( m_path, const_cast<IconViewItem*>(this));
164 currentView()->dirLister()->imageInfo( m_path ); 165 currentView()->dirLister()->imageInfo( m_path );
165 } 166 }
166 167
167 m_pix = PPixmapCache::self()->cachedImage( m_path, m_iconsize, m_iconsize ); 168 m_pix = PPixmapCache::self()->cachedImage( m_path, m_iconsize, m_iconsize );
168 if (!m_pix && !g_stringPix.contains( m_path )) { 169 if (!m_pix && !g_stringPix.contains( m_path )) {
169 check_pix(); 170 check_pix();
170 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); 171 g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
171 currentView()->dirLister()->thumbNail( m_path, m_iconsize, m_iconsize); 172 currentView()->dirLister()->thumbNail( m_path, m_iconsize, m_iconsize);
172 } 173 }
173 return m_pix ? m_pix : _cpyPix; 174 return m_pix ? m_pix : _cpyPix;
174 } 175 }
175 } 176 }
176 inline void IconViewItem::setText( const QString& str ) { 177 inline void IconViewItem::setText( const QString& str ) {
177 QString text = QIconViewItem::text()+"\n"+str; 178 QString text = QIconViewItem::text()+"\n"+str;
178 m_noInfo = true; 179 m_noInfo = true;
179 QIconViewItem::setText( text ); 180 QIconViewItem::setText( text );
180 } 181 }
181} 182}
182 183
183 184
184/* 185/*
185 * Set up the GUI.. initialize the slave set up gui 186 * Set up the GUI.. initialize the slave set up gui
186 * and also load a dir 187 * and also load a dir
187 */ 188 */
188PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) 189PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg )
189 : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) 190 : QVBox( wid ), m_cfg( cfg ), m_updatet( false )
190{ 191{
191 { 192 {
192 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 193 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
193 } 194 }
194 m_path = QDir::homeDirPath(); 195 m_path = QDir::homeDirPath();
195 m_mode = 0; 196 m_mode = 0;
196 m_iconsize = 32; 197 m_iconsize = 32;
197 m_internalReset = false; 198 m_internalReset = false;
198 m_customWidget = 0; 199 m_customWidget = 0;
199 m_setDocCalled = false; 200 m_setDocCalled = false;
200 201
201 m_hbox = new QHBox( this ); 202 m_hbox = new QHBox( this );
202 QLabel* lbl = new QLabel( m_hbox ); 203 QLabel* lbl = new QLabel( m_hbox );
203 lbl->setText( tr("View as" ) ); 204 lbl->setText( tr("View as" ) );
204 205
205 m_views = new QComboBox( m_hbox, "View As" ); 206 m_views = new QComboBox( m_hbox, "View As" );
206 207
207 m_view= new QIconView( this ); 208 m_view= new QIconView( this );
208 connect(m_view, SIGNAL(clicked(QIconViewItem*) ), 209 connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
209 this, SLOT(slotClicked(QIconViewItem*)) ); 210 this, SLOT(slotClicked(QIconViewItem*)) );
210 connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), 211 connect(m_view, SIGNAL(returnPressed(QIconViewItem*)),
211 this, SLOT(slotClicked(QIconViewItem*)) ); 212 this, SLOT(slotClicked(QIconViewItem*)) );
212 213
213 m_view->setArrangement( QIconView::LeftToRight ); 214 m_view->setArrangement( QIconView::LeftToRight );
214 215
215 m_mode = m_cfg->readNumEntry("ListViewMode", 1); 216 m_mode = m_cfg->readNumEntry("ListViewMode", 1);
216 if (m_mode < 1 || m_mode>3) m_mode = 1; 217 if (m_mode < 1 || m_mode>3) m_mode = 1;
217 m_view->setItemTextPos( QIconView::Right ); 218 m_view->setItemTextPos( QIconView::Right );
218 if (m_mode >1) { 219 if (m_mode >1) {
219 m_view->setResizeMode(QIconView::Adjust); 220 m_view->setResizeMode(QIconView::Adjust);
220 } else { 221 } else {
221 m_view->setResizeMode(QIconView::Fixed); 222 m_view->setResizeMode(QIconView::Fixed);
222 } 223 }
223 m_iconsize = m_cfg->readNumEntry("iconsize", 32); 224 m_iconsize = m_cfg->readNumEntry("iconsize", 32);
224 if (m_iconsize<12)m_iconsize = 12; 225 if (m_iconsize<12)m_iconsize = 12;
225 if (m_iconsize>64)m_iconsize = 64; 226 if (m_iconsize>64)m_iconsize = 64;
226 227
227 calculateGrid(); 228 calculateGrid();
228 initKeys(); 229 initKeys();
229 loadViews(); 230 loadViews();
230} 231}
231 232
232void PIconView::setDoccalled(bool how) 233void PIconView::setDoccalled(bool how)
233{ 234{
234 m_setDocCalled = how; 235 m_setDocCalled = how;
235} 236}
236 237
237/* 238/*
238 * Unref the slave and save the keyboard manager 239 * Unref the slave and save the keyboard manager
239 */ 240 */
240PIconView::~PIconView() { 241PIconView::~PIconView() {
241 { 242 {
242 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 243 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
243 } 244 }
244 m_viewManager->save(); 245 m_viewManager->save();
245 delete m_viewManager; 246 delete m_viewManager;
246} 247}
247 248
248Opie::Core::OKeyConfigManager* PIconView::manager() { 249Opie::Core::OKeyConfigManager* PIconView::manager() {
249 return m_viewManager; 250 return m_viewManager;
250} 251}
251 252
252 253
253/* 254/*
254 * init the KeyBoard Shortcuts 255 * init the KeyBoard Shortcuts
255 * called from the c'tor 256 * called from the c'tor
256 */ 257 */
257void PIconView::initKeys() { 258void PIconView::initKeys() {
258 Opie::Core::OKeyPair::List lst; 259 Opie::Core::OKeyPair::List lst;
259 lst.append( Opie::Core::OKeyPair::upArrowKey() ); 260 lst.append( Opie::Core::OKeyPair::upArrowKey() );
260 lst.append( Opie::Core::OKeyPair::downArrowKey() ); 261 lst.append( Opie::Core::OKeyPair::downArrowKey() );
261 lst.append( Opie::Core::OKeyPair::leftArrowKey() ); 262 lst.append( Opie::Core::OKeyPair::leftArrowKey() );
262 lst.append( Opie::Core::OKeyPair::rightArrowKey() ); 263 lst.append( Opie::Core::OKeyPair::rightArrowKey() );
263 lst.append( Opie::Core::OKeyPair::returnKey() ); 264 lst.append( Opie::Core::OKeyPair::returnKey() );
264 265
265 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", 266 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config",
266 lst, false,this, "keyconfig name" ); 267 lst, false,this, "keyconfig name" );
267 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", 268 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam",
268 Resource::loadPixmap("beam"), BeamItem, 269 Resource::loadPixmap("beam"), BeamItem,
269 Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), 270 Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton),
270 this, SLOT(slotBeam())) ); 271 this, SLOT(slotBeam())) );
271 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", 272 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete",
272 Resource::loadPixmap("trash"), DeleteItem, 273 Resource::loadPixmap("trash"), DeleteItem,
273 Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), 274 Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton),
274 this, SLOT(slotTrash())) ); 275 this, SLOT(slotTrash())) );
275 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", 276 m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view",
276 Resource::loadPixmap("1to1"), ViewItem, 277 Resource::loadPixmap("1to1"), ViewItem,
277 Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), 278 Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton),
278 this, SLOT(slotShowImage()))); 279 this, SLOT(slotShowImage())));
279 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", 280 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info",
280 Resource::loadPixmap("DocumentTypeWord"), InfoItem, 281 Resource::loadPixmap("DocumentTypeWord"), InfoItem,
281 Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), 282 Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ),
282 this, SLOT(slotImageInfo()) ) ); 283 this, SLOT(slotImageInfo()) ) );
283 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow", 284 m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow",
284 Resource::loadPixmap("1to1"), SlideItem, 285 Resource::loadPixmap("1to1"), SlideItem,
285 Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton), 286 Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton),
286 this, SLOT(slotStartSlide()))); 287 this, SLOT(slotStartSlide())));
287 m_viewManager->load(); 288 m_viewManager->load();
288 m_viewManager->handleWidget( m_view ); 289 m_viewManager->handleWidget( m_view );
289} 290}
290 291
291 292
292/* 293/*
293 * change one dir up 294 * change one dir up
294 */ 295 */
295void PIconView::slotDirUp() 296void PIconView::slotDirUp()
296{ 297{
297 slotChangeDir( currentView()->dirLister()->dirUp( m_path ) ); 298 slotChangeDir( currentView()->dirLister()->dirUp( m_path ) );
298} 299}
299 300
300/* 301/*
301 * change the dir 302 * change the dir
302 */ 303 */
303void PIconView::slotChangeDir(const QString& path) { 304void PIconView::slotChangeDir(const QString& path) {
304 if ( !currentView() ) 305 if ( !currentView() )
305 return; 306 return;
306 307
307 PDirLister *lister = currentView()->dirLister(); 308 PDirLister *lister = currentView()->dirLister();
308 if (!lister ) 309 if (!lister )
309 return; 310 return;
310 311
311 /* 312 /*
312 * Say what we want and take what we get 313 * Say what we want and take what we get
313 */ 314 */
314 lister->setStartPath( path ); 315 lister->setStartPath( path );
315 m_path = lister->currentPath(); 316 m_path = lister->currentPath();
316 317
317 m_view->viewport()->setUpdatesEnabled( false ); 318 m_view->viewport()->setUpdatesEnabled( false );
318 m_view->clear(); 319 m_view->clear();
319 320
320 // Also invalidate the cache. We can't cancel the operations anyway 321 // Also invalidate the cache. We can't cancel the operations anyway
321 g_stringPix.clear(); 322 g_stringPix.clear();
322 g_stringInf.clear(); 323 g_stringInf.clear();
323 324
324 /* 325 /*
325 * add files and folders 326 * add files and folders
326 */ 327 */
327 addFolders( lister->folders() ); 328 addFolders( lister->folders() );
328 addFiles( lister->files() ); 329 addFiles( lister->files() );
329 m_view->viewport()->setUpdatesEnabled( true ); 330 m_view->viewport()->setUpdatesEnabled( true );
330 331
331 // looks ugly 332 // looks ugly
332 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); 333 static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
333} 334}
334 335
335/** 336/**
336 * get the current file name 337 * get the current file name
337 * @param isDir see if this is a dir or real file 338 * @param isDir see if this is a dir or real file
338 */ 339 */
339QString PIconView::currentFileName(bool &isDir)const { 340QString PIconView::currentFileName(bool &isDir)const {
340 isDir = false; 341 isDir = false;
341 QIconViewItem* _it = m_view->currentItem(); 342 QIconViewItem* _it = m_view->currentItem();
342 if ( !_it ) 343 if ( !_it )
343 return QString::null; 344 return QString::null;
344 345
345 IconViewItem* it = static_cast<IconViewItem*>( _it ); 346 IconViewItem* it = static_cast<IconViewItem*>( _it );
346 isDir = it->isDir(); 347 isDir = it->isDir();
347 return it->path(); 348 return it->path();
348} 349}
349 350
350QString PIconView::nextFileName(bool &isDir)const 351QString PIconView::nextFileName(bool &isDir)const
351{ 352{
352 isDir = false; 353 isDir = false;
353 QIconViewItem* _it1 = m_view->currentItem(); 354 QIconViewItem* _it1 = m_view->currentItem();
354 if ( !_it1 ) 355 if ( !_it1 )
355 return QString::null; 356 return QString::null;
356 QIconViewItem* _it = _it1->nextItem(); 357 QIconViewItem* _it = _it1->nextItem();
357 if ( !_it ) 358 if ( !_it )
358 return QString::null; 359 return QString::null;
359 IconViewItem* it = static_cast<IconViewItem*>( _it ); 360 IconViewItem* it = static_cast<IconViewItem*>( _it );
360 isDir = it->isDir(); 361 isDir = it->isDir();
361 return it->path(); 362 return it->path();
362} 363}
363 364
364QString PIconView::prevFileName(bool &isDir)const{ 365QString PIconView::prevFileName(bool &isDir)const{
365 isDir = false; 366 isDir = false;
366 QIconViewItem* _it = m_view->currentItem(); 367 QIconViewItem* _it = m_view->currentItem();
367 if ( !_it ) 368 if ( !_it )
368 return QString::null; 369 return QString::null;
369 _it = _it->prevItem(); 370 _it = _it->prevItem();
370 if ( !_it ) 371 if ( !_it )
371 return QString::null; 372 return QString::null;
372 IconViewItem* it = static_cast<IconViewItem*>( _it ); 373 IconViewItem* it = static_cast<IconViewItem*>( _it );
373 isDir = it->isDir(); 374 isDir = it->isDir();
374 return it->path(); 375 return it->path();
375} 376}
376 377
377void PIconView::slotTrash() { 378void PIconView::slotTrash() {
378 bool isDir; 379 bool isDir;
379 QString pa = currentFileName( isDir ); 380 QString pa = currentFileName( isDir );
380 if ( isDir && pa.isEmpty() ) 381 if ( isDir || pa.isEmpty() )
381 return; 382 return;
382 383
383 if (!QPEMessageBox::confirmDelete( this, 384 if (!OMessageBox::confirmDelete( this, tr("the Image"),
384 tr("Delete Image" ), 385 pa, tr("Delete Image" )))
385 tr("the Image %1" ).arg(pa))) 386 return;
386 return
387 387
388 388
389 currentView()->dirLister()->deleteImage( pa ); 389 currentView()->dirLister()->deleteImage( pa );
390 delete m_view->currentItem(); 390 delete m_view->currentItem();
391} 391}
392 392
393/* 393/*
394 * see what views are available 394 * see what views are available
395 */ 395 */
396void PIconView::loadViews() { 396void PIconView::loadViews() {
397 ViewMap::Iterator it; 397 ViewMap::Iterator it;
398 ViewMap* map = viewMap(); 398 ViewMap* map = viewMap();
399 for ( it = map->begin(); it != map->end(); ++it ) 399 for ( it = map->begin(); it != map->end(); ++it )
400 m_views->insertItem( it.key() ); 400 m_views->insertItem( it.key() );
401} 401}
402 402
403void PIconView::resetView() { 403void PIconView::resetView() {
404 m_internalReset = true; 404 m_internalReset = true;
405 // Also invalidate the cache. We can't cancel the operations anyway 405 // Also invalidate the cache. We can't cancel the operations anyway
406 g_stringPix.clear(); 406 g_stringPix.clear();
407 g_stringInf.clear(); 407 g_stringInf.clear();
408 if (m_mode>1) { 408 if (m_mode>1) {
409 int osize = m_iconsize; 409 int osize = m_iconsize;
410 m_iconsize = m_cfg->readNumEntry("iconsize", 32); 410 m_iconsize = m_cfg->readNumEntry("iconsize", 32);
411 if (m_iconsize<12)m_iconsize = 12; 411 if (m_iconsize<12)m_iconsize = 12;
412 if (m_iconsize>64)m_iconsize = 64; 412 if (m_iconsize>64)m_iconsize = 64;
413 if (osize != m_iconsize) { 413 if (osize != m_iconsize) {
414 if (_dirPix){ 414 if (_dirPix){
415 delete _dirPix; 415 delete _dirPix;
416 _dirPix = 0; 416 _dirPix = 0;
417 } 417 }
418 if (_cpyPix){ 418 if (_cpyPix){
419 delete _cpyPix; 419 delete _cpyPix;
420 _cpyPix = 0; 420 _cpyPix = 0;
421 } 421 }
422 calculateGrid(); 422 calculateGrid();
423 } 423 }
424 } else { 424 } else {
425 m_iconsize = 64; 425 m_iconsize = 64;
426 } 426 }
427 slotViewChanged(m_views->currentItem()); 427 slotViewChanged(m_views->currentItem());
428 m_internalReset = false; 428 m_internalReset = false;
429} 429}
430 430
431void PIconView::polish() 431void PIconView::polish()
432{ 432{
433 odebug << "===\n"
434 << "PIconView::polish()\n"
435 << "====" << oendl;
436 QVBox::polish(); 433 QVBox::polish();
437 434
438 QString lastView = m_cfg->readEntry("LastView",""); 435 QString lastView = m_cfg->readEntry("LastView","");
439 int cc=0; 436 int cc=0;
440 for (; cc<m_views->count();++cc) { 437 for (; cc<m_views->count();++cc) {
441 if (m_views->text(cc)==lastView) { 438 if (m_views->text(cc)==lastView) {
442 break; 439 break;
443 } 440 }
444 } 441 }
445 if (cc<m_views->count()) { 442 if (cc<m_views->count()) {
446 m_views->setCurrentItem(cc); 443 m_views->setCurrentItem(cc);
447 slotViewChanged(cc); 444 slotViewChanged(cc);
448 } else { 445 } else {
449 slotViewChanged(m_views->currentItem()); 446 slotViewChanged(m_views->currentItem());
450 } 447 }
451 connect( m_views, SIGNAL(activated(int)), 448 connect( m_views, SIGNAL(activated(int)),
452 this, SLOT(slotViewChanged(int)) ); 449 this, SLOT(slotViewChanged(int)) );
453} 450}
454 451
455/* 452/*
456 *swicth view reloadDir and connect signals 453 *swicth view reloadDir and connect signals
457 */ 454 */
458void PIconView::slotViewChanged( int i) { 455void PIconView::slotViewChanged( int i) {
459 if (!m_views->count() ) { 456 if (!m_views->count() ) {
460 setCurrentView( 0l); 457 setCurrentView( 0l);
461 return; 458 return;
462 } 459 }
463 460
464 if (m_customWidget) { 461 if (m_customWidget) {
465 delete m_customWidget; 462 delete m_customWidget;
466 m_customWidget = 0; 463 m_customWidget = 0;
467 } 464 }
468 PDirView* cur = currentView(); 465 PDirView* cur = currentView();
469 if (cur) { 466 if (cur) {
470 delete cur; 467 delete cur;
471 } 468 }
472 QString str = m_views->text(i); 469 QString str = m_views->text(i);
473 ViewMap* map = viewMap(); 470 ViewMap* map = viewMap();
474 if (!map) { 471 if (!map) {
475 setCurrentView(0l); 472 setCurrentView(0l);
476 return; 473 return;
477 } 474 }
478 475
479 if (map->find(str) == map->end()) { 476 if (map->find(str) == map->end()) {
480 owarn << "Key not found" << oendl; 477 owarn << "Key not found" << oendl;
481 setCurrentView(0l); 478 setCurrentView(0l);
482 return; 479 return;
483 } 480 }
484 481
485 m_cfg->writeEntry("LastView",str); 482 m_cfg->writeEntry("LastView",str);
486 m_cfg->write(); 483 m_cfg->write();
487 cur = (*(*map)[str])(*m_cfg); 484 cur = (*(*map)[str])(*m_cfg);
488 setCurrentView( cur ); 485 setCurrentView( cur );
489 m_customWidget = cur->widget(m_hbox); 486 m_customWidget = cur->widget(m_hbox);
490 if (m_customWidget) { 487 if (m_customWidget) {
491 odebug << "Got a widget" << oendl; 488 odebug << "Got a widget" << oendl;
492 m_customWidget->show(); 489 m_customWidget->show();
493 } 490 }
494 491
495 /* connect to the signals of the lister */ 492 /* connect to the signals of the lister */
496 PDirLister* lis = cur->dirLister(); 493 PDirLister* lis = cur->dirLister();
497 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), 494 connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )),
498 this, SLOT( slotThumbInfo(const QString&, const QString&))); 495 this, SLOT( slotThumbInfo(const QString&, const QString&)));
499 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), 496 connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
500 this, SLOT(slotThumbNail(const QString&, const QPixmap&))); 497 this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
501 connect(lis, SIGNAL(sig_start()), 498 connect(lis, SIGNAL(sig_start()),
502 this, SLOT(slotStart())); 499 this, SLOT(slotStart()));
503 connect(lis, SIGNAL(sig_end()) , 500 connect(lis, SIGNAL(sig_end()) ,
504 this, SLOT(slotEnd()) ); 501 this, SLOT(slotEnd()) );
505 connect(lis,SIGNAL(sig_reloadDir()),this,SLOT(slotReloadDir())); 502 connect(lis,SIGNAL(sig_reloadDir()),this,SLOT(slotReloadDir()));
506 503
507 /* reload now with default Path 504 /* reload now with default Path
508 * but only if it isn't a reset like from setupdlg 505 * but only if it isn't a reset like from setupdlg
509 */ 506 */
510 if (!m_internalReset) { 507 if (!m_internalReset) {
511 m_path = lis->defaultPath(); 508 m_path = lis->defaultPath();
512 } 509 }
513 QTimer::singleShot( 0, this, SLOT(slotReloadDir())); 510 QTimer::singleShot( 0, this, SLOT(slotReloadDir()));
514} 511}
515 512
516 513
517void PIconView::slotReloadDir() { 514void PIconView::slotReloadDir() {
518 slotChangeDir( m_path ); 515 slotChangeDir( m_path );
519} 516}
520 517
521 518
522/* 519/*
523 * add files and folders 520 * add files and folders
524 */ 521 */
525void PIconView::addFolders( const QStringList& lst) { 522void PIconView::addFolders( const QStringList& lst) {
526 QStringList::ConstIterator it; 523 QStringList::ConstIterator it;
527 IconViewItem * _iv; 524 IconViewItem * _iv;
528 525
529 for(it=lst.begin(); it != lst.end(); ++it ) { 526 for(it=lst.begin(); it != lst.end(); ++it ) {
530 _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it),m_iconsize, true ); 527 _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it),m_iconsize, true );
531 if (m_mode==3) _iv->setTextOnly(true); 528 if (m_mode==3) _iv->setTextOnly(true);
532 } 529 }
533} 530}
534 531
535void PIconView::addFiles( const QStringList& lst) { 532void PIconView::addFiles( const QStringList& lst) {
536 QStringList::ConstIterator it; 533 QStringList::ConstIterator it;
537 IconViewItem * _iv; 534 IconViewItem * _iv;
538 QPixmap*m_pix = 0; 535 QPixmap*m_pix = 0;
539 QString pre = ""; 536 QString pre = "";
540 if (!m_path.isEmpty()) { 537 if (!m_path.isEmpty()) {
541 pre = m_path+"/"; 538 pre = m_path+"/";
542 } 539 }
543 QString s = ""; 540 QString s = "";
544 int pos; 541 int pos;
545 for (it=lst.begin(); it!= lst.end(); ++it ) { 542 for (it=lst.begin(); it!= lst.end(); ++it ) {
546 s = (*it); 543 s = (*it);
547 pos = s.find(char(0)); 544 pos = s.find(char(0));
548 m_pix = PPixmapCache::self()->cachedImage( pre+(*it), m_iconsize, m_iconsize ); 545 m_pix = PPixmapCache::self()->cachedImage( pre+(*it), m_iconsize, m_iconsize );
549 if (pos>-1) { 546 if (pos>-1) {
550 _iv = new IconViewItem( m_view, s.mid(pos+1), s.left(pos),m_iconsize ); 547 _iv = new IconViewItem( m_view, s.mid(pos+1), s.left(pos),m_iconsize );
551 } else { 548 } else {
552 _iv = new IconViewItem( m_view, pre+(*it), (*it),m_iconsize ); 549 _iv = new IconViewItem( m_view, pre+(*it), (*it),m_iconsize );
553 } 550 }
554 if (m_mode==3) { 551 if (m_mode==3) {
555 _iv->setTextOnly(true); 552 _iv->setTextOnly(true);
556 _iv->setPixmap(QPixmap()); 553 _iv->setPixmap(QPixmap());
557 } else { 554 } else {
558 if (m_pix) _iv->setPixmap(*m_pix); 555 if (m_pix) _iv->setPixmap(*m_pix);
559 } 556 }
560 } 557 }
561 558
562} 559}
563 560
564/* 561/*
565 * user clicked on the item. Change dir or view 562 * user clicked on the item. Change dir or view
566 */ 563 */
567void PIconView::slotClicked(QIconViewItem* _it) { 564void PIconView::slotClicked(QIconViewItem* _it) {
568 if(!_it ) 565 if(!_it )
569 return; 566 return;
570 567
571 IconViewItem* it = static_cast<IconViewItem*>(_it); 568 IconViewItem* it = static_cast<IconViewItem*>(_it);
572 if( it->isDir() ) 569 if( it->isDir() )
573 slotChangeDir( it->path() ); 570 slotChangeDir( it->path() );
574 else // view image 571 else // view image
575 slotShowImage(); 572 slotShowImage();
576} 573}
577 574
578/* 575/*
579 * Return was pressed. which is triggered by the keydown 576 * Return was pressed. which is triggered by the keydown
580 * handler. The problem is that the key up will be handled 577 * handler. The problem is that the key up will be handled
581 * by the ImageDisplayer and goes to the next image 578 * by the ImageDisplayer and goes to the next image
582 */ 579 */
583void PIconView::slotRetrun( QIconViewItem *_it ) { 580void PIconView::slotRetrun( QIconViewItem *_it ) {
584 if(!_it ) 581 if(!_it )
585 return; 582 return;
586 583
587 IconViewItem* it = static_cast<IconViewItem*>(_it); 584 IconViewItem* it = static_cast<IconViewItem*>(_it);
588 if( it->isDir() ) 585 if( it->isDir() )
589 slotChangeDir( it->path() ); 586 slotChangeDir( it->path() );
590 else 587 else
591 QTimer::singleShot(0, this, SLOT(slotShowImage()) ); 588 QTimer::singleShot(0, this, SLOT(slotShowImage()) );
592} 589}
593 590
594/* 591/*
595 * got thumb info add to the cache if items is visible 592 * got thumb info add to the cache if items is visible
596 * we later need update after processing of slave is done 593 * we later need update after processing of slave is done
597 */ 594 */
598void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { 595void PIconView::slotThumbInfo( const QString& _path, const QString& str ) {
599 IconViewItem* item = g_stringInf[_path]; 596 IconViewItem* item = g_stringInf[_path];
600 if (!item ) 597 if (!item )
601 return; 598 return;
602 599
603 if (m_mode == 2) { 600 if (m_mode == 2) {
604 return; 601 return;
605 } 602 }
606 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), 603 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
607 m_view->contentsWidth(), m_view->contentsHeight() ) ) ) 604 m_view->contentsWidth(), m_view->contentsHeight() ) ) )
608 m_updatet = true; 605 m_updatet = true;
609 606
610 item->setText( str ); 607 item->setText( str );
611 g_stringInf.remove( _path ); 608 g_stringInf.remove( _path );
612} 609}
613 610
614/* 611/*
615 * got thumbnail and see if it is visible so we need to update later 612 * got thumbnail and see if it is visible so we need to update later
616 */ 613 */
617void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { 614void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) {
618 IconViewItem* item = g_stringPix[_path]; 615 IconViewItem* item = g_stringPix[_path];
619 if (!item ) 616 if (!item )
620 return; 617 return;
621 618
622 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), 619 if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
623 m_view->contentsWidth(), m_view->contentsHeight() ) ) ) 620 m_view->contentsWidth(), m_view->contentsHeight() ) ) )
624 m_updatet = true; 621 m_updatet = true;
625 622
626 if (pix.width()>0) { 623 if (pix.width()>0) {
627 if (pix.width()<m_iconsize) { 624 if (pix.width()<m_iconsize) {
628 QPixmap p(m_iconsize,m_iconsize); 625 QPixmap p(m_iconsize,m_iconsize);
629 p.fill(); 626 p.fill();
630 QPainter pa(&p); 627 QPainter pa(&p);
631 int offset = (m_iconsize-pix.width())/2; 628 int offset = (m_iconsize-pix.width())/2;
632 int offy = (m_iconsize-pix.height())/2; 629 int offy = (m_iconsize-pix.height())/2;
633 if (offy<0) offy=0; 630 if (offy<0) offy=0;
634 pa.drawPixmap(offset,offy,pix); 631 pa.drawPixmap(offset,offy,pix);
635 pa.end(); 632 pa.end();
636 PPixmapCache::self()->insertImage( _path, p, m_iconsize, m_iconsize ); 633 PPixmapCache::self()->insertImage( _path, p, m_iconsize, m_iconsize );
637 item->setPixmap(p,true); 634 item->setPixmap(p,true);
638 } else { 635 } else {
639 PPixmapCache::self()->insertImage( _path, pix, m_iconsize, m_iconsize ); 636 PPixmapCache::self()->insertImage( _path, pix, m_iconsize, m_iconsize );
640 item->setPixmap(pix,true); 637 item->setPixmap(pix,true);
641 } 638 }
642 639
643 } else { 640 } else {
644 PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), m_iconsize, m_iconsize ); 641 PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), m_iconsize, m_iconsize );
645 } 642 }
646 g_stringPix.remove( _path ); 643 g_stringPix.remove( _path );
647 m_view->arrangeItemsInGrid(true); 644 m_view->arrangeItemsInGrid(true);
648} 645}
649 646
650 647
651/* 648/*
652 * FIXME rename 649 * FIXME rename
653 */ 650 */
654void PIconView::slotRename() { 651void PIconView::slotRename() {
655 652
656} 653}
657 654
658 655
659/* 656/*
660 * BEAM the current file 657 * BEAM the current file
661 */ 658 */
662void PIconView::slotBeam() { 659void PIconView::slotBeam() {
663 bool isDir; 660 bool isDir;
664 QString pa = currentFileName( isDir ); 661 QString pa = currentFileName( isDir );
665 if ( isDir && pa.isEmpty() ) 662 if ( isDir && pa.isEmpty() )
666 return; 663 return;
667 664
668 Ir* ir = new Ir( this ); 665 Ir* ir = new Ir( this );
669 connect( ir, SIGNAL(done(Ir*)), 666 connect( ir, SIGNAL(done(Ir*)),
670 this, SLOT(slotBeamDone(Ir*))); 667 this, SLOT(slotBeamDone(Ir*)));
671 ir->send(pa, tr( "Image" ) ); 668 ir->send(pa, tr( "Image" ) );
672} 669}
673 670
674/* 671/*
675 * BEAM done clean up 672 * BEAM done clean up
676 */ 673 */
677void PIconView::slotBeamDone( Ir* ir) { 674void PIconView::slotBeamDone( Ir* ir) {
678 delete ir; 675 delete ir;
679} 676}
680 677
681void PIconView::slotStart() { 678void PIconView::slotStart() {
682 m_view->viewport()->setUpdatesEnabled( false ); 679 m_view->viewport()->setUpdatesEnabled( false );
683} 680}
684 681
685void PIconView::slotEnd() { 682void PIconView::slotEnd() {
686 if ( m_updatet ) 683 if ( m_updatet )
687 m_view->arrangeItemsInGrid( ); 684 m_view->arrangeItemsInGrid( );
688 m_view->viewport()->setUpdatesEnabled( true ); 685 m_view->viewport()->setUpdatesEnabled( true );
689 m_updatet = false; 686 m_updatet = false;
690} 687}
691 688
692void PIconView::slotShowLast() 689void PIconView::slotShowLast()
693{ 690{
694 QIconViewItem* last_it = m_view->lastItem(); 691 QIconViewItem* last_it = m_view->lastItem();
695 if (!last_it) return; 692 if (!last_it) return;
696 m_view->setCurrentItem(last_it); 693 m_view->setCurrentItem(last_it);
697 IconViewItem* it = static_cast<IconViewItem*>( last_it ); 694 IconViewItem* it = static_cast<IconViewItem*>( last_it );
698 bool isDir = it->isDir(); 695 bool isDir = it->isDir();
699 QString name = it->path(); 696 QString name = it->path();
700 if (!isDir && !name.isEmpty()) { 697 if (!isDir && !name.isEmpty()) {
701 slotShowImage(name); 698 slotShowImage(name);
702 return; 699 return;
703 } 700 }
704 bool first_loop = true; 701 bool first_loop = true;
705 while(isDir==true) { 702 while(isDir==true) {
706 if (!first_loop) { 703 if (!first_loop) {
707 m_view->setCurrentItem(m_view->currentItem()->prevItem()); 704 m_view->setCurrentItem(m_view->currentItem()->prevItem());
708 } else { 705 } else {
709 first_loop = false; 706 first_loop = false;
710 } 707 }
711 name = prevFileName(isDir); 708 name = prevFileName(isDir);
712 } 709 }
713 710
714 if (name.isEmpty()) return; 711 if (name.isEmpty()) return;
715 /* if we got a name we have a prev item */ 712 /* if we got a name we have a prev item */
716 m_view->setCurrentItem(m_view->currentItem()->prevItem()); 713 m_view->setCurrentItem(m_view->currentItem()->prevItem());
717 slotShowImage(name); 714 slotShowImage(name);
718} 715}
719 716
720bool PIconView::slotShowFirst() 717bool PIconView::slotShowFirst()
721{ 718{
722 /* stop when reached - otherwise we may get an endless loop */ 719 /* stop when reached - otherwise we may get an endless loop */
723 QIconViewItem* first_it = m_view->firstItem(); 720 QIconViewItem* first_it = m_view->firstItem();
724 if (!first_it) return false; 721 if (!first_it) return false;
725 m_view->setCurrentItem(first_it); 722 m_view->setCurrentItem(first_it);
726 IconViewItem* it = static_cast<IconViewItem*>( first_it ); 723 IconViewItem* it = static_cast<IconViewItem*>( first_it );
727 bool isDir = it->isDir(); 724 bool isDir = it->isDir();
728 QString name = it->path(); 725 QString name = it->path();
729 if (!isDir && !name.isEmpty()) { 726 if (!isDir && !name.isEmpty()) {
730 slotShowImage(name); 727 slotShowImage(name);
731 return false; 728 return false;
732 } 729 }
733 bool first_loop = true; 730 bool first_loop = true;
734 while(isDir==true) { 731 while(isDir==true) {
735 /* if name is empty isDir is false, too. */ 732 /* if name is empty isDir is false, too. */
736 if (!first_loop) { 733 if (!first_loop) {
737 m_view->setCurrentItem(m_view->currentItem()->nextItem()); 734 m_view->setCurrentItem(m_view->currentItem()->nextItem());
738 } else { 735 } else {
739 first_loop = false; 736 first_loop = false;
740 } 737 }
741 name = nextFileName(isDir); 738 name = nextFileName(isDir);
742 } 739 }
743 if (name.isEmpty()) return false; 740 if (name.isEmpty()) return false;
744 /* if we got a name we have a next item */ 741 /* if we got a name we have a next item */
745 m_view->setCurrentItem(m_view->currentItem()->nextItem()); 742 m_view->setCurrentItem(m_view->currentItem()->nextItem());
746 slotShowImage(name); 743 slotShowImage(name);
747 return true; 744 return true;
748} 745}
749 746
750void PIconView::slotShowNext() 747void PIconView::slotShowNext()
751{ 748{
752 bool isDir = false; 749 bool isDir = false;
753 QString name = nextFileName(isDir); 750 QString name = nextFileName(isDir);
754 while (isDir==true) { 751 while (isDir==true) {
755 m_view->setCurrentItem(m_view->currentItem()->nextItem()); 752 m_view->setCurrentItem(m_view->currentItem()->nextItem());
756 name = nextFileName(isDir); 753 name = nextFileName(isDir);
757 } 754 }
758 if (name.isEmpty()) { 755 if (name.isEmpty()) {
759 slotShowFirst(); 756 slotShowFirst();
760 return; 757 return;
761 } 758 }
762 if (isDir) return; 759 if (isDir) return;
763 /* if we got a name we have a next item */ 760 /* if we got a name we have a next item */
764 m_view->setCurrentItem(m_view->currentItem()->nextItem()); 761 m_view->setCurrentItem(m_view->currentItem()->nextItem());
765 slotShowImage(name); 762 slotShowImage(name);
766} 763}
767 764
768void PIconView::slotShowPrev() 765void PIconView::slotShowPrev()
769{ 766{
770 bool isDir = false; 767 bool isDir = false;
771 QString name = prevFileName(isDir); 768 QString name = prevFileName(isDir);
772 while (isDir==true) { 769 while (isDir==true) {
773 /* if name is empty isDir is false, too. */ 770 /* if name is empty isDir is false, too. */
774 m_view->setCurrentItem(m_view->currentItem()->prevItem()); 771 m_view->setCurrentItem(m_view->currentItem()->prevItem());
775 name = prevFileName(isDir); 772 name = prevFileName(isDir);
776 } 773 }
777 if (name.isEmpty()) { 774 if (name.isEmpty()) {
778 slotShowLast(); 775 slotShowLast();
779 return; 776 return;
780 } 777 }
781 if (isDir) return; 778 if (isDir) return;
782 /* if we got a name we have a prev item */ 779 /* if we got a name we have a prev item */
783 m_view->setCurrentItem(m_view->currentItem()->prevItem()); 780 m_view->setCurrentItem(m_view->currentItem()->prevItem());
784 slotShowImage(name); 781 slotShowImage(name);
785} 782}
786 783
787void PIconView::slotShowImage() 784void PIconView::slotShowImage()
788{ 785{
789 bool isDir = false; 786 bool isDir = false;
790 QString name = currentFileName(isDir); 787 QString name = currentFileName(isDir);
791 if (isDir) return; 788 if (isDir) return;
792 slotShowImage( name ); 789 slotShowImage( name );
793} 790}
794void PIconView::slotShowImage( const QString& name) { 791void PIconView::slotShowImage( const QString& name) {
795 PDirLister *lister = currentView()->dirLister(); 792 PDirLister *lister = currentView()->dirLister();
796 QString r_name = lister->nameToFname(name); 793 QString r_name = lister->nameToFname(name);
797 emit sig_display(r_name); 794 emit sig_display(r_name);
798} 795}
799 796
800void PIconView::slotStartSlide() { 797void PIconView::slotStartSlide() {
801 bool isDir = false; 798 bool isDir = false;
802 QString name = currentFileName(isDir); 799 QString name = currentFileName(isDir);
803 if (isDir) { 800 if (isDir) {
804 if (!slotShowFirst()) 801 if (!slotShowFirst())
805 return; 802 return;
806 } else { 803 } else {
807 slotShowImage( name ); 804 slotShowImage( name );
808 } 805 }
809 int t = m_cfg->readNumEntry("slideshowtimeout", 2); 806 int t = m_cfg->readNumEntry("slideshowtimeout", 2);
810 emit sig_startslide(t); 807 emit sig_startslide(t);
811} 808}
812 809
813void PIconView::slotImageInfo() { 810void PIconView::slotImageInfo() {
814 bool isDir = false; 811 bool isDir = false;
815 QString name = currentFileName(isDir); 812 QString name = currentFileName(isDir);
816 if (isDir) return; 813 if (isDir) return;
817 slotImageInfo( name ); 814 slotImageInfo( name );
818} 815}
819 816
820void PIconView::slotImageInfo( const QString& name) { 817void PIconView::slotImageInfo( const QString& name) {
821 PDirLister *lister = currentView()->dirLister(); 818 PDirLister *lister = currentView()->dirLister();
822 QString r_name = lister->nameToFname(name); 819 QString r_name = lister->nameToFname(name);
823 emit sig_showInfo(r_name ); 820 emit sig_showInfo(r_name );
824} 821}
825 822
826 823
827void PIconView::slotChangeMode( int mode ) { 824void PIconView::slotChangeMode( int mode ) {
828 if ( mode >= 1 && mode <= 3 ) { 825 if ( mode >= 1 && mode <= 3 ) {
829 m_mode = mode; 826 m_mode = mode;
830 m_cfg->writeEntry("ListViewMode", m_mode); 827 m_cfg->writeEntry("ListViewMode", m_mode);
831 /* performance! */ 828 /* performance! */
832 m_view->clear(); 829 m_view->clear();
833 if (m_mode >1) { 830 if (m_mode >1) {
834 m_view->setResizeMode(QIconView::Adjust); 831 m_view->setResizeMode(QIconView::Adjust);
835 } else { 832 } else {
836 m_view->setResizeMode(QIconView::Fixed); 833 m_view->setResizeMode(QIconView::Fixed);
837 } 834 }
838 if (m_mode==1) { 835 if (m_mode==1) {
839 m_iconsize = 64; 836 m_iconsize = 64;
840 } else { 837 } else {
841 m_iconsize = m_cfg->readNumEntry("iconsize", 32); 838 m_iconsize = m_cfg->readNumEntry("iconsize", 32);
842 if (m_iconsize<12)m_iconsize = 12; 839 if (m_iconsize<12)m_iconsize = 12;
843 if (m_iconsize>64)m_iconsize = 64; 840 if (m_iconsize>64)m_iconsize = 64;
844 } 841 }
845 if (_dirPix){ 842 if (_dirPix){
846 delete _dirPix; 843 delete _dirPix;
847 _dirPix = 0; 844 _dirPix = 0;
848 } 845 }
849 if (_cpyPix){ 846 if (_cpyPix){
850 delete _cpyPix; 847 delete _cpyPix;
851 _cpyPix = 0; 848 _cpyPix = 0;
852 } 849 }
853 calculateGrid(); 850 calculateGrid();
854 slotReloadDir(); 851 slotReloadDir();
855 } 852 }
856} 853}
857 854
858 855
859void PIconView::resizeEvent( QResizeEvent* re ) { 856void PIconView::resizeEvent( QResizeEvent* re ) {
860 calculateGrid(re); 857 calculateGrid(re);
861 QVBox::resizeEvent( re ); 858 QVBox::resizeEvent( re );
862 //calculateGrid(); 859 //calculateGrid();
863} 860}
864 861
865 862
866void PIconView::calculateGrid(QResizeEvent* re) 863void PIconView::calculateGrid(QResizeEvent* re)
867{ 864{
868 int viewerWidth; 865 int viewerWidth;
869 if (re) { 866 if (re) {
870 viewerWidth=re->size().width(); 867 viewerWidth=re->size().width();
871 } else { 868 } else {
872 int dw = QApplication::desktop()->width(); 869 int dw = QApplication::desktop()->width();
873 viewerWidth = dw-style().scrollBarExtent().width(); 870 viewerWidth = dw-style().scrollBarExtent().width();
874 } 871 }
875 872
876 QIconView::ItemTextPos pos; 873 QIconView::ItemTextPos pos;
877 switch( m_mode ) { 874 switch( m_mode ) {
878 case 2: 875 case 2:
879 pos = QIconView::Bottom; 876 pos = QIconView::Bottom;
880 break; 877 break;
881 case 3: 878 case 3:
882 case 1: 879 case 1:
883 default: 880 default:
884 pos = QIconView::Right; 881 pos = QIconView::Right;
885 break; 882 break;
886 } 883 }
887 int cache = 0; 884 int cache = 0;
888 m_view->setItemTextPos( pos ); 885 m_view->setItemTextPos( pos );
889 switch (m_mode) { 886 switch (m_mode) {
890 case 2: 887 case 2:
891 m_view->setSpacing(2); 888 m_view->setSpacing(2);
892 m_view->setGridX(m_iconsize); 889 m_view->setGridX(m_iconsize);
893 m_view->setGridY(-1); 890 m_view->setGridY(-1);
894 cache = (int)((double)64/(double)m_iconsize*40.0); 891 cache = (int)((double)64/(double)m_iconsize*40.0);
895 odebug << "cache size: " << cache << oendl; 892 odebug << "cache size: " << cache << oendl;
896 PPixmapCache::self()->setMaxImages(cache); 893 PPixmapCache::self()->setMaxImages(cache);
897 break; 894 break;
898 case 3: 895 case 3:
899 m_view->setSpacing(10); 896 m_view->setSpacing(10);
900 m_view->setGridX( fontMetrics().width("testimage.jpg")+20); 897 m_view->setGridX( fontMetrics().width("testimage.jpg")+20);
901 m_view->setGridY(8); 898 m_view->setGridY(8);
902 PPixmapCache::self()->setMaxImages(2); 899 PPixmapCache::self()->setMaxImages(2);
903 break; 900 break;
904 case 1: 901 case 1:
905 default: 902 default:
906 m_view->setSpacing(10); 903 m_view->setSpacing(10);
907 m_view->setGridX( viewerWidth-3*m_view->spacing()); 904 m_view->setGridX( viewerWidth-3*m_view->spacing());
908 m_view->setGridY( fontMetrics().height()*2+40 ); 905 m_view->setGridY( fontMetrics().height()*2+40 );
909 PPixmapCache::self()->setMaxImages(20); 906 PPixmapCache::self()->setMaxImages(20);
910 break; 907 break;
911 } 908 }
912} 909}
diff --git a/noncore/graphics/opie-eye/gui/messagebox.cpp b/noncore/graphics/opie-eye/gui/messagebox.cpp
new file mode 100644
index 0000000..c84e4e1
--- a/dev/null
+++ b/noncore/graphics/opie-eye/gui/messagebox.cpp
@@ -0,0 +1,119 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2004 Holger Hans Peter <freyther@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include "messagebox.h"
30
31#include <qapplication.h>
32#include <qmessagebox.h>
33
34/*
35 * LGPLv2 KDE Project kstringhandler.cpp
36 */
37template<class T>
38inline const T& kClamp( const T& x, const T& low, const T& high )
39{
40 if ( x < low ) return low;
41 else if ( high < x ) return high;
42 else return x;
43}
44
45/**
46 * dependant on the screen rotation place the dots
47 */
48static QString g_insert_ldot( const QString& name, const QFontMetrics& fontMetrics ) {
49 uint maxPixels = qApp->desktop()->width()-90;
50 uint nameWidth = fontMetrics.width(name);
51
52 if (maxPixels < nameWidth) {
53 QString tmp = name;
54 const uint em = fontMetrics.maxWidth();
55 maxPixels -= fontMetrics.width("...");
56
57 while (maxPixels < nameWidth && !tmp.isEmpty()) {
58 int delta = (nameWidth - maxPixels) / em;
59 delta = kClamp(delta, 1, delta); // no max
60
61 tmp.remove(0, delta);
62 nameWidth = fontMetrics.width(tmp);
63 }
64
65 return ("..." + tmp);
66 }
67
68 return name;
69}
70
71/**
72 *
73 * #FIXME Write Own message box to be more independant on sizes
74 * #FIXME Ask translator how to make the sentence more robust
75 *
76 * \brief replacement for QPEMessageBox::confirmDelete
77 *
78 * If you want to delete a file and the path is too long to fit
79 * on the screen \ldots is inserted in the middle of the string
80 * to fit on the screen. This allows the user still to identify
81 * the file.
82 *
83 * @param parent The parent of this MessageBox
84 * @param type The type of the object to delte. i.e 'the image'
85 * @param object The 'object' to be deleted
86 * @param caption An optional caption for the box
87 *
88 */
89bool OMessageBox::confirmDelete( QWidget* parent, const QString& type, const QString& object,
90 const QString& _caption ) {
91 /*
92 * create a messagebox to get the font metrics
93 */
94 QMessageBox msg( QString::null, QString::null,
95 QMessageBox::Warning, QMessageBox::Yes,
96 QMessageBox::No|QMessageBox::Default|QMessageBox::Escape,
97 QMessageBox::NoButton,
98 parent, "OMessageBox::confirmDelete" );
99
100 /*
101 * Create the Message and Caption
102 */
103 QString msga = QObject::tr("<qt>Are you sure you want to delete %1<br> %2?</qt>" )
104 .arg( type )
105 .arg( g_insert_ldot( object, msg.fontMetrics() ) );
106 QString caption = _caption.isEmpty() ?
107 QObject::tr( "Confirm Deletion" ) : _caption;
108
109 msg.setText( msga );
110 msg.setCaption( caption );
111 msg.setIcon( QMessageBox::Warning );
112 msg.adjustSize();
113
114 /*
115 * Warn the user that he will delete
116 */
117 int ret = msg.exec();
118 return ( ret == QMessageBox::Yes );
119}
diff --git a/noncore/graphics/opie-eye/gui/messagebox.h b/noncore/graphics/opie-eye/gui/messagebox.h
new file mode 100644
index 0000000..a0e6fa0
--- a/dev/null
+++ b/noncore/graphics/opie-eye/gui/messagebox.h
@@ -0,0 +1,57 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2004 Holger Hans Peter <freyther@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef OPIE_UI_OMESSAGE_BOX_H
30#define OPIE_UI_OMEESAGE_BOX_H
31
32#include <qstring.h>
33
34class QWidget;
35
36/*
37 * ### to be moved to OpieUI
38 * ### move KDEs KStringHandler to OpieCore
39 * ### once done
40 * FIXME
41 */
42
43/**
44 * \brief Custom and common Opie MessageBoxes
45 *
46 * A set of static methods to open special MessageBoxes.
47 */
48class OMessageBox {
49public:
50 static bool confirmDelete(QWidget *parent,
51 const QString& type,
52 const QString& object,
53 const QString & caption = QString::null);
54
55};
56
57#endif