author | zcarsten <zcarsten> | 2003-07-22 19:23:13 (UTC) |
---|---|---|
committer | zcarsten <zcarsten> | 2003-07-22 19:23:13 (UTC) |
commit | fa3772aa7ddea5725cc7e7db42d017567e4cc14c (patch) (unidiff) | |
tree | 112ec27dd148d0b381ac559fd3e1ee32a89ecd0d /noncore/apps/zsafe/scqtfileedit.cpp | |
parent | 059af0e82a14a32f068c2ad943dc918afca93587 (diff) | |
download | opie-fa3772aa7ddea5725cc7e7db42d017567e4cc14c.zip opie-fa3772aa7ddea5725cc7e7db42d017567e4cc14c.tar.gz opie-fa3772aa7ddea5725cc7e7db42d017567e4cc14c.tar.bz2 |
Initial revision
Diffstat (limited to 'noncore/apps/zsafe/scqtfileedit.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/zsafe/scqtfileedit.cpp | 756 |
1 files changed, 756 insertions, 0 deletions
diff --git a/noncore/apps/zsafe/scqtfileedit.cpp b/noncore/apps/zsafe/scqtfileedit.cpp new file mode 100644 index 0000000..effd86b --- a/dev/null +++ b/noncore/apps/zsafe/scqtfileedit.cpp | |||
@@ -0,0 +1,756 @@ | |||
1 | /*************************************************************************** | ||
2 | scqtfileedit.cpp - description | ||
3 | ------------------- | ||
4 | begin : Mon Sep 3 2001 | ||
5 | copyright : (C) 2001 by Werner Schulte | ||
6 | email : sc@schulte-ac.de | ||
7 | ***************************************************************************/ | ||
8 | |||
9 | /* $Id$ */ | ||
10 | |||
11 | /*************************************************************************** | ||
12 | * * | ||
13 | * This program is free software; you can redistribute it and/or modify * | ||
14 | * it under the terms of the GNU General Public License as published by * | ||
15 | * the Free Software Foundation; either version 2 of the License, or * | ||
16 | * (at your option) any later version. * | ||
17 | * * | ||
18 | ***************************************************************************/ | ||
19 | #include <stdio.h> | ||
20 | #include <stdlib.h> | ||
21 | |||
22 | #include "qdir.h" | ||
23 | #include "qdialog.h" | ||
24 | #include "qpixmap.h" | ||
25 | #include "qlistview.h" | ||
26 | #include "qlineedit.h" | ||
27 | #include "qtoolbutton.h" | ||
28 | |||
29 | #include "scqtfileedit.h" | ||
30 | |||
31 | // #define DEBUGFILEEDIT | ||
32 | |||
33 | /* XPM */ | ||
34 | static const char* const file_xpm[]={ | ||
35 | "16 16 5 1", | ||
36 | ". c #7f7f7f", | ||
37 | "# c None", | ||
38 | "c c #000000", | ||
39 | "b c #bfbfbf", | ||
40 | "a c #ffffff", | ||
41 | "################", | ||
42 | "..........######", | ||
43 | ".aaaaaaaab.#####", | ||
44 | ".aaaaaaaaba.####", | ||
45 | ".aaaaaaaacccc###", | ||
46 | ".aaaaaaaaaabc###", | ||
47 | ".aaaaaaaaaabc###", | ||
48 | ".aaaaaaaaaabc###", | ||
49 | ".aaaaaaaaaabc###", | ||
50 | ".aaaaaaaaaabc###", | ||
51 | ".aaaaaaaaaabc###", | ||
52 | ".aaaaaaaaaabc###", | ||
53 | ".aaaaaaaaaabc###", | ||
54 | ".aaaaaaaaaabc###", | ||
55 | ".bbbbbbbbbbbc###", | ||
56 | "ccccccccccccc###"}; | ||
57 | |||
58 | /* XPM */ | ||
59 | static const char * const link_file_xpm[]={ | ||
60 | "16 16 10 1", | ||
61 | "h c #808080", | ||
62 | "g c #a0a0a0", | ||
63 | "d c #c3c3c3", | ||
64 | ". c #7f7f7f", | ||
65 | "c c #000000", | ||
66 | "b c #bfbfbf", | ||
67 | "f c #303030", | ||
68 | "e c #585858", | ||
69 | "a c #ffffff", | ||
70 | "# c None", | ||
71 | "################", | ||
72 | "..........######", | ||
73 | ".aaaaaaaab.#####", | ||
74 | ".aaaaaaaaba.####", | ||
75 | ".aaaaaaaacccc###", | ||
76 | ".aaaaaaaaaabc###", | ||
77 | ".aaaaaaaaaabc###", | ||
78 | ".aaaaaaaaaadc###", | ||
79 | ".aaaaaaaaaadc###", | ||
80 | ".aaaacccccccc###", | ||
81 | ".aaaacaaaaaac###", | ||
82 | ".aaaacaeaeaac###", | ||
83 | ".aaaacaefcfac###", | ||
84 | ".aaaacaagchac###", | ||
85 | ".ddddcaaahaac###", | ||
86 | "ccccccccccccc###"}; | ||
87 | |||
88 | /* XPM */ | ||
89 | static const char * const closed_xpm[]={ | ||
90 | "16 16 6 1", | ||
91 | ". c None", | ||
92 | "b c #ffff00", | ||
93 | "d c #000000", | ||
94 | "* c #999999", | ||
95 | "a c #cccccc", | ||
96 | "c c #ffffff", | ||
97 | "................", | ||
98 | "................", | ||
99 | "..*****.........", | ||
100 | ".*ababa*........", | ||
101 | "*abababa******..", | ||
102 | "*cccccccccccc*d.", | ||
103 | "*cbababababab*d.", | ||
104 | "*cabababababa*d.", | ||
105 | "*cbababababab*d.", | ||
106 | "*cabababababa*d.", | ||
107 | "*cbababababab*d.", | ||
108 | "*cabababababa*d.", | ||
109 | "*cbababababab*d.", | ||
110 | "**************d.", | ||
111 | ".dddddddddddddd.", | ||
112 | "................"}; | ||
113 | |||
114 | /* XPM */ | ||
115 | static const char* const cdtoparent_xpm[]={ | ||
116 | "15 13 3 1", | ||
117 | ". c None", | ||
118 | "* c #000000", | ||
119 | "a c #ffff99", | ||
120 | "..*****........", | ||
121 | ".*aaaaa*.......", | ||
122 | "***************", | ||
123 | "*aaaaaaaaaaaaa*", | ||
124 | "*aaaa*aaaaaaaa*", | ||
125 | "*aaa***aaaaaaa*", | ||
126 | "*aa*****aaaaaa*", | ||
127 | "*aaaa*aaaaaaaa*", | ||
128 | "*aaaa*aaaaaaaa*", | ||
129 | "*aaaa******aaa*", | ||
130 | "*aaaaaaaaaaaaa*", | ||
131 | "*aaaaaaaaaaaaa*", | ||
132 | "***************"}; | ||
133 | |||
134 | ScQtFileEditDlg::ScQtFileEditDlg( QWidget *parent, const char *name, | ||
135 | const QString &path, const QString &filter ) | ||
136 | : ScQtFileDlg( parent, name, TRUE ), QDir( path, filter ) | ||
137 | { | ||
138 | // ListView->setRootIsDecorated ( TRUE ); | ||
139 | |||
140 | #ifdef DEBUGFILEEDIT | ||
141 | printf ("\nScQtFileEditDlg:: constructor name=%s", name ); | ||
142 | printf ("\n path=%s", (const char *)path ); | ||
143 | printf ("\n filter=%s", (const char *)filter ); | ||
144 | printf ("\n parent=%p", parent ); | ||
145 | fflush(stdout); | ||
146 | #endif | ||
147 | |||
148 | bpath = path; | ||
149 | bfilter = filter; | ||
150 | exflag = false; | ||
151 | |||
152 | ListView->setAllColumnsShowFocus( TRUE ); | ||
153 | ListView->setColumnAlignment( 1, Qt::AlignRight ); | ||
154 | |||
155 | fileIcon = new QPixmap( (const char **)file_xpm); | ||
156 | dirIcon = new QPixmap( (const char **)closed_xpm); | ||
157 | linkIcon = new QPixmap( (const char **)link_file_xpm); | ||
158 | cdToParentIcon = new QPixmap( (const char **)cdtoparent_xpm); | ||
159 | |||
160 | #ifdef QWS | ||
161 | showMaximized(); | ||
162 | #endif | ||
163 | |||
164 | mkdirflag = false; | ||
165 | MkDirButton->setEnabled( false ); | ||
166 | |||
167 | initDirCombo( bpath ); | ||
168 | initTypeCombo( bfilter ); | ||
169 | |||
170 | dirstr = tr("dir"); | ||
171 | filestr = tr("file"); | ||
172 | linkstr = tr("link"); | ||
173 | |||
174 | rFlag = false; | ||
175 | |||
176 | showTimer.stop(); | ||
177 | connect( &showTimer, SIGNAL(timeout()), SLOT( slotShowDir() ) ); | ||
178 | |||
179 | fmode = QDir::All; | ||
180 | fnfilter = false; | ||
181 | fsorting = false; | ||
182 | |||
183 | } | ||
184 | |||
185 | ScQtFileEditDlg::~ScQtFileEditDlg() | ||
186 | { | ||
187 | #ifdef DEBUGFILEEDIT | ||
188 | printf ("\nScQtFileEditDlg::destructor called" ); | ||
189 | fflush(stdout); | ||
190 | #endif | ||
191 | |||
192 | if ( fileIcon != NULL ) | ||
193 | { | ||
194 | delete fileIcon; | ||
195 | fileIcon = NULL; | ||
196 | } | ||
197 | if ( dirIcon != NULL ) | ||
198 | { | ||
199 | delete dirIcon; | ||
200 | dirIcon = NULL; | ||
201 | } | ||
202 | if ( linkIcon != NULL ) | ||
203 | { | ||
204 | delete linkIcon; | ||
205 | linkIcon = NULL; | ||
206 | } | ||
207 | if ( cdToParentIcon != NULL ) | ||
208 | { | ||
209 | delete cdToParentIcon; | ||
210 | cdToParentIcon = NULL; | ||
211 | } | ||
212 | } | ||
213 | |||
214 | void ScQtFileEditDlg::readIt( ) | ||
215 | { | ||
216 | qfil = readDir( bpath, bfilter ); | ||
217 | slotShowDir( ); | ||
218 | } | ||
219 | |||
220 | void ScQtFileEditDlg::setAutoExtension( bool ex ) | ||
221 | { | ||
222 | exflag = ex; | ||
223 | } | ||
224 | |||
225 | |||
226 | int ScQtFileEditDlg::checkComboEntryExists( QComboBox *com, const QString &str ) | ||
227 | { | ||
228 | int i; | ||
229 | |||
230 | if ( com ) | ||
231 | { | ||
232 | for ( i = 0; i < com->count(); i++ ) | ||
233 | { | ||
234 | if ( com->text( i ) == str ) | ||
235 | { | ||
236 | com->setCurrentItem( i ); | ||
237 | return( 1 ); | ||
238 | } | ||
239 | } | ||
240 | } | ||
241 | |||
242 | return( 0 ); | ||
243 | } | ||
244 | |||
245 | |||
246 | void ScQtFileEditDlg::initDirCombo( const QString &str ) | ||
247 | { | ||
248 | DirComboBox->clear(); | ||
249 | DirComboBox->insertItem( "/" ); | ||
250 | if ( str.isEmpty() ) | ||
251 | return; | ||
252 | DirComboBox->insertItem( str, -1 ); | ||
253 | } | ||
254 | |||
255 | void ScQtFileEditDlg::initTypeCombo( const QString &str ) | ||
256 | { | ||
257 | TypeComboBox->clear(); | ||
258 | TypeComboBox->insertItem( "*" ); | ||
259 | if ( str.isEmpty() ) | ||
260 | return; | ||
261 | TypeComboBox->insertItem( str, -1 ); | ||
262 | } | ||
263 | |||
264 | void ScQtFileEditDlg::insDirCombo( const QString &str ) | ||
265 | { | ||
266 | if ( str.isEmpty() ) | ||
267 | return; | ||
268 | |||
269 | if ( !checkComboEntryExists( DirComboBox, str ) ) | ||
270 | { | ||
271 | if ( DirComboBox->count() >= MAXDIRCOMBOCOUNT ) | ||
272 | { | ||
273 | // 2. Item loeschen (das erste ist "/") | ||
274 | DirComboBox->removeItem( 1 ); | ||
275 | } | ||
276 | // neues Item anhaengen | ||
277 | DirComboBox->insertItem( str, -1 ); | ||
278 | DirComboBox->setCurrentItem( DirComboBox->count() - 1 ); | ||
279 | } | ||
280 | } | ||
281 | |||
282 | void ScQtFileEditDlg::insTypeCombo( const QString &str ) | ||
283 | { | ||
284 | if ( str.isEmpty() ) | ||
285 | return; | ||
286 | |||
287 | if ( !checkComboEntryExists( TypeComboBox, str ) ) | ||
288 | { | ||
289 | if ( TypeComboBox->count() >= MAXTYPECOMBOCOUNT ) | ||
290 | { | ||
291 | // 2. Item loeschen (das erste ist "/") | ||
292 | TypeComboBox->removeItem( 1 ); | ||
293 | } | ||
294 | // neues Item anhaengen | ||
295 | TypeComboBox->insertItem( str, -1 ); | ||
296 | TypeComboBox->setCurrentItem( TypeComboBox->count() - 1 ); | ||
297 | } | ||
298 | } | ||
299 | |||
300 | |||
301 | const QFileInfoList *ScQtFileEditDlg::readDir( const QString &path, const QString &filter ) | ||
302 | { | ||
303 | static QString qpath, qfilter; | ||
304 | |||
305 | #ifdef DEBUGFILEEDIT | ||
306 | printf ("\nScQtFileEditDlg::readDir called, path = %s", (const char *)path ); | ||
307 | printf ("\n filter = %s", (const char *)filter ); | ||
308 | fflush(stdout); | ||
309 | #endif | ||
310 | |||
311 | rFlag = true; | ||
312 | |||
313 | if ( path.isEmpty() ) | ||
314 | qpath = "/"; | ||
315 | else | ||
316 | qpath = path; | ||
317 | |||
318 | if ( filter.isEmpty() ) | ||
319 | qfilter = "*"; | ||
320 | else | ||
321 | qfilter = filter; | ||
322 | |||
323 | insDirCombo( qpath ); | ||
324 | insTypeCombo( qfilter ); | ||
325 | |||
326 | setFilter( fmode ); | ||
327 | if ( fsorting ) | ||
328 | setSorting( QDir::DirsFirst | QDir::Name ); | ||
329 | if ( fnfilter ) | ||
330 | setNameFilter( qfilter ); | ||
331 | setPath( qpath ); | ||
332 | |||
333 | const QFileInfoList *dirlist = entryInfoList(); | ||
334 | |||
335 | if ( !dirlist ) | ||
336 | { | ||
337 | rFlag = false; | ||
338 | return( 0 ); | ||
339 | } | ||
340 | |||
341 | rFlag = false; | ||
342 | |||
343 | return( dirlist ); | ||
344 | } | ||
345 | |||
346 | QString ScQtFileEditDlg::getResult( ) | ||
347 | { | ||
348 | static QString qstr; | ||
349 | |||
350 | #ifdef DEBUGFILEEDIT | ||
351 | printf ("\nScQtFileEditDlg::getResult called" ); | ||
352 | fflush(stdout); | ||
353 | #endif | ||
354 | |||
355 | qstr = bpath + "/"; | ||
356 | qstr = qstr + filename; | ||
357 | bpath = cleanDirPath( qstr ); | ||
358 | |||
359 | return( bpath ); | ||
360 | } | ||
361 | |||
362 | QString ScQtFileEditDlg::getFileName( ) | ||
363 | { | ||
364 | int a; | ||
365 | static QString qstr; | ||
366 | |||
367 | #ifdef DEBUGFILEEDIT | ||
368 | printf ("\nScQtFileEditDlg::getFileName called" ); | ||
369 | fflush(stdout); | ||
370 | #endif | ||
371 | |||
372 | a = bpath.findRev( "/", -1, TRUE ); | ||
373 | if (a == -1) | ||
374 | qstr = bpath; // Nicht gefunden | ||
375 | else | ||
376 | qstr = bpath.right( bpath.length() - a - 1 ); | ||
377 | |||
378 | return( qstr ); | ||
379 | } | ||
380 | |||
381 | // Ab hier die Slots ----------------------------------- | ||
382 | |||
383 | void ScQtFileEditDlg::slotShowDir() | ||
384 | { | ||
385 | static QListViewItem *qlvitem; | ||
386 | static QString ftypestr, fsizestr; | ||
387 | static QFileInfo *fi; // pointer for traversing | ||
388 | |||
389 | if ( !qfil ) // pointer war Null | ||
390 | return; | ||
391 | |||
392 | ListView->clear(); // ersma loeschen | ||
393 | QFileInfoListIterator it( *qfil ); // create list iterator | ||
394 | if ( !it ) // pointer war Null | ||
395 | return; | ||
396 | |||
397 | while ( (fi=it.current()) ) | ||
398 | { // for each file... | ||
399 | if ( !fi ) // current war 0 | ||
400 | return; | ||
401 | |||
402 | if ( !fi->fileName().isNull() ) | ||
403 | { | ||
404 | if ( fi->isDir() == TRUE ) | ||
405 | { | ||
406 | ftypestr = dirstr; | ||
407 | fsizestr = "" ; | ||
408 | } | ||
409 | else if ( fi->isSymLink() == TRUE ) | ||
410 | { | ||
411 | ftypestr = linkstr; | ||
412 | fsizestr = "" ; | ||
413 | } | ||
414 | else if ( fi->isFile() == TRUE ) | ||
415 | { | ||
416 | ftypestr = filestr; | ||
417 | fsizestr.sprintf( "%d", fi->size() ); | ||
418 | } | ||
419 | else | ||
420 | { | ||
421 | printf( "something else\n" ); | ||
422 | fflush(stdout); | ||
423 | } | ||
424 | |||
425 | if ( !(fi->fileName() == "." ) ) // der wird ausgespart | ||
426 | { | ||
427 | qlvitem = new QListViewItem ( ListView, fi->fileName(), fsizestr, ftypestr ); | ||
428 | if ( fi->fileName() == ".." ) | ||
429 | qlvitem->setPixmap( 0, *cdToParentIcon ); | ||
430 | else if ( fi->isDir() == TRUE ) | ||
431 | qlvitem->setPixmap( 0, *dirIcon ); | ||
432 | else if ( fi->isSymLink() == TRUE ) | ||
433 | qlvitem->setPixmap( 0, *linkIcon ); | ||
434 | else if ( fi->isFile() == TRUE ) | ||
435 | qlvitem->setPixmap( 0, *fileIcon ); | ||
436 | } | ||
437 | } | ||
438 | ++it; // goto next list element | ||
439 | } | ||
440 | } | ||
441 | |||
442 | void ScQtFileEditDlg::slotDirComboBoxChanged( int item ) | ||
443 | { | ||
444 | if ( !rFlag ) | ||
445 | { | ||
446 | bpath = DirComboBox->currentText( ); | ||
447 | qfil = readDir( bpath, bfilter ); | ||
448 | slotShowDir( ); | ||
449 | } | ||
450 | } | ||
451 | |||
452 | void ScQtFileEditDlg::slotTypeComboBoxChanged( int item ) | ||
453 | { | ||
454 | if ( !rFlag ) | ||
455 | { | ||
456 | bfilter = TypeComboBox->currentText( ); | ||
457 | qfil = readDir( bpath, bfilter ); | ||
458 | slotShowDir( ); | ||
459 | } | ||
460 | } | ||
461 | |||
462 | void ScQtFileEditDlg::slotFileTextChanged( const QString &txt ) | ||
463 | { | ||
464 | filename = txt; | ||
465 | } | ||
466 | |||
467 | void ScQtFileEditDlg::slotSelectionChanged( QListViewItem *item ) | ||
468 | { | ||
469 | static QString qstr, rstr; | ||
470 | |||
471 | #ifdef DEBUGFILEEDIT | ||
472 | printf ("\nScQtFileEditDlg::slotSelectionChanged called" ); | ||
473 | fflush(stdout); | ||
474 | #endif | ||
475 | if ( item ) | ||
476 | { | ||
477 | if ( !item->text(2) ) | ||
478 | return; | ||
479 | |||
480 | if ( item->text(2) == dirstr ) | ||
481 | { | ||
482 | if ( !rFlag ) | ||
483 | { | ||
484 | rstr = bpath; | ||
485 | qstr = bpath + "/"; | ||
486 | qstr = qstr + item->text(0); | ||
487 | bpath = cleanDirPath( qstr ); | ||
488 | qfil = readDir( bpath, bfilter ); | ||
489 | if ( qfil == 0 ) | ||
490 | { | ||
491 | bpath = rstr; | ||
492 | // Nochmal lesen, um die ComboBoxen zu setzten | ||
493 | qfil = readDir( bpath, bfilter ); | ||
494 | } | ||
495 | showTimer.start( 10, true ); | ||
496 | } | ||
497 | } | ||
498 | else if ( item->text(2) == filestr ) | ||
499 | { | ||
500 | FNameLineEdit->setText( item->text(0) ); | ||
501 | filename = item->text(0); | ||
502 | } | ||
503 | } | ||
504 | } | ||
505 | |||
506 | |||
507 | void ScQtFileEditDlg::slotMkDir( ) | ||
508 | { | ||
509 | QString qstr; | ||
510 | |||
511 | if ( !FNameLineEdit->text().isEmpty() ) | ||
512 | { | ||
513 | qstr = bpath + "/"; | ||
514 | qstr = qstr + FNameLineEdit->text(); | ||
515 | mkdir( qstr, true ); | ||
516 | qfil = readDir( bpath, bfilter ); | ||
517 | FNameLineEdit->setText( "" ); | ||
518 | slotShowDir( ); | ||
519 | } | ||
520 | } | ||
521 | |||
522 | void ScQtFileEditDlg::slotDoubleClicked( QListViewItem *item ) | ||
523 | { | ||
524 | static QString qstr, rstr; | ||
525 | |||
526 | #ifdef DEBUGFILEEDIT | ||
527 | printf ("\nScQtFileEditDlg::slotDoubleClicked called" ); | ||
528 | fflush(stdout); | ||
529 | #endif | ||
530 | |||
531 | if ( item ) | ||
532 | { | ||
533 | if ( item->text(2) == dirstr ) | ||
534 | { | ||
535 | if ( !rFlag ) | ||
536 | { | ||
537 | rstr = bpath; | ||
538 | qstr = bpath + "/"; | ||
539 | qstr = qstr + item->text(0); | ||
540 | bpath = cleanDirPath( qstr ); | ||
541 | qfil = readDir( bpath, bfilter ); | ||
542 | if ( qfil == 0 ) | ||
543 | { | ||
544 | bpath = rstr; | ||
545 | // Nochmal lesen, um die ComboBoxen zu setzten | ||
546 | qfil = readDir( bpath, bfilter ); | ||
547 | } | ||
548 | showTimer.start( 10, TRUE ); | ||
549 | } | ||
550 | } | ||
551 | } | ||
552 | } | ||
553 | |||
554 | void ScQtFileEditDlg::autoExtension( ) | ||
555 | { | ||
556 | QString qstr; | ||
557 | int len; | ||
558 | |||
559 | if ( exflag ) | ||
560 | { | ||
561 | qstr = TypeComboBox->currentText( ); | ||
562 | if ( qstr != "*" ) | ||
563 | { | ||
564 | len = qstr.findRev( ".", -1 ); | ||
565 | if ( len >= 0 ) | ||
566 | { | ||
567 | qstr = qstr.right( qstr.length() - len ); | ||
568 | len = filename.findRev( qstr, -1 ); | ||
569 | if ( len < 0 ) | ||
570 | filename = filename + qstr; | ||
571 | } | ||
572 | } | ||
573 | } | ||
574 | } | ||
575 | |||
576 | void ScQtFileEditDlg::setMode( int mode ) | ||
577 | { | ||
578 | fmode = mode; | ||
579 | } | ||
580 | |||
581 | void ScQtFileEditDlg::setNFilter( bool ff ) | ||
582 | { | ||
583 | fnfilter = ff; | ||
584 | } | ||
585 | |||
586 | void ScQtFileEditDlg::setFSorting( bool ff ) | ||
587 | { | ||
588 | fsorting = ff; | ||
589 | } | ||
590 | |||
591 | void ScQtFileEditDlg::allowMkDir( bool mkdir ) | ||
592 | { | ||
593 | mkdirflag = mkdir; | ||
594 | MkDirButton->setEnabled( mkdir ); | ||
595 | } | ||
596 | |||
597 | |||
598 | void ScQtFileEditDlg::slotOK( ) | ||
599 | { | ||
600 | #ifdef DEBUGFILEEDIT | ||
601 | printf ("\nScQtFileEditDlg::slotOK called" ); | ||
602 | fflush(stdout); | ||
603 | #endif | ||
604 | autoExtension(); | ||
605 | |||
606 | accept(); | ||
607 | } | ||
608 | |||
609 | void ScQtFileEditDlg::slotCancel( ) | ||
610 | { | ||
611 | |||
612 | #ifdef DEBUGFILEEDIT | ||
613 | printf ("\nScQtFileEditDlg::slotCancel called" ); | ||
614 | fflush(stdout); | ||
615 | #endif | ||
616 | |||
617 | reject(); | ||
618 | } | ||
619 | |||
620 | |||
621 | /************************************************************************** | ||
622 | ***************************************************************************/ | ||
623 | ScQtFileEdit::ScQtFileEdit( QWidget *parent, const char *name ) | ||
624 | { | ||
625 | #ifdef DEBUGFILEEDIT | ||
626 | printf ("\nScQtFileEdit constructor called"); | ||
627 | fflush(stdout); | ||
628 | #endif | ||
629 | } | ||
630 | |||
631 | ScQtFileEdit::~ScQtFileEdit() | ||
632 | { | ||
633 | #ifdef DEBUGFILEEDIT | ||
634 | printf ("\nScQtFileEdit destructor called"); | ||
635 | fflush(stdout); | ||
636 | #endif | ||
637 | } | ||
638 | |||
639 | QString ScQtFileEdit::getOpenFileName( QWidget *parent, const char *name, | ||
640 | const QString &path, const QString &filter ) | ||
641 | { | ||
642 | static ScQtFileEditDlg *fd; | ||
643 | static QString fname; | ||
644 | |||
645 | #ifdef DEBUGFILEEDIT | ||
646 | printf ("\nScQtFileEdit::getOpenFileName name=%s", name ); | ||
647 | printf ("\n path=%s", (const char *)path ); | ||
648 | printf ("\n filter=%s", (const char *)filter ); | ||
649 | fflush(stdout); | ||
650 | #endif | ||
651 | |||
652 | fd = new ScQtFileEditDlg( parent, name, path, filter ); | ||
653 | fd->setAutoExtension( false ); | ||
654 | fd->setMode( QDir::All|QDir::System ); | ||
655 | fd->setNFilter( true ); | ||
656 | fd->setFSorting( true ); | ||
657 | fd->readIt(); | ||
658 | fd->exec(); | ||
659 | |||
660 | if ( fd->result() == QDialog::Accepted ) | ||
661 | fname = fd->getResult(); | ||
662 | else | ||
663 | fname = ""; | ||
664 | |||
665 | delete fd; | ||
666 | return( fname ); | ||
667 | } | ||
668 | |||
669 | QString ScQtFileEdit::getSaveAsFileName( QWidget *parent, const char *name, | ||
670 | const QString &path, const QString &filter ) | ||
671 | { | ||
672 | static ScQtFileEditDlg *fd; | ||
673 | static QString fname; | ||
674 | |||
675 | #ifdef DEBUGFILEEDIT | ||
676 | printf ("\nScQtFileEdit::getSaveAsFileName name=%s", name ); | ||
677 | printf ("\n path=%s", (const char *)path ); | ||
678 | printf ("\n filter=%s", (const char *)filter ); | ||
679 | fflush(stdout); | ||
680 | #endif | ||
681 | |||
682 | fd = new ScQtFileEditDlg( parent, name, path, filter ); | ||
683 | fd->allowMkDir( true ); // CS: | ||
684 | fd->setAutoExtension( true ); | ||
685 | fd->setNFilter( true ); | ||
686 | fd->setFSorting( true ); | ||
687 | fd->readIt(); | ||
688 | fd->exec(); | ||
689 | |||
690 | if ( fd->result() == QDialog::Accepted ) | ||
691 | fname = fd->getResult(); | ||
692 | else | ||
693 | fname = ""; | ||
694 | |||
695 | delete fd; | ||
696 | return( fname ); | ||
697 | } | ||
698 | |||
699 | QString ScQtFileEdit::getDirName( QWidget *parent, const char *name, | ||
700 | const QString &path ) | ||
701 | { | ||
702 | static ScQtFileEditDlg *fd; | ||
703 | static QString fname; | ||
704 | |||
705 | #ifdef DEBUGFILEEDIT | ||
706 | printf ("\nScQtFileEdit::getDirName name=%s", name ); | ||
707 | printf ("\n path=%s", (const char *)path ); | ||
708 | fflush(stdout); | ||
709 | #endif | ||
710 | |||
711 | fd = new ScQtFileEditDlg( parent, name, path ); | ||
712 | fd->setMode( QDir::Dirs ); | ||
713 | fd->setNFilter( false ); | ||
714 | fd->setFSorting( true ); | ||
715 | fd->readIt(); | ||
716 | fd->exec(); | ||
717 | |||
718 | if ( fd->result() == QDialog::Accepted ) | ||
719 | fname = fd->getResult(); | ||
720 | else | ||
721 | fname = ""; | ||
722 | |||
723 | delete fd; | ||
724 | return( fname ); | ||
725 | } | ||
726 | |||
727 | QString ScQtFileEdit::mkDir( QWidget *parent, const char *name, | ||
728 | const QString &path, const QString &filter ) | ||
729 | { | ||
730 | static ScQtFileEditDlg *fd; | ||
731 | static QString fname; | ||
732 | |||
733 | #ifdef DEBUGFILEEDIT | ||
734 | printf ("\nScQtFileEdit::mkDir name=%s", name ); | ||
735 | printf ("\n basepath=%s", (const char *)path ); | ||
736 | printf ("\n filter=%s", (const char *)filter ); | ||
737 | fflush(stdout); | ||
738 | #endif | ||
739 | |||
740 | fd = new ScQtFileEditDlg( parent, name, path, filter ); | ||
741 | fd->setAutoExtension( true ); | ||
742 | fd->allowMkDir( true ); | ||
743 | fd->setNFilter( false ); | ||
744 | fd->setFSorting( true ); | ||
745 | fd->readIt(); | ||
746 | fd->exec(); | ||
747 | |||
748 | if ( fd->result() == QDialog::Accepted ) | ||
749 | fname = fd->getResult(); | ||
750 | else | ||
751 | fname = ""; | ||
752 | |||
753 | delete fd; | ||
754 | return( fname ); | ||
755 | } | ||
756 | |||