-rw-r--r-- | noncore/graphics/opie-eye/gui/gui.pro | 6 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 13 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/messagebox.cpp | 119 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/messagebox.h | 57 |
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 @@ | |||
1 | HEADERS += gui/filesystem.h \ | 1 | HEADERS += 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 | ||
9 | SOURCES += gui/filesystem.cpp \ | 10 | SOURCES += 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,627 +1,624 @@ | |||
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 | ||
36 | using Opie::Core::OKeyConfigItem; | 37 | using 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 | */ |
41 | namespace { | 42 | namespace { |
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 | */ |
188 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | 189 | PIconView::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 | ||
232 | void PIconView::setDoccalled(bool how) | 233 | void 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 | */ |
240 | PIconView::~PIconView() { | 241 | PIconView::~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 | ||
248 | Opie::Core::OKeyConfigManager* PIconView::manager() { | 249 | Opie::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 | */ |
257 | void PIconView::initKeys() { | 258 | void 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 | */ |
295 | void PIconView::slotDirUp() | 296 | void 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 | */ |
303 | void PIconView::slotChangeDir(const QString& path) { | 304 | void 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 | */ |
339 | QString PIconView::currentFileName(bool &isDir)const { | 340 | QString 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 | ||
350 | QString PIconView::nextFileName(bool &isDir)const | 351 | QString 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 | ||
364 | QString PIconView::prevFileName(bool &isDir)const{ | 365 | QString 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 | ||
377 | void PIconView::slotTrash() { | 378 | void 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 | */ |
396 | void PIconView::loadViews() { | 396 | void 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 | ||
403 | void PIconView::resetView() { | 403 | void 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 | ||
431 | void PIconView::polish() | 431 | void 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 | */ |
458 | void PIconView::slotViewChanged( int i) { | 455 | void 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 | ||
517 | void PIconView::slotReloadDir() { | 514 | void 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 | */ |
525 | void PIconView::addFolders( const QStringList& lst) { | 522 | void 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 | ||
535 | void PIconView::addFiles( const QStringList& lst) { | 532 | void 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 | */ |
567 | void PIconView::slotClicked(QIconViewItem* _it) { | 564 | void 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 | */ |
583 | void PIconView::slotRetrun( QIconViewItem *_it ) { | 580 | void 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 | */ |
598 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { | 595 | void 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 | */ |
617 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { | 614 | void 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) { |
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 | */ | ||
37 | template<class T> | ||
38 | inline 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 | */ | ||
48 | static 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 | */ | ||
89 | bool 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 | |||
34 | class 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 | */ | ||
48 | class OMessageBox { | ||
49 | public: | ||
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 | ||