-rw-r--r-- | libopie/ofiledialog.h | 4 | ||||
-rw-r--r-- | libopie/ofileselector.cpp | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/libopie/ofiledialog.h b/libopie/ofiledialog.h index 91e0586..3b905c0 100644 --- a/libopie/ofiledialog.h +++ b/libopie/ofiledialog.h | |||
@@ -1,101 +1,101 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 zecke <zecke@handhelds.org> | 3 | .=l. Copyright (c) 2002 zecke <zecke@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | 29 | ||
30 | #ifndef OpieFileDialog_h | 30 | #ifndef OpieFileDialog_h |
31 | #define OpieFileDialog_h | 31 | #define OpieFileDialog_h |
32 | 32 | ||
33 | #include <qdialog.h> | 33 | #include <qdialog.h> |
34 | 34 | ||
35 | #include <opie/ofileselector.h> | 35 | #include <opie/ofileselector.h> |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * This class places a OFileSelector inside a QDialog. | 38 | * This class places a OFileSelector inside a QDialog. |
39 | * It provides static method for letting a user chose | 39 | * It provides static method for letting a user chose |
40 | * a file for either opening or saving. | 40 | * a file for either opening or saving. |
41 | * Most of the time the c'tor will not be used instead using | 41 | * Most of the time the c'tor will not be used instead using |
42 | * the static member functions is prefered. | 42 | * the static member functions is prefered. |
43 | * | 43 | * |
44 | * <pre> | 44 | * <pre> |
45 | * QMap<QString, QStringList> mimeTypes; | 45 | * QMap<QString, QStringList> mimeTypes; |
46 | * QStringList types; | 46 | * QStringList types; |
47 | * types << "text[slash]* "; | 47 | * types << "text@slash* "; |
48 | * mimeTypes.insert( tr("Text"), types ); | 48 | * mimeTypes.insert( tr("Text"), types ); |
49 | * mimeTypes.insert( tr("All"), " * / * " ); // remove the spaces in the 2nd comment | 49 | * mimeTypes.insert( tr("All"), " *@slash* " ); // remove the spaces in the 2nd comment |
50 | * QString fileName= OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, | 50 | * QString fileName= OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, |
51 | * "foo","bar", mimeTypes); | 51 | * "foo","bar", mimeTypes); |
52 | * </pre> | 52 | * </pre> |
53 | * | 53 | * |
54 | * @short A small QDialog swalloing a FileSelector | 54 | * @short A small QDialog swalloing a FileSelector |
55 | * @see QDialog | 55 | * @see QDialog |
56 | * @see OFileSelector | 56 | * @see OFileSelector |
57 | * @version 0.1-unfinished | 57 | * @version 0.1-unfinished |
58 | * @author Holger Freyther ( zecke@handhelds.org ) | 58 | * @author Holger Freyther ( zecke@handhelds.org ) |
59 | */ | 59 | */ |
60 | class OFileDialog : public QDialog { | 60 | class OFileDialog : public QDialog { |
61 | Q_OBJECT | 61 | Q_OBJECT |
62 | public: | 62 | public: |
63 | OFileDialog(const QString &caption, | 63 | OFileDialog(const QString &caption, |
64 | QWidget *, int mode, int selector, | 64 | QWidget *, int mode, int selector, |
65 | const QString &dirName, | 65 | const QString &dirName, |
66 | const QString &fileName = QString::null, | 66 | const QString &fileName = QString::null, |
67 | const MimeTypes &mimetypes = MimeTypes() ); | 67 | const MimeTypes &mimetypes = MimeTypes() ); |
68 | QString mimetype() const; | 68 | QString mimetype() const; |
69 | QString fileName() const; | 69 | QString fileName() const; |
70 | DocLnk selectedDocument()const; | 70 | DocLnk selectedDocument()const; |
71 | 71 | ||
72 | // static methods | 72 | // static methods |
73 | static QString getOpenFileName(int selector, | 73 | static QString getOpenFileName(int selector, |
74 | const QString& startDir = QString::null, | 74 | const QString& startDir = QString::null, |
75 | const QString &fileName = QString::null, | 75 | const QString &fileName = QString::null, |
76 | const MimeTypes& mime = MimeTypes(), | 76 | const MimeTypes& mime = MimeTypes(), |
77 | QWidget *wid = 0, | 77 | QWidget *wid = 0, |
78 | const QString &caption = QString::null ); | 78 | const QString &caption = QString::null ); |
79 | 79 | ||
80 | static QString getSaveFileName(int selector, | 80 | static QString getSaveFileName(int selector, |
81 | const QString& startDir = QString::null, | 81 | const QString& startDir = QString::null, |
82 | const QString& fileName = QString::null, | 82 | const QString& fileName = QString::null, |
83 | const MimeTypes& mimefilter = MimeTypes(), | 83 | const MimeTypes& mimefilter = MimeTypes(), |
84 | QWidget *wid = 0, | 84 | QWidget *wid = 0, |
85 | const QString &caption = QString::null ); | 85 | const QString &caption = QString::null ); |
86 | 86 | ||
87 | //let's OFileSelector catch up first | 87 | //let's OFileSelector catch up first |
88 | //static QString getExistingDirectory(const QString& startDir = QString::null, | 88 | //static QString getExistingDirectory(const QString& startDir = QString::null, |
89 | // QWidget *parent = 0, | 89 | // QWidget *parent = 0, |
90 | // const QString& caption = QString::null ); | 90 | // const QString& caption = QString::null ); |
91 | private: | 91 | private: |
92 | class OFileDialogPrivate; | 92 | class OFileDialogPrivate; |
93 | OFileDialogPrivate *d; | 93 | OFileDialogPrivate *d; |
94 | OFileSelector *file; | 94 | OFileSelector *file; |
95 | 95 | ||
96 | private slots: | 96 | private slots: |
97 | void slotFileSelected( const QString & ); | 97 | void slotFileSelected( const QString & ); |
98 | void slotDirSelected(const QString & ); | 98 | void slotDirSelected(const QString & ); |
99 | void slotSelectorOk(); | 99 | void slotSelectorOk(); |
100 | }; | 100 | }; |
101 | #endif | 101 | #endif |
diff --git a/libopie/ofileselector.cpp b/libopie/ofileselector.cpp index 9afe9c7..9ac2981 100644 --- a/libopie/ofileselector.cpp +++ b/libopie/ofileselector.cpp | |||
@@ -545,196 +545,196 @@ void OFileViewFileListView::slotFSActivated( int id ) { | |||
545 | bool OFileViewFileListView::compliesMime( const QString& str) { | 545 | bool OFileViewFileListView::compliesMime( const QString& str) { |
546 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) | 546 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) |
547 | return true; | 547 | return true; |
548 | 548 | ||
549 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) { | 549 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) { |
550 | QRegExp reg( (*it) ); | 550 | QRegExp reg( (*it) ); |
551 | reg.setWildcard( true ); | 551 | reg.setWildcard( true ); |
552 | if ( str.find( reg ) != -1 ) | 552 | if ( str.find( reg ) != -1 ) |
553 | return true; | 553 | return true; |
554 | 554 | ||
555 | } | 555 | } |
556 | return false; | 556 | return false; |
557 | } | 557 | } |
558 | /* | 558 | /* |
559 | * The listView giving access to the file system! | 559 | * The listView giving access to the file system! |
560 | */ | 560 | */ |
561 | class OFileViewFileSystem : public OFileViewInterface { | 561 | class OFileViewFileSystem : public OFileViewInterface { |
562 | public: | 562 | public: |
563 | OFileViewFileSystem( OFileSelector* ); | 563 | OFileViewFileSystem( OFileSelector* ); |
564 | ~OFileViewFileSystem(); | 564 | ~OFileViewFileSystem(); |
565 | 565 | ||
566 | QString selectedName() const; | 566 | QString selectedName() const; |
567 | QString selectedPath() const; | 567 | QString selectedPath() const; |
568 | 568 | ||
569 | QString directory()const; | 569 | QString directory()const; |
570 | void reread(); | 570 | void reread(); |
571 | int fileCount()const; | 571 | int fileCount()const; |
572 | 572 | ||
573 | QWidget* widget( QWidget* parent ); | 573 | QWidget* widget( QWidget* parent ); |
574 | void activate( const QString& ); | 574 | void activate( const QString& ); |
575 | private: | 575 | private: |
576 | OFileViewFileListView* m_view; | 576 | OFileViewFileListView* m_view; |
577 | bool m_all : 1; | 577 | bool m_all : 1; |
578 | }; | 578 | }; |
579 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) | 579 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) |
580 | : OFileViewInterface( sel ) { | 580 | : OFileViewInterface( sel ) { |
581 | m_view = 0; | 581 | m_view = 0; |
582 | m_all = false; | 582 | m_all = false; |
583 | } | 583 | } |
584 | OFileViewFileSystem::~OFileViewFileSystem() { | 584 | OFileViewFileSystem::~OFileViewFileSystem() { |
585 | } | 585 | } |
586 | QString OFileViewFileSystem::selectedName()const{ | 586 | QString OFileViewFileSystem::selectedName()const{ |
587 | if (!m_view ) | 587 | if (!m_view ) |
588 | return QString::null; | 588 | return QString::null; |
589 | 589 | ||
590 | QString cFN=currentFileName(); | 590 | QString cFN=currentFileName(); |
591 | if (cFN.startsWith("/")) return cFN; | 591 | if (cFN.startsWith("/")) return cFN; |
592 | return m_view->currentDir() + "/" + cFN; | 592 | return m_view->currentDir() + "/" + cFN; |
593 | } | 593 | } |
594 | QString OFileViewFileSystem::selectedPath()const{ | 594 | QString OFileViewFileSystem::selectedPath()const{ |
595 | return QString::null; | 595 | return QString::null; |
596 | } | 596 | } |
597 | QString OFileViewFileSystem::directory()const{ | 597 | QString OFileViewFileSystem::directory()const{ |
598 | if (!m_view) | 598 | if (!m_view) |
599 | return QString::null; | 599 | return QString::null; |
600 | 600 | ||
601 | OFileSelectorItem* item = m_view->currentItem(); | 601 | OFileSelectorItem* item = m_view->currentItem(); |
602 | if (!item ) | 602 | if (!item ) |
603 | return QString::null; | 603 | return QString::null; |
604 | 604 | ||
605 | return QDir(item->directory() ).absPath(); | 605 | return QDir(item->directory() ).absPath(); |
606 | } | 606 | } |
607 | void OFileViewFileSystem::reread() { | 607 | void OFileViewFileSystem::reread() { |
608 | if (!m_view) | 608 | if (!m_view) |
609 | return; | 609 | return; |
610 | 610 | ||
611 | m_view->reread( m_all ); | 611 | m_view->reread( m_all ); |
612 | } | 612 | } |
613 | int OFileViewFileSystem::fileCount()const{ | 613 | int OFileViewFileSystem::fileCount()const{ |
614 | if (!m_view ) | 614 | if (!m_view ) |
615 | return -1; | 615 | return -1; |
616 | return m_view->fileCount(); | 616 | return m_view->fileCount(); |
617 | } | 617 | } |
618 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) { | 618 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) { |
619 | if (!m_view ) { | 619 | if (!m_view ) { |
620 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); | 620 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); |
621 | } | 621 | } |
622 | return m_view; | 622 | return m_view; |
623 | } | 623 | } |
624 | void OFileViewFileSystem::activate( const QString& str) { | 624 | void OFileViewFileSystem::activate( const QString& str) { |
625 | m_all = (str != QObject::tr("Files") ); | 625 | m_all = (str != QObject::tr("Files") ); |
626 | 626 | ||
627 | 627 | ||
628 | } | 628 | } |
629 | 629 | ||
630 | /* Selector */ | 630 | /* Selector */ |
631 | /** | 631 | /** |
632 | * @short new and complete c'tor | 632 | * @short new and complete c'tor |
633 | * | 633 | * |
634 | * Create a OFileSelector to let the user select a file. It can | 634 | * Create a OFileSelector to let the user select a file. It can |
635 | * either be used to open a file, select a save name in a dir or | 635 | * either be used to open a file, select a save name in a dir or |
636 | * as a dropin for the FileSelector. | 636 | * as a dropin for the FileSelector. |
637 | * | 637 | * |
638 | * <pre> | 638 | * <pre> |
639 | * QMap<QString, QStringList> mimeTypes; | 639 | * QMap<QString, QStringList> mimeTypes; |
640 | * QStringList types; | 640 | * QStringList types; |
641 | * types << "text[slash]* "; | 641 | * types << "text@slash* "; |
642 | * types << "audio[slash]*"; | 642 | * types << "audio@slash*"; |
643 | * mimeTypes.insert( tr("Audio and Text"), types ); | 643 | * mimeTypes.insert( tr("Audio and Text"), types ); |
644 | * mimeTypes.insert( tr("All"), "*[slash]*); | 644 | * mimeTypes.insert( tr("All"), "*@slash*); |
645 | * | 645 | * |
646 | * now you could create your fileselector | 646 | * now you could create your fileselector |
647 | * </pre> | 647 | * </pre> |
648 | * | 648 | * |
649 | * | 649 | * |
650 | * @param parent the parent of this widget | 650 | * @param parent the parent of this widget |
651 | * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) | 651 | * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) |
652 | * @param sel The selector to be used | 652 | * @param sel The selector to be used |
653 | * @param dirName The name of the dir to start int | 653 | * @param dirName The name of the dir to start int |
654 | * @param fileName The fileName placed in the fileselector lineedit | 654 | * @param fileName The fileName placed in the fileselector lineedit |
655 | * @param mimetypes The MimeType map of used mimetypes | 655 | * @param mimetypes The MimeType map of used mimetypes |
656 | * @param showNew Show a New Button. Most likely to be used in the FileSelector view. | 656 | * @param showNew Show a New Button. Most likely to be used in the FileSelector view. |
657 | * @param showClose Show a Close Button. Most likely to be used in FileSelector view. | 657 | * @param showClose Show a Close Button. Most likely to be used in FileSelector view. |
658 | * | 658 | * |
659 | */ | 659 | */ |
660 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, | 660 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, |
661 | const QString& dirName, const QString& fileName, | 661 | const QString& dirName, const QString& fileName, |
662 | const MimeTypes& mimetypes, | 662 | const MimeTypes& mimetypes, |
663 | bool showNew, bool showClose) | 663 | bool showNew, bool showClose) |
664 | : QWidget( parent, "OFileSelector" ) | 664 | : QWidget( parent, "OFileSelector" ) |
665 | { | 665 | { |
666 | m_current = 0; | 666 | m_current = 0; |
667 | m_shNew = showNew; | 667 | m_shNew = showNew; |
668 | m_shClose = showClose; | 668 | m_shClose = showClose; |
669 | m_mimeType = mimetypes; | 669 | m_mimeType = mimetypes; |
670 | m_startDir = dirName; | 670 | m_startDir = dirName; |
671 | 671 | ||
672 | m_mode = mode; | 672 | m_mode = mode; |
673 | m_selector = sel; | 673 | m_selector = sel; |
674 | 674 | ||
675 | initUI(); | 675 | initUI(); |
676 | m_lneEdit->setText( fileName ); | 676 | m_lneEdit->setText( fileName ); |
677 | initMime(); | 677 | initMime(); |
678 | initViews(); | 678 | initViews(); |
679 | 679 | ||
680 | QString str; | 680 | QString str; |
681 | switch ( m_selector ) { | 681 | switch ( m_selector ) { |
682 | default: | 682 | default: |
683 | case Normal: | 683 | case Normal: |
684 | str = QObject::tr("Documents"); | 684 | str = QObject::tr("Documents"); |
685 | m_cmbView->setCurrentItem( 0 ); | 685 | m_cmbView->setCurrentItem( 0 ); |
686 | break; | 686 | break; |
687 | case Extended: | 687 | case Extended: |
688 | str = QObject::tr("Files"); | 688 | str = QObject::tr("Files"); |
689 | m_cmbView->setCurrentItem( 1 ); | 689 | m_cmbView->setCurrentItem( 1 ); |
690 | break; | 690 | break; |
691 | case ExtendedAll: | 691 | case ExtendedAll: |
692 | str = QObject::tr("All Files"); | 692 | str = QObject::tr("All Files"); |
693 | m_cmbView->setCurrentItem( 2 ); | 693 | m_cmbView->setCurrentItem( 2 ); |
694 | break; | 694 | break; |
695 | } | 695 | } |
696 | slotViewChange( str ); | 696 | slotViewChange( str ); |
697 | 697 | ||
698 | } | 698 | } |
699 | 699 | ||
700 | /** | 700 | /** |
701 | * This a convience c'tor to just substitute the use of FileSelector | 701 | * This a convience c'tor to just substitute the use of FileSelector |
702 | */ | 702 | */ |
703 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, | 703 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, |
704 | bool showNew, bool showClose ) | 704 | bool showNew, bool showClose ) |
705 | : QWidget( parent, name ) | 705 | : QWidget( parent, name ) |
706 | { | 706 | { |
707 | m_current = 0; | 707 | m_current = 0; |
708 | m_shNew = showNew; | 708 | m_shNew = showNew; |
709 | m_shClose = showClose; | 709 | m_shClose = showClose; |
710 | m_startDir = QPEApplication::documentDir(); | 710 | m_startDir = QPEApplication::documentDir(); |
711 | 711 | ||
712 | if (!mimeFilter.isEmpty() ) | 712 | if (!mimeFilter.isEmpty() ) |
713 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); | 713 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); |
714 | 714 | ||
715 | m_mode = OFileSelector::FileSelector; | 715 | m_mode = OFileSelector::FileSelector; |
716 | m_selector = OFileSelector::Normal; | 716 | m_selector = OFileSelector::Normal; |
717 | 717 | ||
718 | initUI(); | 718 | initUI(); |
719 | initMime(); | 719 | initMime(); |
720 | initViews(); | 720 | initViews(); |
721 | m_cmbView->setCurrentItem( 0 ); | 721 | m_cmbView->setCurrentItem( 0 ); |
722 | slotViewChange( QObject::tr("Documents") ); | 722 | slotViewChange( QObject::tr("Documents") ); |
723 | } | 723 | } |
724 | /* | 724 | /* |
725 | * INIT UI will set up the basic GUI | 725 | * INIT UI will set up the basic GUI |
726 | * Layout: Simple VBoxLayout | 726 | * Layout: Simple VBoxLayout |
727 | * On top a WidgetStack containing the Views... | 727 | * On top a WidgetStack containing the Views... |
728 | * - List View | 728 | * - List View |
729 | * - Document View | 729 | * - Document View |
730 | * Below we will have a Label + LineEdit | 730 | * Below we will have a Label + LineEdit |
731 | * Below we will have two ComoBoxes one for choosing the view one for | 731 | * Below we will have two ComoBoxes one for choosing the view one for |
732 | * choosing the mimetype | 732 | * choosing the mimetype |
733 | */ | 733 | */ |
734 | void OFileSelector::initUI() { | 734 | void OFileSelector::initUI() { |
735 | QVBoxLayout* lay = new QVBoxLayout( this ); | 735 | QVBoxLayout* lay = new QVBoxLayout( this ); |
736 | 736 | ||
737 | m_stack = new QWidgetStack( this ); | 737 | m_stack = new QWidgetStack( this ); |
738 | lay->addWidget( m_stack, 1000 ); | 738 | lay->addWidget( m_stack, 1000 ); |
739 | 739 | ||
740 | m_nameBox = new QHBox( this ); | 740 | m_nameBox = new QHBox( this ); |