author | zecke <zecke> | 2002-04-17 17:22:50 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-04-17 17:22:50 (UTC) |
commit | b94bcfb586b838885d7d0503623ea36ee0054464 (patch) (unidiff) | |
tree | da2f5fb0e422e38d6fae0ab8f8572b332e7da08b | |
parent | b382414bf0446b6facd11d35df5dc097edbd5396 (diff) | |
download | opie-b94bcfb586b838885d7d0503623ea36ee0054464.zip opie-b94bcfb586b838885d7d0503623ea36ee0054464.tar.gz opie-b94bcfb586b838885d7d0503623ea36ee0054464.tar.bz2 |
include the current directory in the filename
-rw-r--r-- | libopie/ofileselector.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index 968541a..ea19143 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -76,513 +76,513 @@ namespace { | |||
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, | 79 | OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, |
80 | const QString &fileName, const QStringList &mimetypes ) : QWidget( wid ) | 80 | const QString &fileName, const QStringList &mimetypes ) : QWidget( wid ) |
81 | { | 81 | { |
82 | if(wid!=0) | 82 | if(wid!=0) |
83 | resize(wid->width(),wid->height()); | 83 | resize(wid->width(),wid->height()); |
84 | m_selector = selector; | 84 | m_selector = selector; |
85 | m_currentDir = dirName; | 85 | m_currentDir = dirName; |
86 | m_name = fileName; | 86 | m_name = fileName; |
87 | m_mimetypes = mimetypes; | 87 | m_mimetypes = mimetypes; |
88 | if( mimetypes.isEmpty() ) | 88 | if( mimetypes.isEmpty() ) |
89 | m_autoMime = true; | 89 | m_autoMime = true; |
90 | 90 | ||
91 | m_mode = mode; | 91 | m_mode = mode; |
92 | m_shTool = true; | 92 | m_shTool = true; |
93 | m_shPerm = true; | 93 | m_shPerm = true; |
94 | m_shLne = true; | 94 | m_shLne = true; |
95 | m_shChooser = true; | 95 | m_shChooser = true; |
96 | m_shYesNo = true; | 96 | m_shYesNo = true; |
97 | // for FILESELECTOR only view is interesting | 97 | // for FILESELECTOR only view is interesting |
98 | m_location = 0; | 98 | m_location = 0; |
99 | m_homeButton = 0; | 99 | m_homeButton = 0; |
100 | m_docButton = 0; | 100 | m_docButton = 0; |
101 | m_hideButton = 0; | 101 | m_hideButton = 0; |
102 | m_ok = 0; | 102 | m_ok = 0; |
103 | m_cancel = 0; | 103 | m_cancel = 0; |
104 | m_reread = 0; | 104 | m_reread = 0; |
105 | m_up = 0; | 105 | m_up = 0; |
106 | m_View = 0; | 106 | m_View = 0; |
107 | m_select = 0; | 107 | m_select = 0; |
108 | m_stack = 0; | 108 | m_stack = 0; |
109 | 109 | ||
110 | m_select = 0; | 110 | m_select = 0; |
111 | m_stack = 0; | 111 | m_stack = 0; |
112 | m_lay = 0; | 112 | m_lay = 0; |
113 | m_boxToolbar = 0; | 113 | m_boxToolbar = 0; |
114 | m_boxOk = 0; | 114 | m_boxOk = 0; |
115 | m_edit = 0; | 115 | m_edit = 0; |
116 | 116 | ||
117 | m_fnLabel = 0; | 117 | m_fnLabel = 0; |
118 | m_checkPerm = 0; | 118 | m_checkPerm = 0; |
119 | m_mimeCheck = 0; | 119 | m_mimeCheck = 0; |
120 | m_viewCheck = 0; | 120 | m_viewCheck = 0; |
121 | 121 | ||
122 | m_pseudo = 0; | 122 | m_pseudo = 0; |
123 | m_pseudoLayout = 0; | 123 | m_pseudoLayout = 0; |
124 | 124 | ||
125 | m_dir = true; | 125 | m_dir = true; |
126 | m_files = true; | 126 | m_files = true; |
127 | m_custom = 0; | 127 | m_custom = 0; |
128 | m_showPopup = true; | 128 | m_showPopup = true; |
129 | 129 | ||
130 | if(m_pixmaps == 0 ) // init the pixmaps | 130 | if(m_pixmaps == 0 ) // init the pixmaps |
131 | initPics(); | 131 | initPics(); |
132 | 132 | ||
133 | m_lay = new QVBoxLayout(this); | 133 | m_lay = new QVBoxLayout(this); |
134 | init(); | 134 | init(); |
135 | m_edit->setText( fileName ); | 135 | m_edit->setText( fileName ); |
136 | } | 136 | } |
137 | void OFileSelector::initPics() | 137 | void OFileSelector::initPics() |
138 | { | 138 | { |
139 | qWarning("init pics" ); | 139 | qWarning("init pics" ); |
140 | m_pixmaps = new QMap<QString,QPixmap>; | 140 | m_pixmaps = new QMap<QString,QPixmap>; |
141 | QPixmap pm = Resource::loadPixmap( "folder" ); | 141 | QPixmap pm = Resource::loadPixmap( "folder" ); |
142 | QPixmap lnk = Resource::loadPixmap( "symlink" ); | 142 | QPixmap lnk = Resource::loadPixmap( "symlink" ); |
143 | QPainter painter( &pm ); | 143 | QPainter painter( &pm ); |
144 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 144 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
145 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 145 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
146 | m_pixmaps->insert("dirsymlink", pm ); | 146 | m_pixmaps->insert("dirsymlink", pm ); |
147 | 147 | ||
148 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | 148 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); |
149 | QPainter pen(&pm2 ); | 149 | QPainter pen(&pm2 ); |
150 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | 150 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); |
151 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | 151 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); |
152 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 152 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
153 | 153 | ||
154 | }; | 154 | }; |
155 | // let's initialize the gui | 155 | // let's initialize the gui |
156 | /** | 156 | /** |
157 | -------------------- | 157 | -------------------- |
158 | | cmbBox Button | | 158 | | cmbBox Button | |
159 | -------------------- | 159 | -------------------- |
160 | | FileSlector | | 160 | | FileSlector | |
161 | | or | | 161 | | or | |
162 | | OSelector | | 162 | | OSelector | |
163 | | | | 163 | | | |
164 | | | | 164 | | | |
165 | ____________________ | 165 | ____________________ |
166 | | LineEdit | | 166 | | LineEdit | |
167 | ____________________ | 167 | ____________________ |
168 | | Permission Bar | | 168 | | Permission Bar | |
169 | ____________________ | 169 | ____________________ |
170 | | ViewChoose | | 170 | | ViewChoose | |
171 | ____________________ | 171 | ____________________ |
172 | | Save Cancel| | 172 | | Save Cancel| |
173 | ____________________ | 173 | ____________________ |
174 | */ | 174 | */ |
175 | void OFileSelector::delItems() | 175 | void OFileSelector::delItems() |
176 | { | 176 | { |
177 | QLayoutIterator it = m_lay->iterator(); | 177 | QLayoutIterator it = m_lay->iterator(); |
178 | while ( it.current() != 0 ){ | 178 | while ( it.current() != 0 ){ |
179 | it.deleteCurrent(); | 179 | it.deleteCurrent(); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | void OFileSelector::init() | 182 | void OFileSelector::init() |
183 | { | 183 | { |
184 | 184 | ||
185 | m_stack = new QWidgetStack(this, "wstack" ); | 185 | m_stack = new QWidgetStack(this, "wstack" ); |
186 | if( m_selector == NORMAL ){ | 186 | if( m_selector == NORMAL ){ |
187 | QString currMime; | 187 | QString currMime; |
188 | if( m_mimeCheck != 0 ) | 188 | if( m_mimeCheck != 0 ) |
189 | currMime = m_mimeCheck->currentText(); | 189 | currMime = m_mimeCheck->currentText(); |
190 | 190 | ||
191 | updateMimes(); | 191 | updateMimes(); |
192 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); | 192 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); |
193 | m_stack->addWidget(m_select, NORMAL ); | 193 | m_stack->addWidget(m_select, NORMAL ); |
194 | m_lay->addWidget(m_stack ); | 194 | m_lay->addWidget(m_stack ); |
195 | m_stack->raiseWidget(NORMAL ); | 195 | m_stack->raiseWidget(NORMAL ); |
196 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); | 196 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); |
197 | m_pseudoLayout = 0l; | 197 | m_pseudoLayout = 0l; |
198 | }else { | 198 | }else { |
199 | initializeListView(); | 199 | initializeListView(); |
200 | } | 200 | } |
201 | 201 | ||
202 | if(m_shLne ){ | 202 | if(m_shLne ){ |
203 | initializeName(); | 203 | initializeName(); |
204 | } | 204 | } |
205 | 205 | ||
206 | if(m_shPerm ){ | 206 | if(m_shPerm ){ |
207 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); | 207 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); |
208 | m_checkPerm->setChecked( false ); | 208 | m_checkPerm->setChecked( false ); |
209 | m_lay->addWidget(m_checkPerm ); | 209 | m_lay->addWidget(m_checkPerm ); |
210 | } | 210 | } |
211 | 211 | ||
212 | if( m_shChooser ) | 212 | if( m_shChooser ) |
213 | initializeChooser(); | 213 | initializeChooser(); |
214 | 214 | ||
215 | if(m_shYesNo ) | 215 | if(m_shYesNo ) |
216 | initializeYes(); | 216 | initializeYes(); |
217 | 217 | ||
218 | 218 | ||
219 | }; | 219 | }; |
220 | 220 | ||
221 | void OFileSelector::setYesCancelVisible( bool show ) | 221 | void OFileSelector::setYesCancelVisible( bool show ) |
222 | { | 222 | { |
223 | if ( show == m_shYesNo ) | 223 | if ( show == m_shYesNo ) |
224 | return; | 224 | return; |
225 | m_shYesNo = show; | 225 | m_shYesNo = show; |
226 | if( !show ){ | 226 | if( !show ){ |
227 | delete m_ok; | 227 | delete m_ok; |
228 | delete m_cancel; | 228 | delete m_cancel; |
229 | m_ok = 0; | 229 | m_ok = 0; |
230 | m_cancel = 0; | 230 | m_cancel = 0; |
231 | // delete m_boxOk; all ready deleted in delItems | 231 | // delete m_boxOk; all ready deleted in delItems |
232 | } | 232 | } |
233 | updateLay(); // recreate it and save the other states | 233 | updateLay(); // recreate it and save the other states |
234 | } | 234 | } |
235 | 235 | ||
236 | void OFileSelector::setToolbarVisible( bool show ) | 236 | void OFileSelector::setToolbarVisible( bool show ) |
237 | { | 237 | { |
238 | if ( m_shTool == show ) | 238 | if ( m_shTool == show ) |
239 | return; | 239 | return; |
240 | if(!m_shTool ){ | 240 | if(!m_shTool ){ |
241 | delete m_boxToolbar; | 241 | delete m_boxToolbar; |
242 | delete m_homeButton; | 242 | delete m_homeButton; |
243 | delete m_docButton; | 243 | delete m_docButton; |
244 | delete m_location; | 244 | delete m_location; |
245 | delete m_up; | 245 | delete m_up; |
246 | m_boxToolbar = 0; | 246 | m_boxToolbar = 0; |
247 | m_homeButton = 0; | 247 | m_homeButton = 0; |
248 | m_docButton = 0; | 248 | m_docButton = 0; |
249 | m_location = 0; | 249 | m_location = 0; |
250 | m_up = 0; | 250 | m_up = 0; |
251 | }; | 251 | }; |
252 | updateLay();// overkill fix it | 252 | updateLay();// overkill fix it |
253 | } | 253 | } |
254 | 254 | ||
255 | void OFileSelector::setPermissionBarVisible( bool show ) | 255 | void OFileSelector::setPermissionBarVisible( bool show ) |
256 | { | 256 | { |
257 | if( show == m_shPerm ) | 257 | if( show == m_shPerm ) |
258 | return; | 258 | return; |
259 | 259 | ||
260 | m_shPerm = show; | 260 | m_shPerm = show; |
261 | 261 | ||
262 | updateLay(); | 262 | updateLay(); |
263 | } | 263 | } |
264 | void OFileSelector::setLineEditVisible( bool show ) | 264 | void OFileSelector::setLineEditVisible( bool show ) |
265 | { | 265 | { |
266 | if( show == m_shLne ) | 266 | if( show == m_shLne ) |
267 | return; | 267 | return; |
268 | 268 | ||
269 | m_shLne = show; | 269 | m_shLne = show; |
270 | if( !show ){ | 270 | if( !show ){ |
271 | delete m_edit; | 271 | delete m_edit; |
272 | delete m_fnLabel; | 272 | delete m_fnLabel; |
273 | m_edit = 0; | 273 | m_edit = 0; |
274 | m_fnLabel = 0; | 274 | m_fnLabel = 0; |
275 | //delete m_boxName; will be deleted | 275 | //delete m_boxName; will be deleted |
276 | } | 276 | } |
277 | updateLay(); | 277 | updateLay(); |
278 | } | 278 | } |
279 | void OFileSelector::setChooserVisible( bool show ) | 279 | void OFileSelector::setChooserVisible( bool show ) |
280 | { | 280 | { |
281 | if( show = m_shChooser ) | 281 | if( show = m_shChooser ) |
282 | return; | 282 | return; |
283 | m_shChooser = show; | 283 | m_shChooser = show; |
284 | if( !show ){ | 284 | if( !show ){ |
285 | delete m_mimeCheck; | 285 | delete m_mimeCheck; |
286 | delete m_viewCheck; | 286 | delete m_viewCheck; |
287 | m_mimeCheck = 0; | 287 | m_mimeCheck = 0; |
288 | m_viewCheck = 0; | 288 | m_viewCheck = 0; |
289 | } | 289 | } |
290 | updateLay(); | 290 | updateLay(); |
291 | } | 291 | } |
292 | QCheckBox* OFileSelector::permissionCheckbox( ) | 292 | QCheckBox* OFileSelector::permissionCheckbox( ) |
293 | { | 293 | { |
294 | return m_checkPerm; | 294 | return m_checkPerm; |
295 | } | 295 | } |
296 | void OFileSelector::setCaseSensetive( bool caSe ) | 296 | void OFileSelector::setCaseSensetive( bool caSe ) |
297 | { | 297 | { |
298 | m_case = caSe; | 298 | m_case = caSe; |
299 | reparse(); | 299 | reparse(); |
300 | } | 300 | } |
301 | void OFileSelector::setShowFiles(bool files ){ | 301 | void OFileSelector::setShowFiles(bool files ){ |
302 | m_files = files; | 302 | m_files = files; |
303 | reparse(); | 303 | reparse(); |
304 | } | 304 | } |
305 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) | 305 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) |
306 | { | 306 | { |
307 | //delete oldpopup; | 307 | //delete oldpopup; |
308 | m_custom = pop; | 308 | m_custom = pop; |
309 | } | 309 | } |
310 | bool OFileSelector::setPermission( ) const | 310 | bool OFileSelector::setPermission( ) const |
311 | { | 311 | { |
312 | if( m_checkPerm == 0 ) | 312 | if( m_checkPerm == 0 ) |
313 | return false; | 313 | return false; |
314 | else | 314 | else |
315 | return m_checkPerm->isChecked(); | 315 | return m_checkPerm->isChecked(); |
316 | } | 316 | } |
317 | void OFileSelector::setPermissionChecked( bool check ) | 317 | void OFileSelector::setPermissionChecked( bool check ) |
318 | { | 318 | { |
319 | if( m_checkPerm == 0 ) | 319 | if( m_checkPerm == 0 ) |
320 | return; | 320 | return; |
321 | m_checkPerm->setChecked( check ); | 321 | m_checkPerm->setChecked( check ); |
322 | } | 322 | } |
323 | QString OFileSelector::selectedName( )const | 323 | QString OFileSelector::selectedName( )const |
324 | { | 324 | { |
325 | QString string; | 325 | QString string; |
326 | if( m_selector == NORMAL ){ | 326 | if( m_selector == NORMAL ){ |
327 | const DocLnk *lnk = m_select->selected(); | 327 | const DocLnk *lnk = m_select->selected(); |
328 | string = lnk->file(); | 328 | string = lnk->file(); |
329 | }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 329 | }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
330 | QListViewItem *item = m_View->currentItem(); | 330 | QListViewItem *item = m_View->currentItem(); |
331 | if(item != 0 ){ | 331 | if(item != 0 ){ |
332 | string = item->text( 1 ); | 332 | string = m_currentDir + "/" + item->text( 1 ); |
333 | } | 333 | } |
334 | } | 334 | } |
335 | return string; | 335 | return string; |
336 | } | 336 | } |
337 | QStringList OFileSelector::selectedNames()const | 337 | QStringList OFileSelector::selectedNames()const |
338 | { | 338 | { |
339 | QStringList list; | 339 | QStringList list; |
340 | return list; | 340 | return list; |
341 | } | 341 | } |
342 | DocLnk OFileSelector::selectedDocument( )const | 342 | DocLnk OFileSelector::selectedDocument( )const |
343 | { | 343 | { |
344 | DocLnk lnk; | 344 | DocLnk lnk; |
345 | return lnk; | 345 | return lnk; |
346 | } | 346 | } |
347 | void OFileSelector::updateLay() | 347 | void OFileSelector::updateLay() |
348 | { | 348 | { |
349 | /* if( m_shTool ) | 349 | /* if( m_shTool ) |
350 | // | 350 | // |
351 | else | 351 | else |
352 | // hide | 352 | // hide |
353 | */ | 353 | */ |
354 | // save the state | 354 | // save the state |
355 | bool check = false; | 355 | bool check = false; |
356 | if( m_checkPerm != 0 ) | 356 | if( m_checkPerm != 0 ) |
357 | check = m_checkPerm->isChecked(); | 357 | check = m_checkPerm->isChecked(); |
358 | QString text; | 358 | QString text; |
359 | 359 | ||
360 | if( m_edit != 0 ) | 360 | if( m_edit != 0 ) |
361 | text = m_edit->text(); | 361 | text = m_edit->text(); |
362 | // save current mimetype | 362 | // save current mimetype |
363 | 363 | ||
364 | delItems(); | 364 | delItems(); |
365 | delete m_checkPerm; | 365 | delete m_checkPerm; |
366 | m_checkPerm = 0; | 366 | m_checkPerm = 0; |
367 | delete m_edit; | 367 | delete m_edit; |
368 | m_edit = 0; | 368 | m_edit = 0; |
369 | delete m_fnLabel; | 369 | delete m_fnLabel; |
370 | m_fnLabel = 0; | 370 | m_fnLabel = 0; |
371 | delete m_ok; | 371 | delete m_ok; |
372 | m_ok = 0; | 372 | m_ok = 0; |
373 | delete m_cancel; | 373 | delete m_cancel; |
374 | m_cancel = 0; | 374 | m_cancel = 0; |
375 | delete m_mimeCheck; | 375 | delete m_mimeCheck; |
376 | m_mimeCheck = 0; | 376 | m_mimeCheck = 0; |
377 | delete m_viewCheck; | 377 | delete m_viewCheck; |
378 | m_viewCheck = 0; | 378 | m_viewCheck = 0; |
379 | delete m_select; // test | 379 | delete m_select; // test |
380 | delete m_stack; | 380 | delete m_stack; |
381 | //delete m_list; | 381 | //delete m_list; |
382 | init(); | 382 | init(); |
383 | if( m_shLne ) | 383 | if( m_shLne ) |
384 | m_edit->setText(text ); | 384 | m_edit->setText(text ); |
385 | if( m_shPerm ) | 385 | if( m_shPerm ) |
386 | m_checkPerm->setChecked(check ); | 386 | m_checkPerm->setChecked(check ); |
387 | } | 387 | } |
388 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve | 388 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve |
389 | // insert QListViewItems with the right options | 389 | // insert QListViewItems with the right options |
390 | bool OFileSelector::compliesMime(const QString &path, const QString &mime ) | 390 | bool OFileSelector::compliesMime(const QString &path, const QString &mime ) |
391 | { | 391 | { |
392 | if( mime == "All" ) | 392 | if( mime == "All" ) |
393 | return true; | 393 | return true; |
394 | MimeType type( path ); | 394 | MimeType type( path ); |
395 | if( type.id() == mime ) | 395 | if( type.id() == mime ) |
396 | return true; | 396 | return true; |
397 | return false; | 397 | return false; |
398 | } | 398 | } |
399 | 399 | ||
400 | void OFileSelector::reparse() | 400 | void OFileSelector::reparse() |
401 | { | 401 | { |
402 | if(m_View== 0 || m_selector == NORMAL) | 402 | if(m_View== 0 || m_selector == NORMAL) |
403 | return; | 403 | return; |
404 | 404 | ||
405 | m_View->clear(); | 405 | m_View->clear(); |
406 | 406 | ||
407 | 407 | ||
408 | QString currMime =m_mimeCheck->currentText(); | 408 | QString currMime =m_mimeCheck->currentText(); |
409 | // update the mimetype now | 409 | // update the mimetype now |
410 | if( m_autoMime ) { | 410 | if( m_autoMime ) { |
411 | QDir dir( m_currentDir ); | 411 | QDir dir( m_currentDir ); |
412 | m_mimetypes.clear(); | 412 | m_mimetypes.clear(); |
413 | m_mimeCheck->clear(); | 413 | m_mimeCheck->clear(); |
414 | dir.setFilter( QDir::Files | QDir::Readable ); | 414 | dir.setFilter( QDir::Files | QDir::Readable ); |
415 | dir.setSorting(QDir::Size ); | 415 | dir.setSorting(QDir::Size ); |
416 | const QFileInfoList *list = dir.entryInfoList(); | 416 | const QFileInfoList *list = dir.entryInfoList(); |
417 | QFileInfoListIterator it( *list ); | 417 | QFileInfoListIterator it( *list ); |
418 | QFileInfo *fi; | 418 | QFileInfo *fi; |
419 | while( (fi=it.current()) ){ | 419 | while( (fi=it.current()) ){ |
420 | if(fi->extension() == QString::fromLatin1("desktop") ){ | 420 | if(fi->extension() == QString::fromLatin1("desktop") ){ |
421 | ++it; | 421 | ++it; |
422 | continue; | 422 | continue; |
423 | } | 423 | } |
424 | MimeType type(fi->filePath() ); | 424 | MimeType type(fi->filePath() ); |
425 | if( !m_mimetypes.contains( type.id() ) ) | 425 | if( !m_mimetypes.contains( type.id() ) ) |
426 | m_mimetypes.append( type.id() ); | 426 | m_mimetypes.append( type.id() ); |
427 | 427 | ||
428 | ++it; | 428 | ++it; |
429 | } | 429 | } |
430 | m_mimetypes.prepend("All" ); | 430 | m_mimetypes.prepend("All" ); |
431 | m_mimeCheck->insertStringList(m_mimetypes ); | 431 | m_mimeCheck->insertStringList(m_mimetypes ); |
432 | // set it to the current mimetype | 432 | // set it to the current mimetype |
433 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); | 433 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); |
434 | }; | 434 | }; |
435 | QDir dir( m_currentDir ); | 435 | QDir dir( m_currentDir ); |
436 | //dir.setFilter(-1 ); | 436 | //dir.setFilter(-1 ); |
437 | int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; | 437 | int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; |
438 | if( m_case ) | 438 | if( m_case ) |
439 | sort = QDir::IgnoreCase; | 439 | sort = QDir::IgnoreCase; |
440 | dir.setSorting( sort ); | 440 | dir.setSorting( sort ); |
441 | 441 | ||
442 | int filter; | 442 | int filter; |
443 | /* if( m_dir && !m_files) | 443 | /* if( m_dir && !m_files) |
444 | filter |= QDir::Dirs; | 444 | filter |= QDir::Dirs; |
445 | else if( !m_dir && m_files ) | 445 | else if( !m_dir && m_files ) |
446 | filter |= QDir::Files; | 446 | filter |= QDir::Files; |
447 | else | 447 | else |
448 | filter |= QDir::All; | 448 | filter |= QDir::All; |
449 | */ | 449 | */ |
450 | if( m_selector == EXTENDED_ALL ) | 450 | if( m_selector == EXTENDED_ALL ) |
451 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 451 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
452 | else | 452 | else |
453 | filter = QDir::Files | QDir::Dirs | QDir::All; | 453 | filter = QDir::Files | QDir::Dirs | QDir::All; |
454 | dir.setFilter( filter ); | 454 | dir.setFilter( filter ); |
455 | 455 | ||
456 | const QFileInfoList *list = dir.entryInfoList(); | 456 | const QFileInfoList *list = dir.entryInfoList(); |
457 | QFileInfoListIterator it( *list ); | 457 | QFileInfoListIterator it( *list ); |
458 | QFileInfo *fi; | 458 | QFileInfo *fi; |
459 | while( (fi=it.current()) ){ | 459 | while( (fi=it.current()) ){ |
460 | if(fi->fileName() == ".." || fi->fileName() == "." ){ | 460 | if(fi->fileName() == ".." || fi->fileName() == "." ){ |
461 | ++it; | 461 | ++it; |
462 | continue; | 462 | continue; |
463 | } | 463 | } |
464 | qWarning("Test: %s", fi->fileName().latin1() ); | 464 | qWarning("Test: %s", fi->fileName().latin1() ); |
465 | if(fi->isSymLink() ){ | 465 | if(fi->isSymLink() ){ |
466 | qWarning("Symlink %s", fi->fileName().latin1() ); | 466 | qWarning("Symlink %s", fi->fileName().latin1() ); |
467 | QString file = fi->dirPath(true)+"/"+ fi->readLink(); | 467 | QString file = fi->dirPath(true)+"/"+ fi->readLink(); |
468 | qWarning("File ->%s", file.latin1() ); | 468 | qWarning("File ->%s", file.latin1() ); |
469 | for(int i=0; i<=4; i++ ){ // prepend from dos | 469 | for(int i=0; i<=4; i++ ){ // prepend from dos |
470 | QFileInfo info( file ); | 470 | QFileInfo info( file ); |
471 | if( !info.exists() ){ | 471 | if( !info.exists() ){ |
472 | qWarning("does not exist" ); | 472 | qWarning("does not exist" ); |
473 | addSymlink(currMime, fi, TRUE ); | 473 | addSymlink(currMime, fi, TRUE ); |
474 | break; | 474 | break; |
475 | }else if( info.isDir() ){ | 475 | }else if( info.isDir() ){ |
476 | qWarning("isDir" ); | 476 | qWarning("isDir" ); |
477 | addDir(currMime, fi, TRUE ); | 477 | addDir(currMime, fi, TRUE ); |
478 | break; | 478 | break; |
479 | }else if( info.isFile() ){ | 479 | }else if( info.isFile() ){ |
480 | qWarning("isFile" ); | 480 | qWarning("isFile" ); |
481 | addFile(currMime, fi, TRUE ); | 481 | addFile(currMime, fi, TRUE ); |
482 | break; | 482 | break; |
483 | }else if( info.isSymLink() ){ | 483 | }else if( info.isSymLink() ){ |
484 | file = info.dirPath(true)+ "/"+ info.readLink(); | 484 | file = info.dirPath(true)+ "/"+ info.readLink(); |
485 | qWarning("isSymlink again %s", file.latin1() ); | 485 | qWarning("isSymlink again %s", file.latin1() ); |
486 | }else if( i == 4 ){ // just insert it and have the symlink symbol | 486 | }else if( i == 4 ){ // just insert it and have the symlink symbol |
487 | addSymlink(currMime, fi ); | 487 | addSymlink(currMime, fi ); |
488 | qWarning("level too deep" ); | 488 | qWarning("level too deep" ); |
489 | } | 489 | } |
490 | } | 490 | } |
491 | }else if( fi->isDir() ){ | 491 | }else if( fi->isDir() ){ |
492 | addDir(currMime, fi ); | 492 | addDir(currMime, fi ); |
493 | }else if( fi->isFile() ) { // file ? | 493 | }else if( fi->isFile() ) { // file ? |
494 | addFile(currMime, fi ); | 494 | addFile(currMime, fi ); |
495 | } | 495 | } |
496 | ++it; | 496 | ++it; |
497 | } | 497 | } |
498 | m_View->sort(); | 498 | m_View->sort(); |
499 | } | 499 | } |
500 | QString OFileSelector::directory()const | 500 | QString OFileSelector::directory()const |
501 | { | 501 | { |
502 | return m_currentDir; | 502 | return m_currentDir; |
503 | } | 503 | } |
504 | int OFileSelector::fileCount() | 504 | int OFileSelector::fileCount() |
505 | { | 505 | { |
506 | return 0; | 506 | return 0; |
507 | } | 507 | } |
508 | void OFileSelector::slotOk( ) | 508 | void OFileSelector::slotOk( ) |
509 | { | 509 | { |
510 | emit ok(); | 510 | emit ok(); |
511 | } | 511 | } |
512 | void OFileSelector::slotCancel( ) | 512 | void OFileSelector::slotCancel( ) |
513 | { | 513 | { |
514 | emit cancel(); | 514 | emit cancel(); |
515 | } | 515 | } |
516 | 516 | ||
517 | void OFileSelector::initializeName() | 517 | void OFileSelector::initializeName() |
518 | { | 518 | { |
519 | m_boxName = new QHBoxLayout(this ); | 519 | m_boxName = new QHBoxLayout(this ); |
520 | m_edit = new QLineEdit(this ); | 520 | m_edit = new QLineEdit(this ); |
521 | m_fnLabel = new QLabel(this ); | 521 | m_fnLabel = new QLabel(this ); |
522 | m_fnLabel->setText(tr("Name:") ); | 522 | m_fnLabel->setText(tr("Name:") ); |
523 | m_boxName->addWidget(m_fnLabel ); | 523 | m_boxName->addWidget(m_fnLabel ); |
524 | m_boxName->insertSpacing(1, 8 ); | 524 | m_boxName->insertSpacing(1, 8 ); |
525 | m_boxName->addWidget(m_edit, 100 ); | 525 | m_boxName->addWidget(m_edit, 100 ); |
526 | 526 | ||
527 | m_lay->addLayout(m_boxName); | 527 | m_lay->addLayout(m_boxName); |
528 | } | 528 | } |
529 | void OFileSelector::initializeYes() | 529 | void OFileSelector::initializeYes() |
530 | { | 530 | { |
531 | m_ok = new QPushButton("&Save", this, "save" ); | 531 | m_ok = new QPushButton("&Save", this, "save" ); |
532 | m_cancel = new QPushButton("C&ancel", this, "cancel" ); | 532 | m_cancel = new QPushButton("C&ancel", this, "cancel" ); |
533 | m_boxOk = new QHBoxLayout(this ); | 533 | m_boxOk = new QHBoxLayout(this ); |
534 | m_boxOk->addWidget( m_ok, Qt::AlignHCenter ); | 534 | m_boxOk->addWidget( m_ok, Qt::AlignHCenter ); |
535 | m_boxOk->insertSpacing(1, 8 ); | 535 | m_boxOk->insertSpacing(1, 8 ); |
536 | m_boxOk->addWidget( m_cancel, Qt::AlignHCenter); | 536 | m_boxOk->addWidget( m_cancel, Qt::AlignHCenter); |
537 | m_lay->addLayout(m_boxOk ); | 537 | m_lay->addLayout(m_boxOk ); |
538 | connect(m_ok, SIGNAL(clicked() ), | 538 | connect(m_ok, SIGNAL(clicked() ), |
539 | this, SLOT(slotOk() ) ); | 539 | this, SLOT(slotOk() ) ); |
540 | connect(m_cancel, SIGNAL(clicked() ), | 540 | connect(m_cancel, SIGNAL(clicked() ), |
541 | this, SLOT(slotCancel() ) ); | 541 | this, SLOT(slotCancel() ) ); |
542 | 542 | ||
543 | } | 543 | } |
544 | void OFileSelector::initializeChooser() | 544 | void OFileSelector::initializeChooser() |
545 | { | 545 | { |
546 | m_boxView = new QHBoxLayout(this ); | 546 | m_boxView = new QHBoxLayout(this ); |
547 | 547 | ||
548 | m_mimeCheck = new QComboBox(this, "mime check"); | 548 | m_mimeCheck = new QComboBox(this, "mime check"); |
549 | m_viewCheck = new QComboBox(this, "view check"); | 549 | m_viewCheck = new QComboBox(this, "view check"); |
550 | m_boxView->addWidget(m_viewCheck, 0 ); | 550 | m_boxView->addWidget(m_viewCheck, 0 ); |
551 | m_boxView->insertSpacing(1, 8 ); | 551 | m_boxView->insertSpacing(1, 8 ); |
552 | m_boxView->addWidget(m_mimeCheck, 0 ); | 552 | m_boxView->addWidget(m_mimeCheck, 0 ); |
553 | m_lay->addLayout(m_boxView ); | 553 | m_lay->addLayout(m_boxView ); |
554 | 554 | ||
555 | m_viewCheck->insertItem(tr("Documents") ); | 555 | m_viewCheck->insertItem(tr("Documents") ); |
556 | m_viewCheck->insertItem(tr("Files") ); | 556 | m_viewCheck->insertItem(tr("Files") ); |
557 | m_viewCheck->insertItem(tr("All Files") ); | 557 | m_viewCheck->insertItem(tr("All Files") ); |
558 | 558 | ||
559 | if(!m_autoMime ) | 559 | if(!m_autoMime ) |
560 | m_mimeCheck->insertItem(m_mimetypes.join("," ) ); | 560 | m_mimeCheck->insertItem(m_mimetypes.join("," ) ); |
561 | else{ // check | 561 | else{ // check |
562 | updateMimes(); | 562 | updateMimes(); |
563 | m_mimeCheck->insertStringList( m_mimetypes ); | 563 | m_mimeCheck->insertStringList( m_mimetypes ); |
564 | } | 564 | } |
565 | 565 | ||
566 | connect( m_viewCheck, SIGNAL(activated(const QString &) ), | 566 | connect( m_viewCheck, SIGNAL(activated(const QString &) ), |
567 | this, SLOT(slotViewCheck(const QString & ) ) ); | 567 | this, SLOT(slotViewCheck(const QString & ) ) ); |
568 | 568 | ||
569 | connect( m_mimeCheck, SIGNAL(activated(const QString &) ), | 569 | connect( m_mimeCheck, SIGNAL(activated(const QString &) ), |
570 | this, SLOT(slotMimeCheck(const QString & ) ) ); | 570 | this, SLOT(slotMimeCheck(const QString & ) ) ); |
571 | } | 571 | } |
572 | void OFileSelector::slotMimeCheck(const QString &view ){ | 572 | void OFileSelector::slotMimeCheck(const QString &view ){ |
573 | if(m_selector == NORMAL ){ | 573 | if(m_selector == NORMAL ){ |
574 | delete m_select; | 574 | delete m_select; |
575 | m_select = new FileSelector(view == "All" ? QString::null : view | 575 | m_select = new FileSelector(view == "All" ? QString::null : view |
576 | , m_stack, "fileselector", FALSE, FALSE ); | 576 | , m_stack, "fileselector", FALSE, FALSE ); |
577 | m_stack->addWidget( m_select, NORMAL ); | 577 | m_stack->addWidget( m_select, NORMAL ); |
578 | m_stack->raiseWidget( NORMAL ); | 578 | m_stack->raiseWidget( NORMAL ); |
579 | }else{ | 579 | }else{ |
580 | reparse(); | 580 | reparse(); |
581 | } | 581 | } |
582 | } | 582 | } |
583 | 583 | ||
584 | void OFileSelector::slotViewCheck(const QString &view ){ | 584 | void OFileSelector::slotViewCheck(const QString &view ){ |
585 | qWarning("changed: show %s", view.latin1() ); | 585 | qWarning("changed: show %s", view.latin1() ); |
586 | // if the current view is the one | 586 | // if the current view is the one |
587 | QString currMime = m_mimeCheck->currentText(); | 587 | QString currMime = m_mimeCheck->currentText(); |
588 | if( view == QString::fromLatin1("Documents") ){ | 588 | if( view == QString::fromLatin1("Documents") ){ |