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