author | zecke <zecke> | 2002-06-26 20:41:06 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-26 20:41:06 (UTC) |
commit | a078163b38383870dd5a659c1f0964e1238867b3 (patch) (unidiff) | |
tree | 68a517f1adc23cc0fa70b979fe772bcaa53790ab | |
parent | c229565c40d478555a9ed0aa4910b9ab8181884c (diff) | |
download | opie-a078163b38383870dd5a659c1f0964e1238867b3.zip opie-a078163b38383870dd5a659c1f0964e1238867b3.tar.gz opie-a078163b38383870dd5a659c1f0964e1238867b3.tar.bz2 |
OFileSelector is now a complete drop in replacement
of the QPE fileselector
-rw-r--r-- | libopie/ofileselector.cc | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index 98290e0..824acf2 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -1,1258 +1,1282 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include <qcheckbox.h> | 3 | #include <qcheckbox.h> |
4 | #include <qcombobox.h> | 4 | #include <qcombobox.h> |
5 | #include <qheader.h> | 5 | #include <qheader.h> |
6 | #include <qlabel.h> | 6 | #include <qlabel.h> |
7 | #include <qabstractlayout.h> | 7 | #include <qabstractlayout.h> |
8 | #include <qlayout.h> | 8 | #include <qlayout.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qlistview.h> | 10 | #include <qlistview.h> |
11 | #include <qmessagebox.h> | 11 | #include <qmessagebox.h> |
12 | #include <qpainter.h> | 12 | #include <qpainter.h> |
13 | #include <qpushbutton.h> | 13 | #include <qpushbutton.h> |
14 | #include <qwidgetstack.h> | 14 | #include <qwidgetstack.h> |
15 | #include <qpopupmenu.h> | 15 | #include <qpopupmenu.h> |
16 | #include <qdir.h> | 16 | #include <qdir.h> |
17 | #include <qfile.h> | 17 | #include <qfile.h> |
18 | #include <qfileinfo.h> | 18 | #include <qfileinfo.h> |
19 | #include <qtimer.h> | 19 | #include <qtimer.h> |
20 | 20 | ||
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/applnk.h> | 22 | #include <qpe/applnk.h> |
23 | #include <qpe/fileselector.h> | 23 | #include <qpe/fileselector.h> |
24 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | #include <qpe/mimetype.h> | 25 | #include <qpe/mimetype.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/storage.h> | 27 | #include <qpe/storage.h> |
28 | 28 | ||
29 | #include <unistd.h> | 29 | #include <unistd.h> |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | #include <sys/stat.h> | 31 | #include <sys/stat.h> |
32 | 32 | ||
33 | #include "ofileselector.h" | 33 | #include "ofileselector.h" |
34 | 34 | ||
35 | 35 | ||
36 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | 36 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; |
37 | 37 | ||
38 | namespace { | 38 | namespace { |
39 | int indexByString( const QComboBox *box, const QString &str ){ | 39 | int indexByString( const QComboBox *box, const QString &str ){ |
40 | int index= 0; | 40 | int index= 0; |
41 | for(int i= 0; i < box->count(); i++ ){ | 41 | for(int i= 0; i < box->count(); i++ ){ |
42 | if( str == box->text(i ) ){ | 42 | if( str == box->text(i ) ){ |
43 | index= i; | 43 | index= i; |
44 | break; | 44 | break; |
45 | } | 45 | } |
46 | } | 46 | } |
47 | return index; | 47 | return index; |
48 | } | 48 | } |
49 | class OFileSelectorItem : public QListViewItem { | 49 | class OFileSelectorItem : public QListViewItem { |
50 | public: | 50 | public: |
51 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | 51 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, |
52 | const QString &date, const QString &size, const QString &mDir, | 52 | const QString &date, const QString &size, const QString &mDir, |
53 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { | 53 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { |
54 | setPixmap(0, pixmap ); | 54 | setPixmap(0, pixmap ); |
55 | setText(1, path ); | 55 | setText(1, path ); |
56 | setText(2, size ); | 56 | setText(2, size ); |
57 | setText(3, date ); | 57 | setText(3, date ); |
58 | //setText(4, mDir ); | 58 | //setText(4, mDir ); |
59 | m_dir = mDir; | 59 | m_dir = mDir; |
60 | dir = isDir; | 60 | dir = isDir; |
61 | mLocked = isLocked; | 61 | mLocked = isLocked; |
62 | } | 62 | } |
63 | bool isLocked() const{ | 63 | bool isLocked() const{ |
64 | return mLocked; | 64 | return mLocked; |
65 | } | 65 | } |
66 | QString directory()const{ | 66 | QString directory()const{ |
67 | return m_dir; | 67 | return m_dir; |
68 | } | 68 | } |
69 | bool isDir()const{ | 69 | bool isDir()const{ |
70 | return dir; | 70 | return dir; |
71 | } | 71 | } |
72 | QString path()const{ | 72 | QString path()const{ |
73 | return text(1 ); | 73 | return text(1 ); |
74 | } | 74 | } |
75 | QString key(int id, bool )const { | 75 | QString key(int id, bool )const { |
76 | QString ke; | 76 | QString ke; |
77 | if( id == 0 || id == 1 ){ // name | 77 | if( id == 0 || id == 1 ){ // name |
78 | if( dir ){ | 78 | if( dir ){ |
79 | ke.append("0" ); | 79 | ke.append("0" ); |
80 | ke.append( text(1) ); | 80 | ke.append( text(1) ); |
81 | }else{ | 81 | }else{ |
82 | ke.append("1" ); | 82 | ke.append("1" ); |
83 | ke.append( text(1) ); | 83 | ke.append( text(1) ); |
84 | } | 84 | } |
85 | }else if( id == 2 ){ // size | 85 | }else if( id == 2 ){ // size |
86 | return text(2); | 86 | return text(2); |
87 | }else if( id == 3 ){ // date | 87 | }else if( id == 3 ){ // date |
88 | return text(3); | 88 | return text(3); |
89 | } | 89 | } |
90 | return ke; | 90 | return ke; |
91 | }; | 91 | }; |
92 | private: | 92 | private: |
93 | bool mLocked:1; | 93 | bool mLocked:1; |
94 | bool dir:1; | 94 | bool dir:1; |
95 | QString m_dir; | 95 | QString m_dir; |
96 | }; | 96 | }; |
97 | }; | 97 | }; |
98 | 98 | ||
99 | 99 | ||
100 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, | 100 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, |
101 | const QString &dirName, | 101 | const QString &dirName, |
102 | const QString &fileName, | 102 | const QString &fileName, |
103 | const QMap<QString,QStringList>& mimeTypes) | 103 | const QMap<QString,QStringList>& mimeTypes) |
104 | : QWidget( wid, "OFileSelector") | 104 | : QWidget( wid, "OFileSelector") |
105 | { | 105 | { |
106 | m_mimetypes = mimeTypes; | 106 | m_mimetypes = mimeTypes; |
107 | if (mode == SAVE ) | 107 | if (mode == SAVE ) |
108 | m_name = fileName; | 108 | m_name = fileName; |
109 | initVars(); | 109 | initVars(); |
110 | m_mode = mode; | 110 | m_mode = mode; |
111 | m_selector = selector; | 111 | m_selector = selector; |
112 | m_currentDir = dirName; | 112 | m_currentDir = dirName; |
113 | init(); | 113 | init(); |
114 | //QTimer::singleShot(6*1000, this, SLOT( slotTest() ) ); | 114 | //QTimer::singleShot(6*1000, this, SLOT( slotTest() ) ); |
115 | } | 115 | } |
116 | 116 | ||
117 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, | 117 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, |
118 | const char *name, bool newVisible, | 118 | const char *name, bool newVisible, |
119 | bool closeVisible ) | 119 | bool closeVisible ) |
120 | : QWidget( parent, name ) | 120 | : QWidget( parent, name ) |
121 | { | 121 | { |
122 | if (!mimeFilter.isEmpty() ) { | 122 | if (!mimeFilter.isEmpty() ) { |
123 | QStringList list = QStringList::split(";", mimeFilter ); | 123 | QStringList list = QStringList::split(";", mimeFilter ); |
124 | m_mimetypes.insert(mimeFilter, list ); | 124 | m_mimetypes.insert(mimeFilter, list ); |
125 | } | 125 | } |
126 | initVars(); | 126 | initVars(); |
127 | m_currentDir = QPEApplication::documentDir(); | 127 | m_currentDir = QPEApplication::documentDir(); |
128 | m_mode = OPEN; | 128 | m_mode = FILESELECTOR; |
129 | m_selector = NORMAL; | 129 | m_selector = NORMAL; |
130 | m_shClose = closeVisible; | 130 | m_shClose = closeVisible; |
131 | m_shNew = newVisible; | 131 | m_shNew = newVisible; |
132 | m_shLne = false; | 132 | m_shLne = false; |
133 | m_shPerm = false; | 133 | m_shPerm = false; |
134 | m_shYesNo = false; | 134 | m_shYesNo = false; |
135 | init(); | 135 | init(); |
136 | 136 | ||
137 | 137 | ||
138 | } | 138 | } |
139 | 139 | ||
140 | OFileSelector::~OFileSelector() | 140 | OFileSelector::~OFileSelector() |
141 | { | 141 | { |
142 | 142 | ||
143 | 143 | ||
144 | } | 144 | } |
145 | 145 | ||
146 | void OFileSelector::setNewVisible( bool visible ) | 146 | void OFileSelector::setNewVisible( bool visible ) |
147 | { | 147 | { |
148 | m_shNew = visible; | 148 | m_shNew = visible; |
149 | if( m_selector == NORMAL ){ | 149 | if( m_selector == NORMAL ){ |
150 | delete m_select; | 150 | delete m_select; |
151 | // we need to initialize but keep the selected mimetype | 151 | // we need to initialize but keep the selected mimetype |
152 | QString mime = currentMimeType(); | 152 | QString mime = currentMimeType(); |
153 | m_select = new FileSelector( mime , | 153 | m_select = new FileSelector( mime , |
154 | m_stack, "fileselector", | 154 | m_stack, "fileselector", |
155 | m_shNew, m_shClose); | 155 | m_shNew, m_shClose); |
156 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 156 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
157 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 157 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
158 | connect(m_select, SIGNAL(closeMe() ), | ||
159 | this, SIGNAL(closeMe() ) ); | ||
158 | //connect to close me and other signals as well | 160 | //connect to close me and other signals as well |
159 | m_stack->addWidget( m_select, NORMAL ); | 161 | m_stack->addWidget( m_select, NORMAL ); |
160 | }else{ | 162 | }else{ |
161 | m_new->show(); | 163 | m_new->show(); |
162 | } | 164 | } |
163 | } | 165 | } |
164 | void OFileSelector::setCloseVisible( bool visible ) | 166 | void OFileSelector::setCloseVisible( bool visible ) |
165 | { | 167 | { |
166 | m_shClose = visible; | 168 | m_shClose = visible; |
167 | if( m_selector == NORMAL ){ | 169 | if( m_selector == NORMAL ){ |
168 | setNewVisible( m_shNew ); // yeah baby | 170 | setNewVisible( m_shNew ); // yeah baby |
169 | }else{ | 171 | }else{ |
170 | m_close->show(); | 172 | m_close->show(); |
171 | } | 173 | } |
172 | } | 174 | } |
173 | void OFileSelector::reread() | 175 | void OFileSelector::reread() |
174 | { | 176 | { |
175 | if( m_selector == NORMAL ){ | 177 | if( m_selector == NORMAL ){ |
176 | setNewVisible( m_shNew ); // make it a initializeSelector | 178 | setNewVisible( m_shNew ); // make it a initializeSelector |
177 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 179 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
178 | reparse(); | 180 | reparse(); |
179 | //}else{ | 181 | //}else{ |
180 | //; | 182 | //; |
181 | } | 183 | } |
182 | } | 184 | } |
183 | 185 | ||
184 | const DocLnk *OFileSelector::selected() | 186 | const DocLnk *OFileSelector::selected() |
185 | { | 187 | { |
186 | if( m_selector == NORMAL ){ | 188 | if( m_selector == NORMAL ){ |
187 | return m_select->selected(); | 189 | return m_select->selected(); |
188 | }else{ | 190 | }else{ |
189 | DocLnk *lnk = new DocLnk(selectedDocument() ); | 191 | DocLnk *lnk = new DocLnk(selectedDocument() ); |
190 | return lnk; | 192 | return lnk; |
191 | } | 193 | } |
192 | } | 194 | } |
193 | 195 | ||
194 | void OFileSelector::setYesCancelVisible( bool show ) | 196 | void OFileSelector::setYesCancelVisible( bool show ) |
195 | { | 197 | { |
196 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( | 198 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( |
197 | m_shYesNo = show; | 199 | m_shYesNo = show; |
198 | if( m_shYesNo ) | 200 | if( m_shYesNo ) |
199 | m_boxOk->show(); | 201 | m_boxOk->show(); |
200 | else | 202 | else |
201 | m_boxOk->hide(); | 203 | m_boxOk->hide(); |
202 | 204 | ||
203 | } | 205 | } |
204 | void OFileSelector::setToolbarVisible( bool show ) | 206 | void OFileSelector::setToolbarVisible( bool show ) |
205 | { | 207 | { |
206 | m_shTool = show; | 208 | m_shTool = show; |
207 | initializeListView(); // FIXME see above waste of memory | 209 | initializeListView(); // FIXME see above waste of memory |
208 | if(!m_shTool ){ | 210 | if(!m_shTool ){ |
209 | m_location->hide(); | 211 | m_location->hide(); |
210 | m_up->hide(); | 212 | m_up->hide(); |
211 | m_homeButton->hide(); | 213 | m_homeButton->hide(); |
212 | m_docButton->hide(); | 214 | m_docButton->hide(); |
213 | }else{ | 215 | }else{ |
214 | m_location->show(); | 216 | m_location->show(); |
215 | m_up->show(); | 217 | m_up->show(); |
216 | m_homeButton->show(); | 218 | m_homeButton->show(); |
217 | m_docButton->show(); | 219 | m_docButton->show(); |
218 | } | 220 | } |
219 | } | 221 | } |
220 | void OFileSelector::setPermissionBarVisible( bool show ) | 222 | void OFileSelector::setPermissionBarVisible( bool show ) |
221 | { | 223 | { |
222 | m_shPerm = show; | 224 | m_shPerm = show; |
223 | initializePerm(); | 225 | initializePerm(); |
224 | if( m_shPerm ) | 226 | if( m_shPerm ) |
225 | m_checkPerm->show(); | 227 | m_checkPerm->show(); |
226 | else | 228 | else |
227 | m_checkPerm->hide(); | 229 | m_checkPerm->hide(); |
228 | } | 230 | } |
229 | void OFileSelector::setLineEditVisible( bool show ) | 231 | void OFileSelector::setLineEditVisible( bool show ) |
230 | { | 232 | { |
231 | if( show ){ | 233 | if( show ){ |
232 | initializeName(); | 234 | initializeName(); |
233 | m_boxName->show(); | 235 | m_boxName->show(); |
234 | }else{ | 236 | }else{ |
235 | if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go | 237 | if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go |
236 | m_boxName->hide(); | 238 | m_boxName->hide(); |
237 | } | 239 | } |
238 | } | 240 | } |
239 | m_shLne = show; | 241 | m_shLne = show; |
240 | } | 242 | } |
241 | 243 | ||
242 | void OFileSelector::setChooserVisible( bool show ) | 244 | void OFileSelector::setChooserVisible( bool show ) |
243 | { | 245 | { |
244 | m_shChooser = show; | 246 | m_shChooser = show; |
245 | initializeChooser(); | 247 | initializeChooser(); |
246 | if( m_shChooser ){ | 248 | if( m_shChooser ){ |
247 | m_boxView->hide(); | 249 | m_boxView->hide(); |
248 | }else{ | 250 | }else{ |
249 | m_boxView->show(); | 251 | m_boxView->show(); |
250 | } | 252 | } |
251 | } | 253 | } |
252 | 254 | ||
253 | QCheckBox* OFileSelector::permissionCheckbox() | 255 | QCheckBox* OFileSelector::permissionCheckbox() |
254 | { | 256 | { |
255 | if( m_selector == NORMAL ) | 257 | if( m_selector == NORMAL ) |
256 | return 0l; | 258 | return 0l; |
257 | else | 259 | else |
258 | return m_checkPerm; | 260 | return m_checkPerm; |
259 | } | 261 | } |
260 | bool OFileSelector::setPermission()const | 262 | bool OFileSelector::setPermission()const |
261 | { | 263 | { |
262 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); | 264 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); |
263 | } | 265 | } |
264 | void OFileSelector::setPermissionChecked( bool check ) | 266 | void OFileSelector::setPermissionChecked( bool check ) |
265 | { | 267 | { |
266 | if( m_checkPerm ) | 268 | if( m_checkPerm ) |
267 | m_checkPerm->setChecked( check ); | 269 | m_checkPerm->setChecked( check ); |
268 | } | 270 | } |
269 | 271 | ||
270 | void OFileSelector::setMode(int mode) // FIXME do direct raising | 272 | void OFileSelector::setMode(int mode) // FIXME do direct raising |
271 | { | 273 | { |
272 | m_mode = mode; | 274 | m_mode = mode; |
273 | if( m_selector == NORMAL ) | 275 | if( m_selector == NORMAL ) |
274 | return; | 276 | return; |
275 | } | 277 | } |
276 | void OFileSelector::setShowDirs(bool ) | 278 | void OFileSelector::setShowDirs(bool ) |
277 | { | 279 | { |
278 | m_dir = true; | 280 | m_dir = true; |
279 | reparse(); | 281 | reparse(); |
280 | } | 282 | } |
281 | void OFileSelector::setCaseSensetive(bool caSe ) | 283 | void OFileSelector::setCaseSensetive(bool caSe ) |
282 | { | 284 | { |
283 | m_case = caSe; | 285 | m_case = caSe; |
284 | reparse(); | 286 | reparse(); |
285 | } | 287 | } |
286 | void OFileSelector::setShowFiles(bool show ) | 288 | void OFileSelector::setShowFiles(bool show ) |
287 | { | 289 | { |
288 | m_files = show; | 290 | m_files = show; |
289 | reparse(); | 291 | reparse(); |
290 | } | 292 | } |
291 | /// | 293 | /// |
292 | bool OFileSelector::cd(const QString &path ) | 294 | bool OFileSelector::cd(const QString &path ) |
293 | { | 295 | { |
294 | m_currentDir = path; | 296 | m_currentDir = path; |
295 | reparse(); | 297 | reparse(); |
296 | return true; | 298 | return true; |
297 | } | 299 | } |
298 | void OFileSelector::setSelector(int mode ) | 300 | void OFileSelector::setSelector(int mode ) |
299 | { | 301 | { |
300 | QString text; | 302 | QString text; |
301 | switch( mode ){ | 303 | switch( mode ){ |
302 | case NORMAL: | 304 | case NORMAL: |
303 | text = tr("Documents"); | 305 | text = tr("Documents"); |
304 | break; | 306 | break; |
305 | case EXTENDED: | 307 | case EXTENDED: |
306 | text = tr("Files"); | 308 | text = tr("Files"); |
307 | break; | 309 | break; |
308 | case EXTENDED_ALL: | 310 | case EXTENDED_ALL: |
309 | text = tr("All Files"); | 311 | text = tr("All Files"); |
310 | break; | 312 | break; |
311 | } | 313 | } |
312 | slotViewCheck( text ); | 314 | slotViewCheck( text ); |
313 | } | 315 | } |
314 | 316 | ||
315 | void OFileSelector::setPopupMenu(QPopupMenu *popup ) | 317 | void OFileSelector::setPopupMenu(QPopupMenu *popup ) |
316 | { | 318 | { |
317 | m_custom = popup; | 319 | m_custom = popup; |
318 | m_showPopup = true; | 320 | m_showPopup = true; |
319 | } | 321 | } |
320 | 322 | ||
321 | //void OFileSelector::updateL | 323 | //void OFileSelector::updateL |
322 | 324 | ||
323 | QString OFileSelector::selectedName() const | 325 | QString OFileSelector::selectedName() const |
324 | { | 326 | { |
325 | QString name; | 327 | QString name; |
326 | if( m_selector == NORMAL ){ | 328 | if( m_selector == NORMAL ){ |
327 | const DocLnk *lnk = m_select->selected(); | 329 | const DocLnk *lnk = m_select->selected(); |
328 | name = lnk->file(); | 330 | name = lnk->file(); |
329 | delete lnk; | 331 | delete lnk; |
330 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 332 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
331 | QListViewItem *item = m_View->currentItem(); | 333 | QListViewItem *item = m_View->currentItem(); |
332 | if( item != 0 ) | 334 | if( item != 0 ) |
333 | name = m_currentDir + "/" + item->text( 1 ); | 335 | name = m_currentDir + "/" + item->text( 1 ); |
334 | }else { // installed view | 336 | }else { // installed view |
335 | ; | 337 | ; |
336 | } | 338 | } |
337 | return name; | 339 | return name; |
338 | } | 340 | } |
339 | QStringList OFileSelector::selectedNames()const | 341 | QStringList OFileSelector::selectedNames()const |
340 | { | 342 | { |
341 | QStringList list; | 343 | QStringList list; |
342 | if( m_selector == NORMAL ){ | 344 | if( m_selector == NORMAL ){ |
343 | list << selectedName(); | 345 | list << selectedName(); |
344 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 346 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
345 | list << selectedName(); // FIXME implement multiple Selections | 347 | list << selectedName(); // FIXME implement multiple Selections |
346 | } | 348 | } |
347 | return list; | 349 | return list; |
348 | } | 350 | } |
349 | /** If mode is set to the Dir selection this will return the selected path. | 351 | /** If mode is set to the Dir selection this will return the selected path. |
350 | * | 352 | * |
351 | * | 353 | * |
352 | */ | 354 | */ |
353 | QString OFileSelector::selectedPath()const | 355 | QString OFileSelector::selectedPath()const |
354 | { | 356 | { |
355 | QString path; | 357 | QString path; |
356 | if( m_selector == NORMAL ){ | 358 | if( m_selector == NORMAL ){ |
357 | path = QPEApplication::documentDir(); | 359 | path = QPEApplication::documentDir(); |
358 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 360 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
359 | ; | 361 | ; |
360 | } | 362 | } |
361 | return path; | 363 | return path; |
362 | } | 364 | } |
363 | QStringList OFileSelector::selectedPaths() const | 365 | QStringList OFileSelector::selectedPaths() const |
364 | { | 366 | { |
365 | QStringList list; | 367 | QStringList list; |
366 | list << selectedPath(); | 368 | list << selectedPath(); |
367 | return list; | 369 | return list; |
368 | } | 370 | } |
369 | QString OFileSelector::directory()const | 371 | QString OFileSelector::directory()const |
370 | { | 372 | { |
371 | if( m_selector == NORMAL ) | 373 | if( m_selector == NORMAL ) |
372 | return QPEApplication::documentDir(); | 374 | return QPEApplication::documentDir(); |
373 | 375 | ||
374 | return QDir(m_currentDir).absPath(); | 376 | return QDir(m_currentDir).absPath(); |
375 | } | 377 | } |
376 | 378 | ||
377 | int OFileSelector::fileCount() | 379 | int OFileSelector::fileCount() |
378 | { | 380 | { |
379 | int count; | 381 | int count; |
380 | switch( m_selector ){ | 382 | switch( m_selector ){ |
381 | case NORMAL: | 383 | case NORMAL: |
382 | count = m_select->fileCount(); | 384 | count = m_select->fileCount(); |
383 | break; | 385 | break; |
384 | //case CUSTOM: | 386 | //case CUSTOM: |
385 | case EXTENDED: | 387 | case EXTENDED: |
386 | case EXTENDED_ALL: | 388 | case EXTENDED_ALL: |
387 | default: | 389 | default: |
388 | count = m_View->childCount(); | 390 | count = m_View->childCount(); |
389 | break; | 391 | break; |
390 | } | 392 | } |
391 | return count; | 393 | return count; |
392 | } | 394 | } |
393 | DocLnk OFileSelector::selectedDocument() const | 395 | DocLnk OFileSelector::selectedDocument() const |
394 | { | 396 | { |
395 | DocLnk lnk; | 397 | DocLnk lnk; |
396 | switch( m_selector ){ | 398 | switch( m_selector ){ |
397 | case NORMAL:{ | 399 | case NORMAL:{ |
398 | const DocLnk *lnk2 = m_select->selected(); | 400 | const DocLnk *lnk2 = m_select->selected(); |
399 | lnk = DocLnk(*lnk2 ); // copy | 401 | lnk = DocLnk(*lnk2 ); // copy |
400 | delete lnk2; | 402 | delete lnk2; |
401 | break; | 403 | break; |
402 | } | 404 | } |
403 | case EXTENDED: | 405 | case EXTENDED: |
404 | case EXTENDED_ALL: | 406 | case EXTENDED_ALL: |
405 | default: | 407 | default: |
406 | lnk = DocLnk( selectedName() ); // new DocLnk | 408 | lnk = DocLnk( selectedName() ); // new DocLnk |
407 | break; | 409 | break; |
408 | } | 410 | } |
409 | return lnk; | 411 | return lnk; |
410 | } | 412 | } |
411 | QValueList<DocLnk> OFileSelector::selectedDocuments() const | 413 | QValueList<DocLnk> OFileSelector::selectedDocuments() const |
412 | { | 414 | { |
413 | QValueList<DocLnk> docs; | 415 | QValueList<DocLnk> docs; |
414 | docs.append( selectedDocument() ); | 416 | docs.append( selectedDocument() ); |
415 | return docs; | 417 | return docs; |
416 | } | 418 | } |
417 | 419 | ||
418 | 420 | ||
419 | // slots internal | 421 | // slots internal |
420 | 422 | ||
421 | void OFileSelector::slotOk() | 423 | void OFileSelector::slotOk() |
422 | { | 424 | { |
423 | emit ok(); | 425 | emit ok(); |
424 | } | 426 | } |
425 | void OFileSelector::slotCancel() | 427 | void OFileSelector::slotCancel() |
426 | { | 428 | { |
427 | emit cancel(); | 429 | emit cancel(); |
428 | } | 430 | } |
429 | void OFileSelector::slotViewCheck(const QString &sel) | 431 | void OFileSelector::slotViewCheck(const QString &sel) |
430 | { | 432 | { |
431 | if( sel == tr("Documents" ) ){ | 433 | if( sel == tr("Documents" ) ){ |
432 | if( m_select == 0 ){ | 434 | if( m_select == 0 ){ |
433 | // autMime? fix cause now we use All and not the current | 435 | // autMime? fix cause now we use All and not the current |
434 | // yes currentMime fixes that for us | 436 | // yes currentMime fixes that for us |
435 | QString mime = currentMimeType(); | 437 | QString mime = currentMimeType(); |
436 | m_select = new FileSelector(mime, | 438 | m_select = new FileSelector(mime, |
437 | m_stack, "fileselector", | 439 | m_stack, "fileselector", |
438 | FALSE, FALSE); | 440 | m_shNew, m_shClose); |
439 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 441 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
440 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 442 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
443 | connect(m_select, SIGNAL(closeMe() ), | ||
444 | this, SIGNAL(closeMe() ) ); | ||
441 | //connect to close me and other signals as well | 445 | //connect to close me and other signals as well |
442 | 446 | ||
443 | m_stack->addWidget( m_select, NORMAL ); | 447 | m_stack->addWidget( m_select, NORMAL ); |
444 | } | 448 | } |
445 | m_stack->raiseWidget( NORMAL ); | 449 | m_stack->raiseWidget( NORMAL ); |
446 | m_selector = NORMAL; | 450 | m_selector = NORMAL; |
447 | }else if( sel == tr("Files") ){ | 451 | }else if( sel == tr("Files") ){ |
448 | m_selector = EXTENDED; | 452 | m_selector = EXTENDED; |
449 | initializeListView(); | 453 | initializeListView(); |
450 | reparse(); | 454 | reparse(); |
451 | m_stack->raiseWidget( EXTENDED ); | 455 | m_stack->raiseWidget( EXTENDED ); |
452 | }else if( sel == tr("All Files") ){ | 456 | }else if( sel == tr("All Files") ){ |
453 | m_selector = EXTENDED_ALL; | 457 | m_selector = EXTENDED_ALL; |
454 | initializeListView(); | 458 | initializeListView(); |
455 | reparse(); | 459 | reparse(); |
456 | m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter | 460 | m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter |
457 | } | 461 | } |
458 | } | 462 | } |
459 | // not yet finished..... | 463 | // not yet finished..... |
460 | QString OFileSelector::currentMimeType() const{ | 464 | QString OFileSelector::currentMimeType() const{ |
461 | QString mime; | 465 | QString mime; |
462 | QString currentText; | 466 | QString currentText; |
463 | if (m_shChooser ) | 467 | if (m_shChooser ) |
464 | currentText = m_mimeCheck->currentText(); | 468 | currentText = m_mimeCheck->currentText(); |
465 | 469 | ||
466 | if (tr("All") == currentText ) return QString::null; | 470 | if (tr("All") == currentText ) return QString::null; |
467 | else if (currentText.isEmpty() ) { | 471 | else if (currentText.isEmpty() ) { |
468 | ; | 472 | ; |
469 | }else { | 473 | }else { |
470 | QMap<QString, QStringList>::ConstIterator it; | 474 | QMap<QString, QStringList>::ConstIterator it; |
471 | it = m_mimetypes.find( currentText ); | 475 | it = m_mimetypes.find( currentText ); |
472 | if ( it == m_mimetypes.end() ) { | 476 | if ( it == m_mimetypes.end() ) { |
473 | mime = it.data().join(";"); | 477 | mime = it.data().join(";"); |
474 | }else{ | 478 | }else{ |
475 | mime = currentText; | 479 | mime = currentText; |
476 | } | 480 | } |
477 | } | 481 | } |
478 | return mime; | 482 | return mime; |
479 | } | 483 | } |
480 | void OFileSelector::slotMimeCheck(const QString &mime) | 484 | void OFileSelector::slotMimeCheck(const QString &mime) |
481 | { | 485 | { |
482 | if( m_selector == NORMAL ){ | 486 | if( m_selector == NORMAL ){ |
483 | //if( m_autoMime ){ | 487 | //if( m_autoMime ){ |
484 | QString newMimeType; | 488 | QString newMimeType; |
485 | if (mime != tr("All") ) { | 489 | if (mime != tr("All") ) { |
486 | QMap<QString, QStringList>::Iterator it; | 490 | QMap<QString, QStringList>::Iterator it; |
487 | it = m_mimetypes.find(mime); | 491 | it = m_mimetypes.find(mime); |
488 | if ( it != m_mimetypes.end() ) { | 492 | if ( it != m_mimetypes.end() ) { |
489 | newMimeType = it.data().join(";"); | 493 | newMimeType = it.data().join(";"); |
490 | }else{ | 494 | }else{ |
491 | newMimeType = mime; | 495 | newMimeType = mime; |
492 | } | 496 | } |
493 | } | 497 | } |
494 | delete m_select; | 498 | delete m_select; |
495 | m_select = new FileSelector( newMimeType, | 499 | m_select = new FileSelector( newMimeType, |
496 | m_stack, "fileselector", | 500 | m_stack, "fileselector", |
497 | FALSE, FALSE); | 501 | m_shNew, m_shClose); |
498 | 502 | ||
499 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 503 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
500 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 504 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
505 | connect(m_select, SIGNAL(closeMe() ), | ||
506 | this, SIGNAL(closeMe() ) ); | ||
501 | //connect to close me and other signals as well | 507 | //connect to close me and other signals as well |
502 | m_stack->addWidget( m_select, NORMAL ); | 508 | m_stack->addWidget( m_select, NORMAL ); |
503 | m_stack->raiseWidget( NORMAL ); | 509 | m_stack->raiseWidget( NORMAL ); |
504 | updateMimes(); | 510 | updateMimes(); |
505 | updateMimeCheck(); | 511 | updateMimeCheck(); |
506 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 512 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
507 | //} | 513 | //} |
508 | }else{ // others | 514 | }else{ // others |
509 | qWarning("Mime %s", mime.latin1() ); | 515 | qWarning("Mime %s", mime.latin1() ); |
510 | if(m_shChooser ){ | 516 | if(m_shChooser ){ |
511 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); | 517 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); |
512 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 518 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
513 | } | 519 | } |
514 | reparse(); | 520 | reparse(); |
515 | } | 521 | } |
516 | 522 | ||
517 | } | 523 | } |
518 | void OFileSelector::slotLocationActivated(const QString &file) | 524 | void OFileSelector::slotLocationActivated(const QString &file) |
519 | { | 525 | { |
520 | cd(file.left(file.find("<-",0,TRUE))); | 526 | cd(file.left(file.find("<-",0,TRUE))); |
521 | reparse(); | 527 | reparse(); |
522 | } | 528 | } |
523 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) | 529 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) |
524 | { | 530 | { |
525 | QStringList pathList; | 531 | QStringList pathList; |
526 | bool underDog = FALSE; | 532 | bool underDog = FALSE; |
527 | for(int i=0;i<count;i++) { | 533 | for(int i=0;i<count;i++) { |
528 | pathList << m_location->text(i); | 534 | pathList << m_location->text(i); |
529 | if( m_location->text(i) == currentPath) | 535 | if( m_location->text(i) == currentPath) |
530 | underDog = TRUE; | 536 | underDog = TRUE; |
531 | } | 537 | } |
532 | if( !underDog) { | 538 | if( !underDog) { |
533 | m_location->clear(); | 539 | m_location->clear(); |
534 | if( currentPath.left(2)=="//") | 540 | if( currentPath.left(2)=="//") |
535 | pathList.append( currentPath.right(currentPath.length()-1) ); | 541 | pathList.append( currentPath.right(currentPath.length()-1) ); |
536 | else | 542 | else |
537 | pathList.append( currentPath ); | 543 | pathList.append( currentPath ); |
538 | m_location->insertStringList( pathList,-1); | 544 | m_location->insertStringList( pathList,-1); |
539 | } | 545 | } |
540 | } | 546 | } |
541 | void OFileSelector::locationComboChanged() | 547 | void OFileSelector::locationComboChanged() |
542 | { | 548 | { |
543 | cd( m_location->lineEdit()->text()); | 549 | cd( m_location->lineEdit()->text()); |
544 | reparse(); | 550 | reparse(); |
545 | } | 551 | } |
546 | void OFileSelector::init() | 552 | void OFileSelector::init() |
547 | { | 553 | { |
548 | m_lay = new QVBoxLayout( this ); | 554 | m_lay = new QVBoxLayout( this ); |
549 | m_lay->setSpacing(0 ); | 555 | m_lay->setSpacing(0 ); |
550 | 556 | ||
551 | m_stack = new QWidgetStack( this ); | 557 | m_stack = new QWidgetStack( this ); |
552 | if( m_selector == NORMAL ){ | 558 | if( m_selector == NORMAL ){ |
553 | QString mime; | 559 | QString mime; |
554 | if (!m_autoMime) { | 560 | if (!m_autoMime) { |
555 | if (!m_mimetypes.isEmpty() ) { | 561 | if (!m_mimetypes.isEmpty() ) { |
556 | QMap<QString, QStringList>::Iterator it; | 562 | QMap<QString, QStringList>::Iterator it; |
557 | it = m_mimetypes.begin(); // cause we're in the init | 563 | it = m_mimetypes.begin(); // cause we're in the init |
558 | mime = it.data().join(";"); | 564 | mime = it.data().join(";"); |
559 | } | 565 | } |
560 | } | 566 | } |
561 | m_select = new FileSelector(mime, | 567 | m_select = new FileSelector(mime, |
562 | m_stack, "fileselector", | 568 | m_stack, "fileselector", |
563 | FALSE, FALSE); | 569 | m_shNew, m_shClose); |
564 | 570 | ||
565 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 571 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
566 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 572 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
573 | connect(m_select, SIGNAL(closeMe() ), | ||
574 | this, SIGNAL( closeMe() ) ); | ||
567 | //connect to close me and other signals as well | 575 | //connect to close me and other signals as well |
568 | 576 | ||
569 | m_stack->addWidget( m_select, NORMAL ); | 577 | m_stack->addWidget( m_select, NORMAL ); |
570 | m_stack->raiseWidget( NORMAL ); | 578 | m_stack->raiseWidget( NORMAL ); |
571 | }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL | 579 | }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL |
572 | // and initializeListview will take care of those | 580 | // and initializeListview will take care of those |
573 | // toolbar get's generade in initializeListView | 581 | // toolbar get's generade in initializeListView |
574 | initializeListView( ); // will raise the widget as well | 582 | initializeListView( ); // will raise the widget as well |
575 | m_stack->raiseWidget( EXTENDED ); | 583 | m_stack->raiseWidget( EXTENDED ); |
576 | } | 584 | } |
577 | m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch | 585 | m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch |
578 | 586 | ||
579 | if( m_shLne ) // the LineEdit with the current FileName | 587 | if( m_shLne ) // the LineEdit with the current FileName |
580 | initializeName(); | 588 | initializeName(); |
581 | 589 | ||
582 | if( m_shPerm ) // the Permission QCheckBox | 590 | if( m_shPerm ) // the Permission QCheckBox |
583 | initializePerm(); | 591 | initializePerm(); |
584 | 592 | ||
585 | if( m_shChooser ) // the Chooser for the view and Mimetypes | 593 | if( m_shChooser ) // the Chooser for the view and Mimetypes |
586 | initializeChooser(); | 594 | initializeChooser(); |
587 | 595 | ||
588 | if( m_shYesNo ) // the Yes No button row | 596 | if( m_shYesNo ) // the Yes No button row |
589 | initializeYes( ); | 597 | initializeYes( ); |
590 | 598 | ||
591 | if (m_selector != NORMAL ) | 599 | if (m_selector != NORMAL ) |
592 | reparse(); | 600 | reparse(); |
593 | } | 601 | } |
594 | void OFileSelector::updateMimes() | 602 | void OFileSelector::updateMimes() |
595 | { | 603 | { |
596 | if( m_autoMime ){ | 604 | if( m_autoMime ){ |
597 | m_mimetypes.clear(); | 605 | m_mimetypes.clear(); |
598 | m_mimetypes.insert( tr("All"), QString::null ); | 606 | m_mimetypes.insert( tr("All"), QString::null ); |
599 | if( m_selector == NORMAL ){ | 607 | if( m_selector == NORMAL ){ |
600 | DocLnkSet set; | 608 | DocLnkSet set; |
601 | Global::findDocuments(&set, QString::null ); | 609 | Global::findDocuments(&set, QString::null ); |
602 | QListIterator<DocLnk> dit( set.children() ); | 610 | QListIterator<DocLnk> dit( set.children() ); |
603 | for( ; dit.current(); ++dit ){ | 611 | for( ; dit.current(); ++dit ){ |
604 | if( !m_mimetypes.contains( (*dit)->type() ) ) | 612 | if( !m_mimetypes.contains( (*dit)->type() ) ) |
605 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); | 613 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); |
606 | } | 614 | } |
607 | }// else done in reparse | 615 | }// else done in reparse |
608 | } | 616 | } |
609 | } | 617 | } |
610 | void OFileSelector::initVars() | 618 | void OFileSelector::initVars() |
611 | { | 619 | { |
612 | if( m_mimetypes.isEmpty() ) | 620 | if( m_mimetypes.isEmpty() ) |
613 | m_autoMime = true; | 621 | m_autoMime = true; |
614 | else | 622 | else |
615 | m_autoMime = false; | 623 | m_autoMime = false; |
616 | m_shClose = false; | 624 | m_shClose = false; |
617 | m_shNew = false; | 625 | m_shNew = false; |
618 | m_shTool = true; | 626 | m_shTool = true; |
619 | m_shPerm = false; | 627 | m_shPerm = false; |
620 | m_shLne = true; | 628 | m_shLne = true; |
621 | m_shChooser = true; | 629 | m_shChooser = true; |
622 | m_shYesNo = true; | 630 | m_shYesNo = true; |
623 | m_case = false; | 631 | m_case = false; |
624 | m_dir = true; | 632 | m_dir = true; |
625 | m_files = true; | 633 | m_files = true; |
626 | m_showPopup = false; | 634 | m_showPopup = false; |
627 | if(m_pixmaps == 0 ) // init the pixmaps | 635 | if(m_pixmaps == 0 ) // init the pixmaps |
628 | initPics(); | 636 | initPics(); |
629 | 637 | ||
630 | // pointers | 638 | // pointers |
631 | m_location = 0; | 639 | m_location = 0; |
632 | m_mimeCheck = 0; | 640 | m_mimeCheck = 0; |
633 | m_viewCheck = 0; | 641 | m_viewCheck = 0; |
634 | m_homeButton = 0; | 642 | m_homeButton = 0; |
635 | m_docButton = 0; | 643 | m_docButton = 0; |
636 | m_hideButton = 0; | 644 | m_hideButton = 0; |
637 | m_ok = 0; | 645 | m_ok = 0; |
638 | m_cancel = 0; | 646 | m_cancel = 0; |
639 | m_reread = 0; | 647 | m_reread = 0; |
640 | m_up = 0; | 648 | m_up = 0; |
641 | m_View = 0; | 649 | m_View = 0; |
642 | m_checkPerm = 0; | 650 | m_checkPerm = 0; |
643 | m_pseudo = 0; | 651 | m_pseudo = 0; |
644 | m_pseudoLayout = 0; | 652 | m_pseudoLayout = 0; |
645 | m_select = 0; | 653 | m_select = 0; |
646 | m_stack = 0; | 654 | m_stack = 0; |
647 | m_lay = 0; | 655 | m_lay = 0; |
648 | m_Oselector = 0; | 656 | m_Oselector = 0; |
649 | m_boxToolbar = 0; | 657 | m_boxToolbar = 0; |
650 | m_boxOk = 0; | 658 | m_boxOk = 0; |
651 | m_boxName = 0; | 659 | m_boxName = 0; |
652 | m_boxView = 0; | 660 | m_boxView = 0; |
653 | m_custom = 0; | 661 | m_custom = 0; |
654 | m_edit = 0; | 662 | m_edit = 0; |
655 | m_fnLabel = 0; | 663 | m_fnLabel = 0; |
656 | m_new = 0; | 664 | m_new = 0; |
657 | m_close = 0; | 665 | m_close = 0; |
658 | } | 666 | } |
659 | void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink) | 667 | void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink) |
660 | { | 668 | { |
661 | if(!m_files) | 669 | if(!m_files) |
662 | return; | 670 | return; |
663 | // if( !compliesMime(info->absFilePath(), mime ) ) | 671 | // if( !compliesMime(info->absFilePath(), mime ) ) |
664 | // return; | 672 | // return; |
665 | MimeType type( info->absFilePath() ); | 673 | MimeType type( info->absFilePath() ); |
666 | if (!compliesMime( type.id() ) ) | 674 | if (!compliesMime( type.id() ) ) |
667 | return; | 675 | return; |
668 | 676 | ||
669 | QPixmap pix = type.pixmap(); | 677 | QPixmap pix = type.pixmap(); |
670 | QString dir; | 678 | QString dir; |
671 | QString name; | 679 | QString name; |
672 | bool locked; | 680 | bool locked; |
673 | if( pix.isNull() ) | 681 | if( pix.isNull() ) |
674 | pix = Resource::loadPixmap( "UnknownDocument-14"); | 682 | pix = Resource::loadPixmap( "UnknownDocument-14"); |
675 | dir = info->dirPath( true ); | 683 | dir = info->dirPath( true ); |
676 | if( symlink ) | 684 | if( symlink ) |
677 | name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); | 685 | name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); |
678 | else { | 686 | else { |
679 | name = info->fileName(); | 687 | name = info->fileName(); |
680 | if( ( m_mode == OPEN && !info->isReadable() )|| | 688 | if( ( m_mode == OPEN && !info->isReadable() )|| |
681 | ( m_mode == SAVE && !info->isWritable() ) ){ | 689 | ( m_mode == SAVE && !info->isWritable() ) ){ |
682 | 690 | ||
683 | locked = true; pix = Resource::loadPixmap("locked"); | 691 | locked = true; pix = Resource::loadPixmap("locked"); |
684 | } | 692 | } |
685 | } | 693 | } |
686 | new OFileSelectorItem( m_View, pix, name, | 694 | new OFileSelectorItem( m_View, pix, name, |
687 | info->lastModified().toString(), | 695 | info->lastModified().toString(), |
688 | QString::number( info->size() ), | 696 | QString::number( info->size() ), |
689 | dir, locked ); | 697 | dir, locked ); |
690 | } | 698 | } |
691 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) | 699 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) |
692 | { | 700 | { |
693 | if(!m_dir) | 701 | if(!m_dir) |
694 | return; | 702 | return; |
695 | if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){ | 703 | if( m_selector == EXTENDED_ALL || m_selector == EXTENDED ){ |
696 | bool locked = false; | 704 | bool locked = false; |
697 | QString name; | 705 | QString name; |
698 | QPixmap pix; | 706 | QPixmap pix; |
699 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ | 707 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ |
700 | locked = true; | 708 | locked = true; |
701 | if( symlink ) | 709 | if( symlink ) |
702 | pix = (*m_pixmaps)["symlinkedlocked"]; | 710 | pix = (*m_pixmaps)["symlinkedlocked"]; |
703 | else | 711 | else |
704 | pix = Resource::loadPixmap("lockedfolder"); | 712 | pix = Resource::loadPixmap("lockedfolder"); |
705 | }else { // readable | 713 | }else { // readable |
706 | pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ; | 714 | pix = symlink ? (*m_pixmaps)["dirsymlink"] : Resource::loadPixmap("folder") ; |
707 | } | 715 | } |
708 | name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; | 716 | name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; |
709 | new OFileSelectorItem( m_View, pix, name, | 717 | new OFileSelectorItem( m_View, pix, name, |
710 | info->lastModified().toString(), | 718 | info->lastModified().toString(), |
711 | QString::number( info->size() ), | 719 | QString::number( info->size() ), |
712 | info->dirPath( true ), locked, | 720 | info->dirPath( true ), locked, |
713 | true ); | 721 | true ); |
714 | 722 | ||
715 | }// else CUSTOM View | 723 | }// else CUSTOM View |
716 | } | 724 | } |
717 | void OFileSelector::delItems() | 725 | void OFileSelector::delItems() |
718 | { | 726 | { |
719 | 727 | ||
720 | } | 728 | } |
721 | void OFileSelector::initializeName() | 729 | void OFileSelector::initializeName() |
722 | { | 730 | { |
723 | /** Name Layout Line | 731 | /** Name Layout Line |
724 | * This is the Layout line arranged in | 732 | * This is the Layout line arranged in |
725 | * horizontal way each components | 733 | * horizontal way each components |
726 | * are next to each other | 734 | * are next to each other |
727 | * but we will only do this if | 735 | * but we will only do this if |
728 | * we didn't initialize a while ago. | 736 | * we didn't initialize a while ago. |
729 | */ | 737 | */ |
730 | if( m_boxName == 0 ){ | 738 | if( m_boxName == 0 ){ |
731 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox | 739 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox |
732 | m_fnLabel = new QLabel( m_boxName ); | 740 | m_fnLabel = new QLabel( m_boxName ); |
733 | m_fnLabel->setText( tr("Name:") ); | 741 | m_fnLabel->setText( tr("Name:") ); |
734 | m_edit = new QLineEdit( m_boxName ); | 742 | m_edit = new QLineEdit( m_boxName ); |
735 | m_edit->setText( m_name ); | 743 | m_edit->setText( m_name ); |
736 | //m_boxName->addWidget( m_fnLabel ); | 744 | //m_boxName->addWidget( m_fnLabel ); |
737 | m_boxName->setMargin( 5 ); | 745 | m_boxName->setMargin( 5 ); |
738 | m_boxName->setSpacing( 8 ); | 746 | m_boxName->setSpacing( 8 ); |
739 | //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor | 747 | //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor |
740 | 748 | ||
741 | m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout | 749 | m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout |
742 | }// else we already initialized | 750 | }// else we already initialized |
743 | // maybe show the components? | 751 | // maybe show the components? |
744 | // | 752 | // |
745 | } | 753 | } |
746 | void OFileSelector::initializeYes() | 754 | void OFileSelector::initializeYes() |
747 | { | 755 | { |
748 | /** The Save Cancel bar | 756 | /** The Save Cancel bar |
749 | * | 757 | * |
750 | */ | 758 | */ |
751 | if( m_boxOk == 0 ){ | 759 | if( m_boxOk == 0 ){ |
752 | m_boxOk = new QHBox( this ); | 760 | m_boxOk = new QHBox( this ); |
753 | m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); | 761 | m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); |
754 | m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); | 762 | m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); |
755 | 763 | ||
756 | //m_boxOk->addWidget( m_ok ); | 764 | //m_boxOk->addWidget( m_ok ); |
757 | //m_boxOk->addWidget( m_cancel ); | 765 | //m_boxOk->addWidget( m_cancel ); |
758 | m_boxOk->setMargin( 5 ); | 766 | m_boxOk->setMargin( 5 ); |
759 | m_boxOk->setSpacing( 10 ); | 767 | m_boxOk->setSpacing( 10 ); |
760 | m_lay->addWidget( m_boxOk, 0 ); | 768 | m_lay->addWidget( m_boxOk, 0 ); |
761 | 769 | ||
762 | connect( m_ok, SIGNAL( clicked() ), | 770 | connect( m_ok, SIGNAL( clicked() ), |
763 | this, SLOT(slotOk() ) ); | 771 | this, SLOT(slotOk() ) ); |
764 | connect( m_cancel, SIGNAL( clicked() ), | 772 | connect( m_cancel, SIGNAL( clicked() ), |
765 | this, SLOT( slotCancel() ) ); | 773 | this, SLOT( slotCancel() ) ); |
766 | } | 774 | } |
767 | } | 775 | } |
768 | /* | 776 | /* |
769 | * OK m_mimeCheck is a QComboBox we now want to fill | 777 | * OK m_mimeCheck is a QComboBox we now want to fill |
770 | * out that combobox | 778 | * out that combobox |
771 | * if automime we need to update the mimetypes | 779 | * if automime we need to update the mimetypes |
772 | */ | 780 | */ |
773 | void OFileSelector::updateMimeCheck() { | 781 | void OFileSelector::updateMimeCheck() { |
774 | m_mimeCheck->clear(); | 782 | m_mimeCheck->clear(); |
775 | if (m_autoMime ) { | 783 | if (m_autoMime ) { |
776 | //m_mimeCheck->insertItem( tr("All") ); | 784 | //m_mimeCheck->insertItem( tr("All") ); |
777 | updateMimes(); | 785 | updateMimes(); |
778 | } | 786 | } |
779 | 787 | ||
780 | QMap<QString, QStringList>::Iterator it; | 788 | QMap<QString, QStringList>::Iterator it; |
781 | for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { | 789 | for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { |
782 | m_mimeCheck->insertItem( it.key() ); | 790 | m_mimeCheck->insertItem( it.key() ); |
783 | } | 791 | } |
784 | } | 792 | } |
785 | 793 | ||
786 | void OFileSelector::initializeChooser() | 794 | void OFileSelector::initializeChooser() |
787 | { | 795 | { |
788 | if( m_boxView == 0 ){ | 796 | if( m_boxView == 0 ){ |
789 | m_boxView = new QHBox( this ); | 797 | m_boxView = new QHBox( this ); |
790 | m_viewCheck = new QComboBox( m_boxView, "view check"); | 798 | m_viewCheck = new QComboBox( m_boxView, "view check"); |
791 | m_mimeCheck = new QComboBox( m_boxView, "mime check"); | 799 | m_mimeCheck = new QComboBox( m_boxView, "mime check"); |
792 | m_boxView->setSpacing( 8 ); | 800 | m_boxView->setSpacing( 8 ); |
793 | m_lay->addWidget(m_boxView, 0 ); | 801 | m_lay->addWidget(m_boxView, 0 ); |
794 | 802 | ||
795 | m_viewCheck->insertItem( tr("Documents") ); | 803 | m_viewCheck->insertItem( tr("Documents") ); |
796 | m_viewCheck->insertItem( tr("Files") ); | 804 | m_viewCheck->insertItem( tr("Files") ); |
797 | m_viewCheck->insertItem( tr("All Files") ); | 805 | m_viewCheck->insertItem( tr("All Files") ); |
798 | updateMimeCheck(); | 806 | updateMimeCheck(); |
799 | 807 | ||
800 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), | 808 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), |
801 | this, SLOT( slotViewCheck(const QString & ) ) ); | 809 | this, SLOT( slotViewCheck(const QString & ) ) ); |
802 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), | 810 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), |
803 | this, SLOT( slotMimeCheck( const QString & ) ) ); | 811 | this, SLOT( slotMimeCheck( const QString & ) ) ); |
804 | } | 812 | } |
805 | } | 813 | } |
806 | void OFileSelector::initializeListView() | 814 | void OFileSelector::initializeListView() |
807 | { | 815 | { |
808 | qWarning("initializeListView"); | 816 | qWarning("initializeListView"); |
809 | if( m_pseudo == 0 ){ | 817 | if( m_pseudo == 0 ){ |
810 | qWarning("init"); | 818 | qWarning("init"); |
811 | m_pseudo = new QWidget( m_stack, "Pseudo Widget"); | 819 | m_pseudo = new QWidget( m_stack, "Pseudo Widget"); |
812 | m_pseudoLayout = new QVBoxLayout( m_pseudo ); | 820 | m_pseudoLayout = new QVBoxLayout( m_pseudo ); |
813 | // toolbar | 821 | // toolbar |
814 | m_boxToolbar = new QHBox( m_pseudo ); | 822 | m_boxToolbar = new QHBox( m_pseudo ); |
815 | m_boxToolbar->setSpacing(0 ); // next to each other please | 823 | m_boxToolbar->setSpacing(0 ); // next to each other please |
816 | 824 | ||
817 | // toolbar members | 825 | // toolbar members |
818 | { | 826 | { |
819 | // location QComboBox | 827 | // location QComboBox |
820 | m_location = new QComboBox( m_boxToolbar ); | 828 | m_location = new QComboBox( m_boxToolbar ); |
821 | m_location->setEditable( TRUE ); | 829 | m_location->setEditable( TRUE ); |
822 | m_location->setDuplicatesEnabled( FALSE ); | 830 | m_location->setDuplicatesEnabled( FALSE ); |
823 | connect( m_location, SIGNAL(activated(const QString &) ), | 831 | connect( m_location, SIGNAL(activated(const QString &) ), |
824 | this, SLOT( slotLocationActivated(const QString &) ) ); | 832 | this, SLOT( slotLocationActivated(const QString &) ) ); |
825 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ), | 833 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ), |
826 | this, SLOT(locationComboChanged() ) ); | 834 | this, SLOT(locationComboChanged() ) ); |
827 | // UP Button | 835 | // UP Button |
828 | m_up = new QPushButton(Resource::loadIconSet("up"),"", | 836 | m_up = new QPushButton(Resource::loadIconSet("up"),"", |
829 | m_boxToolbar,"cdUpButton"); | 837 | m_boxToolbar,"cdUpButton"); |
830 | m_up->setFixedSize( QSize( 20, 20 ) ); | 838 | m_up->setFixedSize( QSize( 20, 20 ) ); |
831 | connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); | 839 | connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); |
832 | m_up->setFlat(TRUE); | 840 | m_up->setFlat(TRUE); |
833 | 841 | ||
834 | // Home Button | 842 | // Home Button |
835 | m_homeButton = new QPushButton(Resource::loadIconSet("home") , | 843 | m_homeButton = new QPushButton(Resource::loadIconSet("home") , |
836 | "", m_boxToolbar); | 844 | "", m_boxToolbar); |
837 | m_homeButton->setFixedSize( QSize( 20, 20 ) ); | 845 | m_homeButton->setFixedSize( QSize( 20, 20 ) ); |
838 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); | 846 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); |
839 | m_homeButton->setFlat(TRUE); | 847 | m_homeButton->setFlat(TRUE); |
840 | // Documents Button | 848 | // Documents Button |
841 | m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", | 849 | m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", |
842 | m_boxToolbar,"docsButton"); | 850 | m_boxToolbar,"docsButton"); |
843 | m_docButton->setFixedSize( QSize( 20, 20 ) ); | 851 | m_docButton->setFixedSize( QSize( 20, 20 ) ); |
844 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); | 852 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); |
845 | m_docButton->setFlat(TRUE); | 853 | m_docButton->setFlat(TRUE); |
846 | 854 | ||
847 | // Close button | 855 | // Close button |
848 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", | 856 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", |
849 | m_boxToolbar ); | 857 | m_boxToolbar ); |
850 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); | 858 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); |
851 | m_close->setFixedSize( 20, 20 ); | 859 | m_close->setFixedSize( 20, 20 ); |
852 | 860 | ||
853 | m_boxToolbar->setFixedHeight( 20 ); | 861 | m_boxToolbar->setFixedHeight( 20 ); |
854 | m_pseudoLayout->addWidget(m_boxToolbar ); | 862 | m_pseudoLayout->addWidget(m_boxToolbar ); |
855 | 863 | ||
856 | // let;s fill the Location ComboBox | 864 | // let;s fill the Location ComboBox |
857 | StorageInfo storage; | 865 | StorageInfo storage; |
858 | const QList<FileSystem> &fs = storage.fileSystems(); | 866 | const QList<FileSystem> &fs = storage.fileSystems(); |
859 | QListIterator<FileSystem> it ( fs ); | 867 | QListIterator<FileSystem> it ( fs ); |
860 | for( ; it.current(); ++it ){ | 868 | for( ; it.current(); ++it ){ |
861 | const QString disk = (*it)->name(); | 869 | const QString disk = (*it)->name(); |
862 | const QString path = (*it)->path(); | 870 | const QString path = (*it)->path(); |
863 | m_location->insertItem(path+ "<-"+disk ); | 871 | m_location->insertItem(path+ "<-"+disk ); |
864 | } | 872 | } |
865 | int count = m_location->count(); | 873 | int count = m_location->count(); |
866 | m_location->insertItem( m_currentDir ); | 874 | m_location->insertItem( m_currentDir ); |
867 | m_location->setCurrentItem( count ); | 875 | m_location->setCurrentItem( count ); |
868 | // due to the New and Close button we can not simply hide m_boxToolBar to not show it | 876 | // due to the New and Close button we can not simply hide m_boxToolBar to not show it |
869 | if( !m_shTool ){ | 877 | if( !m_shTool ){ |
870 | m_location->hide( ); | 878 | m_location->hide( ); |
871 | m_up->hide( ); | 879 | m_up->hide( ); |
872 | m_homeButton->hide( ); | 880 | m_homeButton->hide( ); |
873 | m_docButton->hide( ); | 881 | m_docButton->hide( ); |
874 | } | 882 | } |
875 | if(!m_shClose ) | 883 | if(!m_shClose ) |
876 | m_close->hide(); | 884 | m_close->hide(); |
877 | if(!m_shNew) | 885 | //if(!m_shNew) |
878 | m_close->hide(); | 886 | //m_close->hide(); |
879 | 887 | ||
880 | } // off toolbar | 888 | } // off toolbar |
881 | // the Main ListView | 889 | // the Main ListView |
882 | // make a QWidgetStack first so Views can share the Toolbar | 890 | // make a QWidgetStack first so Views can share the Toolbar |
883 | m_View = new QListView( m_pseudo, "Extended view"); | 891 | m_View = new QListView( m_pseudo, "Extended view"); |
884 | QPEApplication::setStylusOperation( m_View->viewport(), | 892 | QPEApplication::setStylusOperation( m_View->viewport(), |
885 | QPEApplication::RightOnHold); | 893 | QPEApplication::RightOnHold); |
886 | m_View->addColumn(" " ); | 894 | m_View->addColumn(" " ); |
887 | m_View->addColumn(tr("Name"), 135 ); | 895 | m_View->addColumn(tr("Name"), 135 ); |
888 | m_View->addColumn(tr("Size"), -1 ); | 896 | m_View->addColumn(tr("Size"), -1 ); |
889 | m_View->addColumn(tr("Date"), 60 ); | 897 | m_View->addColumn(tr("Date"), 60 ); |
890 | m_View->addColumn(tr("Mime Type"), -1 ); | 898 | m_View->addColumn(tr("Mime Type"), -1 ); |
891 | QHeader *header = m_View->header(); | 899 | QHeader *header = m_View->header(); |
892 | header->hide(); | 900 | header->hide(); |
893 | m_View->setSorting( 1 ); | 901 | m_View->setSorting( 1 ); |
894 | m_View->setAllColumnsShowFocus( TRUE ); | 902 | m_View->setAllColumnsShowFocus( TRUE ); |
895 | 903 | ||
896 | connect(m_View, SIGNAL(selectionChanged() ), | 904 | connect(m_View, SIGNAL(selectionChanged() ), |
897 | this, SLOT(slotSelectionChanged() ) ); | 905 | this, SLOT(slotSelectionChanged() ) ); |
898 | 906 | ||
899 | connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), | 907 | connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), |
900 | this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); | 908 | this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); |
901 | 909 | ||
902 | connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), | 910 | connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), |
903 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); | 911 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); |
904 | 912 | ||
905 | connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), | 913 | connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), |
906 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); | 914 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); |
907 | 915 | ||
908 | m_pseudoLayout->addWidget( m_View, 288 ); | 916 | m_pseudoLayout->addWidget( m_View, 288 ); |
909 | m_stack->addWidget( m_pseudo, EXTENDED ); | 917 | m_stack->addWidget( m_pseudo, EXTENDED ); |
910 | } | 918 | } |
911 | } | 919 | } |
912 | void OFileSelector::initializePerm() | 920 | void OFileSelector::initializePerm() |
913 | { | 921 | { |
914 | if( m_checkPerm == 0 ){ | 922 | if( m_checkPerm == 0 ){ |
915 | m_checkPerm = new QCheckBox(tr("Ser Permission"), this, "perm"); | 923 | m_checkPerm = new QCheckBox(tr("Ser Permission"), this, "perm"); |
916 | m_checkPerm->setChecked( false ); | 924 | m_checkPerm->setChecked( false ); |
917 | m_lay->addWidget( m_checkPerm ); | 925 | m_lay->addWidget( m_checkPerm ); |
918 | 926 | ||
919 | } | 927 | } |
920 | } | 928 | } |
921 | void OFileSelector::initPics() | 929 | void OFileSelector::initPics() |
922 | { | 930 | { |
923 | m_pixmaps = new QMap<QString,QPixmap>; | 931 | m_pixmaps = new QMap<QString,QPixmap>; |
924 | QPixmap pm = Resource::loadPixmap( "folder" ); | 932 | QPixmap pm = Resource::loadPixmap( "folder" ); |
925 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 933 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
926 | QPainter painter( &pm ); | 934 | QPainter painter( &pm ); |
927 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 935 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
928 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 936 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
929 | m_pixmaps->insert("dirsymlink", pm ); | 937 | m_pixmaps->insert("dirsymlink", pm ); |
930 | 938 | ||
931 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | 939 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); |
932 | QPainter pen(&pm2 ); | 940 | QPainter pen(&pm2 ); |
933 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | 941 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); |
934 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | 942 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); |
935 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 943 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
936 | } | 944 | } |
937 | // if a mime complies with the m_mimeCheck->currentItem | 945 | // if a mime complies with the m_mimeCheck->currentItem |
938 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) | 946 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) |
939 | { | 947 | { |
940 | if( mime == "All" ) | 948 | if( mime == "All" ) |
941 | return true; | 949 | return true; |
942 | MimeType type( path ); | 950 | MimeType type( path ); |
943 | if( type.id() == mime ) | 951 | if( type.id() == mime ) |
944 | return true; | 952 | return true; |
945 | return false; | 953 | return false; |
946 | } | 954 | } |
947 | /* check if the mimetype in mime | 955 | /* check if the mimetype in mime |
948 | * complies with the one which is current | 956 | * complies with the one which is current |
949 | */ | 957 | */ |
950 | /* | 958 | /* |
951 | * We've the mimetype of the file | 959 | * We've the mimetype of the file |
952 | * We need to get the stringlist of the current mimetype | 960 | * We need to get the stringlist of the current mimetype |
953 | * | 961 | * |
954 | * mime = image/jpeg | 962 | * mime = image/jpeg |
955 | * QStringList = 'image/*' | 963 | * QStringList = 'image/*' |
956 | * or QStringList = image/jpeg;image/png;application/x-ogg | 964 | * or QStringList = image/jpeg;image/png;application/x-ogg |
957 | * or QStringList = application/x-ogg;image/*; | 965 | * or QStringList = application/x-ogg;image/*; |
958 | * with all these mime filters it should get acceptes | 966 | * with all these mime filters it should get acceptes |
959 | * to do so we need to look if mime is contained inside | 967 | * to do so we need to look if mime is contained inside |
960 | * the stringlist | 968 | * the stringlist |
961 | * if it's contained return true | 969 | * if it's contained return true |
962 | * if not ( I'm no RegExp expert at all ) we'll look if a '/*' | 970 | * if not ( I'm no RegExp expert at all ) we'll look if a '/*' |
963 | * is contained in the mimefilter and then we will | 971 | * is contained in the mimefilter and then we will |
964 | * look if both are equal until the '/' | 972 | * look if both are equal until the '/' |
965 | */ | 973 | */ |
966 | bool OFileSelector::compliesMime( const QString& mime ) { | 974 | bool OFileSelector::compliesMime( const QString& mime ) { |
967 | qWarning("mimetype is %s", mime.latin1() ); | 975 | qWarning("mimetype is %s", mime.latin1() ); |
968 | QString currentText; | 976 | QString currentText; |
969 | if (m_shChooser ) | 977 | if (m_shChooser ) |
970 | currentText = m_mimeCheck->currentText(); | 978 | currentText = m_mimeCheck->currentText(); |
971 | 979 | ||
972 | qWarning("current text is %s", currentText.latin1() ); | 980 | qWarning("current text is %s", currentText.latin1() ); |
973 | QMap<QString, QStringList>::Iterator it; | 981 | QMap<QString, QStringList>::Iterator it; |
974 | QStringList list; | 982 | QStringList list; |
975 | if ( currentText == tr("All") ) return true; | 983 | if ( currentText == tr("All") ) return true; |
976 | else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { | 984 | else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { |
977 | it = m_mimetypes.begin(); | 985 | it = m_mimetypes.begin(); |
978 | list = it.data(); | 986 | list = it.data(); |
979 | }else if ( currentText.isEmpty() ) return true; | 987 | }else if ( currentText.isEmpty() ) return true; |
980 | else{ | 988 | else{ |
981 | it = m_mimetypes.find(currentText ); | 989 | it = m_mimetypes.find(currentText ); |
982 | if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; | 990 | if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; |
983 | else qWarning("found"), list = it.data(); | 991 | else qWarning("found"), list = it.data(); |
984 | } | 992 | } |
985 | // dump it now | 993 | // dump it now |
986 | //for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 994 | //for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
987 | // qWarning( "%s", (*it).latin1() ); | 995 | // qWarning( "%s", (*it).latin1() ); |
988 | //} | 996 | //} |
989 | 997 | ||
990 | 998 | ||
991 | if ( list.contains(mime) ) return true; | 999 | if ( list.contains(mime) ) return true; |
992 | qWarning("list doesn't contain it "); | 1000 | qWarning("list doesn't contain it "); |
993 | QStringList::Iterator it2; | 1001 | QStringList::Iterator it2; |
994 | int pos; | 1002 | int pos; |
995 | int pos2; | 1003 | int pos2; |
996 | for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { | 1004 | for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { |
997 | pos = (*it2).findRev("/*"); | 1005 | pos = (*it2).findRev("/*"); |
998 | if ( pos >= 0 ) { | 1006 | if ( pos >= 0 ) { |
999 | if ( mime.contains( (*it2).left(pos) ) ) return true; | 1007 | if ( mime.contains( (*it2).left(pos) ) ) return true; |
1000 | } | 1008 | } |
1001 | } | 1009 | } |
1002 | return false; | 1010 | return false; |
1003 | } | 1011 | } |
1004 | void OFileSelector::slotFileSelected( const QString &string ) | 1012 | void OFileSelector::slotFileSelected( const QString &string ) |
1005 | { | 1013 | { |
1006 | if( m_shLne ) | 1014 | if( m_shLne ) |
1007 | m_edit->setText( string ); | 1015 | m_edit->setText( string ); |
1008 | emit fileSelected( string ); | 1016 | emit fileSelected( string ); |
1009 | } | 1017 | } |
1010 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) | 1018 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) |
1011 | { | 1019 | { |
1012 | slotFileSelected( lnk.name() ); | 1020 | slotFileSelected( lnk.name() ); |
1013 | // emit fileSelected( lnk ); | 1021 | // emit fileSelected( lnk ); |
1014 | } | 1022 | } |
1015 | void OFileSelector::slotSelectionChanged() | 1023 | void OFileSelector::slotSelectionChanged() |
1016 | { | 1024 | { |
1017 | 1025 | ||
1018 | } | 1026 | } |
1019 | void OFileSelector::slotCurrentChanged(QListViewItem* item ) | 1027 | void OFileSelector::slotCurrentChanged(QListViewItem* item ) |
1020 | { | 1028 | { |
1021 | if( item == 0 ) | 1029 | if( item == 0 ) |
1022 | return; | 1030 | return; |
1023 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 1031 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
1024 | OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;) | 1032 | OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;) |
1033 | qWarning("current changed"); | ||
1025 | if(!sel->isDir() ){ | 1034 | if(!sel->isDir() ){ |
1026 | if( m_shLne ) | 1035 | if( m_shLne ) |
1027 | m_edit->setText( sel->text(1) ); | 1036 | m_edit->setText( sel->text(1) ); |
1037 | |||
1038 | if (m_mode == FILESELECTOR ) { | ||
1039 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
1040 | QString path =sel->directory() + "/" + str[0].stripWhiteSpace(); | ||
1041 | emit fileSelected(path ); | ||
1042 | DocLnk lnk( path ); | ||
1043 | emit fileSelected(lnk ); | ||
1044 | } | ||
1028 | } | 1045 | } |
1029 | } | 1046 | } |
1030 | } | 1047 | } |
1031 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int) | 1048 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int) |
1032 | { | 1049 | { |
1033 | if ( item == 0 ) | 1050 | if ( item == 0 ) |
1034 | return; | 1051 | return; |
1035 | 1052 | ||
1036 | if( button != Qt::LeftButton ) | 1053 | if( button != Qt::LeftButton ) |
1037 | return; | 1054 | return; |
1038 | 1055 | ||
1039 | switch( m_selector ){ | 1056 | switch( m_selector ){ |
1040 | default: | 1057 | default: |
1041 | break; | 1058 | break; |
1042 | case EXTENDED: // fall through | 1059 | case EXTENDED: // fall through |
1043 | case EXTENDED_ALL:{ | 1060 | case EXTENDED_ALL:{ |
1044 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | 1061 | OFileSelectorItem *sel = (OFileSelectorItem*)item; |
1045 | if(!sel->isLocked() ){ | 1062 | if(!sel->isLocked() ){ |
1046 | QStringList str = QStringList::split("->", sel->text(1) ); | 1063 | QStringList str = QStringList::split("->", sel->text(1) ); |
1047 | if( sel->isDir() ){ | 1064 | if( sel->isDir() ){ |
1048 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); | 1065 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); |
1049 | // if MODE Dir m_shLne set the Text | 1066 | // if MODE Dir m_shLne set the Text |
1050 | }else{ | 1067 | }else{ |
1051 | if( m_shLne ) | 1068 | if( m_shLne ) |
1052 | m_edit->setText( str[0].stripWhiteSpace() ); | 1069 | m_edit->setText( str[0].stripWhiteSpace() ); |
1070 | qWarning("selected here in slot clicked"); | ||
1053 | emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() ); | 1071 | emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() ); |
1072 | DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1073 | qWarning("file selected"); | ||
1074 | emit fileSelected( lnk ); | ||
1054 | } | 1075 | } |
1055 | } | 1076 | } |
1056 | break; | 1077 | break; |
1057 | } | 1078 | } |
1058 | } | 1079 | } |
1059 | } | 1080 | } |
1060 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) | 1081 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) |
1061 | { | 1082 | { |
1062 | if( item == 0 ) | 1083 | if( item == 0 ) |
1063 | return; | 1084 | return; |
1064 | 1085 | ||
1065 | if( button != Qt::RightButton ) | 1086 | if( button != Qt::RightButton ) |
1066 | return; | 1087 | return; |
1067 | slotContextMenu( item ); | 1088 | slotContextMenu( item ); |
1068 | } | 1089 | } |
1069 | void OFileSelector::slotContextMenu( QListViewItem *item) | 1090 | void OFileSelector::slotContextMenu( QListViewItem *item) |
1070 | { | 1091 | { |
1071 | 1092 | ||
1072 | } | 1093 | } |
1073 | void OFileSelector::slotChangedDir() | 1094 | void OFileSelector::slotChangedDir() |
1074 | { | 1095 | { |
1075 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 1096 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
1076 | if(sel->isDir() ){ | 1097 | if(sel->isDir() ){ |
1077 | QStringList str = QStringList::split("->", sel->text(1) ); | 1098 | QStringList str = QStringList::split("->", sel->text(1) ); |
1078 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); | 1099 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); |
1079 | } | 1100 | } |
1080 | } | 1101 | } |
1081 | void OFileSelector::slotOpen() | 1102 | void OFileSelector::slotOpen() |
1082 | { | 1103 | { |
1083 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 1104 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
1084 | if(!sel->isDir() ){ | 1105 | if(!sel->isDir() ){ |
1085 | QStringList str = QStringList::split("->", sel->text(1) ); | 1106 | QStringList str = QStringList::split("->", sel->text(1) ); |
1086 | slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() ); | 1107 | slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() ); |
1108 | qWarning("slot open"); | ||
1109 | // DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1110 | //emit fileSelected( lnk ); | ||
1087 | } | 1111 | } |
1088 | } | 1112 | } |
1089 | void OFileSelector::slotRescan() | 1113 | void OFileSelector::slotRescan() |
1090 | { | 1114 | { |
1091 | 1115 | ||
1092 | } | 1116 | } |
1093 | void OFileSelector::slotRename() | 1117 | void OFileSelector::slotRename() |
1094 | { | 1118 | { |
1095 | reparse(); | 1119 | reparse(); |
1096 | } | 1120 | } |
1097 | void OFileSelector::slotDelete() | 1121 | void OFileSelector::slotDelete() |
1098 | { | 1122 | { |
1099 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 1123 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
1100 | QStringList list = QStringList::split("->", sel->text(1) ); | 1124 | QStringList list = QStringList::split("->", sel->text(1) ); |
1101 | if( sel->isDir() ){ | 1125 | if( sel->isDir() ){ |
1102 | QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry | 1126 | QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry |
1103 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], | 1127 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], |
1104 | tr("Yes"),tr("No"),0,1,1) ) { | 1128 | tr("Yes"),tr("No"),0,1,1) ) { |
1105 | case 0: | 1129 | case 0: |
1106 | ::system(str.utf8().data() ); | 1130 | ::system(str.utf8().data() ); |
1107 | break; | 1131 | break; |
1108 | } | 1132 | } |
1109 | } else { | 1133 | } else { |
1110 | QFile::remove( list[0] ); | 1134 | QFile::remove( list[0] ); |
1111 | } | 1135 | } |
1112 | m_View->takeItem( sel ); | 1136 | m_View->takeItem( sel ); |
1113 | delete sel; | 1137 | delete sel; |
1114 | } | 1138 | } |
1115 | void OFileSelector::cdUP() | 1139 | void OFileSelector::cdUP() |
1116 | { | 1140 | { |
1117 | QDir dir( m_currentDir ); | 1141 | QDir dir( m_currentDir ); |
1118 | dir.cdUp(); | 1142 | dir.cdUp(); |
1119 | if(dir.exists() ){ | 1143 | if(dir.exists() ){ |
1120 | m_currentDir = dir.absPath(); | 1144 | m_currentDir = dir.absPath(); |
1121 | reparse(); | 1145 | reparse(); |
1122 | int count = m_location->count(); | 1146 | int count = m_location->count(); |
1123 | slotInsertLocationPath( m_currentDir, count); | 1147 | slotInsertLocationPath( m_currentDir, count); |
1124 | m_location->setCurrentItem( indexByString( m_location, m_currentDir)); | 1148 | m_location->setCurrentItem( indexByString( m_location, m_currentDir)); |
1125 | //this wont work in all instances | 1149 | //this wont work in all instances |
1126 | // FIXME | 1150 | // FIXME |
1127 | } | 1151 | } |
1128 | } | 1152 | } |
1129 | void OFileSelector::slotHome() | 1153 | void OFileSelector::slotHome() |
1130 | { | 1154 | { |
1131 | cd(QDir::homeDirPath() ); | 1155 | cd(QDir::homeDirPath() ); |
1132 | } | 1156 | } |
1133 | void OFileSelector::slotDoc() | 1157 | void OFileSelector::slotDoc() |
1134 | { | 1158 | { |
1135 | cd(QPEApplication::documentDir() ); | 1159 | cd(QPEApplication::documentDir() ); |
1136 | } | 1160 | } |
1137 | void OFileSelector::slotNavigate( ) | 1161 | void OFileSelector::slotNavigate( ) |
1138 | { | 1162 | { |
1139 | 1163 | ||
1140 | } | 1164 | } |
1141 | // fill the View with life | 1165 | // fill the View with life |
1142 | void OFileSelector::reparse() | 1166 | void OFileSelector::reparse() |
1143 | { | 1167 | { |
1144 | if( m_selector == NORMAL ) | 1168 | if( m_selector == NORMAL ) |
1145 | return; | 1169 | return; |
1146 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) | 1170 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) |
1147 | m_View->clear(); | 1171 | m_View->clear(); |
1148 | else // custom view | 1172 | else // custom view |
1149 | ; // currentView()->clear(); | 1173 | ; // currentView()->clear(); |
1150 | if( m_shChooser) | 1174 | if( m_shChooser) |
1151 | qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); | 1175 | qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); |
1152 | 1176 | ||
1153 | QString currentMimeType; | 1177 | QString currentMimeType; |
1154 | // let's update the mimetype | 1178 | // let's update the mimetype |
1155 | if( m_autoMime ){ | 1179 | if( m_autoMime ){ |
1156 | m_mimetypes.clear(); | 1180 | m_mimetypes.clear(); |
1157 | // ok we can change mimetype so we need to be able to give a selection | 1181 | // ok we can change mimetype so we need to be able to give a selection |
1158 | if( m_shChooser ) { | 1182 | if( m_shChooser ) { |
1159 | currentMimeType = m_mimeCheck->currentText(); | 1183 | currentMimeType = m_mimeCheck->currentText(); |
1160 | m_mimeCheck->clear(); | 1184 | m_mimeCheck->clear(); |
1161 | 1185 | ||
1162 | // let's find possible mimetypes | 1186 | // let's find possible mimetypes |
1163 | QDir dir( m_currentDir ); | 1187 | QDir dir( m_currentDir ); |
1164 | dir.setFilter( QDir::Files | QDir::Readable ); | 1188 | dir.setFilter( QDir::Files | QDir::Readable ); |
1165 | dir.setSorting( QDir::Size ); | 1189 | dir.setSorting( QDir::Size ); |
1166 | const QFileInfoList *list = dir.entryInfoList(); | 1190 | const QFileInfoList *list = dir.entryInfoList(); |
1167 | QFileInfoListIterator it( *list ); | 1191 | QFileInfoListIterator it( *list ); |
1168 | QFileInfo *fi; | 1192 | QFileInfo *fi; |
1169 | while( (fi=it.current() ) ) { | 1193 | while( (fi=it.current() ) ) { |
1170 | if( fi->extension() == QString::fromLatin1("desktop") ){ | 1194 | if( fi->extension() == QString::fromLatin1("desktop") ){ |
1171 | ++it; | 1195 | ++it; |
1172 | continue; | 1196 | continue; |
1173 | } | 1197 | } |
1174 | MimeType type( fi->absFilePath() ); | 1198 | MimeType type( fi->absFilePath() ); |
1175 | if( !m_mimetypes.contains( type.id() ) ){ | 1199 | if( !m_mimetypes.contains( type.id() ) ){ |
1176 | //qWarning("Type %s", type.id().latin1() ); | 1200 | //qWarning("Type %s", type.id().latin1() ); |
1177 | m_mimetypes.insert( type.id(), type.id() ); | 1201 | m_mimetypes.insert( type.id(), type.id() ); |
1178 | } | 1202 | } |
1179 | 1203 | ||
1180 | ++it; | 1204 | ++it; |
1181 | } | 1205 | } |
1182 | // add them to the chooser | 1206 | // add them to the chooser |
1183 | updateMimeCheck(); | 1207 | updateMimeCheck(); |
1184 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); | 1208 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); |
1185 | currentMimeType = m_mimeCheck->currentText(); | 1209 | currentMimeType = m_mimeCheck->currentText(); |
1186 | } | 1210 | } |
1187 | }else { // no autoMime | 1211 | }else { // no autoMime |
1188 | // let the mimetype be set from out side the m_mimeCheck FEATURE | 1212 | // let the mimetype be set from out side the m_mimeCheck FEATURE |
1189 | 1213 | ||
1190 | if( m_shChooser ){ | 1214 | if( m_shChooser ){ |
1191 | currentMimeType = m_mimeCheck->currentText(); | 1215 | currentMimeType = m_mimeCheck->currentText(); |
1192 | // updateMimeCheck(); | 1216 | // updateMimeCheck(); |
1193 | } | 1217 | } |
1194 | } | 1218 | } |
1195 | // now we got our mimetypes we can add the files | 1219 | // now we got our mimetypes we can add the files |
1196 | 1220 | ||
1197 | QDir dir( m_currentDir ); | 1221 | QDir dir( m_currentDir ); |
1198 | 1222 | ||
1199 | int sort; | 1223 | int sort; |
1200 | if ( m_case ) | 1224 | if ( m_case ) |
1201 | sort = (QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed); | 1225 | sort = (QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed); |
1202 | else | 1226 | else |
1203 | sort = (QDir::Name | QDir::DirsFirst | QDir::Reversed); | 1227 | sort = (QDir::Name | QDir::DirsFirst | QDir::Reversed); |
1204 | dir.setSorting( sort ); | 1228 | dir.setSorting( sort ); |
1205 | 1229 | ||
1206 | int filter; | 1230 | int filter; |
1207 | if( m_selector == EXTENDED_ALL /*|| m_selector ==CUSTOM_ALL */ ){ | 1231 | if( m_selector == EXTENDED_ALL /*|| m_selector ==CUSTOM_ALL */ ){ |
1208 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 1232 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
1209 | }else | 1233 | }else |
1210 | filter = QDir::Files | QDir::Dirs | QDir::All; | 1234 | filter = QDir::Files | QDir::Dirs | QDir::All; |
1211 | dir.setFilter( filter ); | 1235 | dir.setFilter( filter ); |
1212 | 1236 | ||
1213 | // now go through all files | 1237 | // now go through all files |
1214 | const QFileInfoList *list = dir.entryInfoList(); | 1238 | const QFileInfoList *list = dir.entryInfoList(); |
1215 | QFileInfoListIterator it( *list ); | 1239 | QFileInfoListIterator it( *list ); |
1216 | QFileInfo *fi; | 1240 | QFileInfo *fi; |
1217 | while( (fi=it.current() ) ){ | 1241 | while( (fi=it.current() ) ){ |
1218 | //qWarning("True and only" ); | 1242 | //qWarning("True and only" ); |
1219 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ | 1243 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ |
1220 | //qWarning(".. or ." ); | 1244 | //qWarning(".. or ." ); |
1221 | ++it; | 1245 | ++it; |
1222 | continue; | 1246 | continue; |
1223 | } | 1247 | } |
1224 | if( fi->isSymLink() ){ | 1248 | if( fi->isSymLink() ){ |
1225 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); | 1249 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); |
1226 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos | 1250 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos |
1227 | QFileInfo info( file ); | 1251 | QFileInfo info( file ); |
1228 | if( !info.exists() ){ | 1252 | if( !info.exists() ){ |
1229 | addSymlink( currentMimeType, fi, TRUE ); | 1253 | addSymlink( currentMimeType, fi, TRUE ); |
1230 | break; | 1254 | break; |
1231 | }else if( info.isDir() ){ | 1255 | }else if( info.isDir() ){ |
1232 | addDir( currentMimeType, fi, TRUE ); | 1256 | addDir( currentMimeType, fi, TRUE ); |
1233 | break; | 1257 | break; |
1234 | }else if( info.isFile() ){ | 1258 | }else if( info.isFile() ){ |
1235 | addFile( currentMimeType, fi, TRUE ); | 1259 | addFile( currentMimeType, fi, TRUE ); |
1236 | break; | 1260 | break; |
1237 | }else if( info.isSymLink() ){ | 1261 | }else if( info.isSymLink() ){ |
1238 | file = info.dirPath(true ) + "/" + info.readLink() ; | 1262 | file = info.dirPath(true ) + "/" + info.readLink() ; |
1239 | break; | 1263 | break; |
1240 | }else if( i == 4){ | 1264 | }else if( i == 4){ |
1241 | addSymlink( currentMimeType, fi ); | 1265 | addSymlink( currentMimeType, fi ); |
1242 | } | 1266 | } |
1243 | } // off for loop | 1267 | } // off for loop |
1244 | }else if( fi->isDir() ){ | 1268 | }else if( fi->isDir() ){ |
1245 | addDir( currentMimeType, fi ); | 1269 | addDir( currentMimeType, fi ); |
1246 | }else if( fi->isFile() ){ | 1270 | }else if( fi->isFile() ){ |
1247 | addFile( currentMimeType, fi ); | 1271 | addFile( currentMimeType, fi ); |
1248 | } | 1272 | } |
1249 | //qWarning( "%s", fi->fileName().latin1() ); | 1273 | //qWarning( "%s", fi->fileName().latin1() ); |
1250 | ++it; | 1274 | ++it; |
1251 | } // of while loop | 1275 | } // of while loop |
1252 | m_View->sort(); | 1276 | m_View->sort(); |
1253 | if( m_shTool ){ | 1277 | if( m_shTool ){ |
1254 | m_location->insertItem( m_currentDir ); | 1278 | m_location->insertItem( m_currentDir ); |
1255 | 1279 | ||
1256 | } | 1280 | } |
1257 | // reenable painting and updates | 1281 | // reenable painting and updates |
1258 | } | 1282 | } |