Diffstat (limited to 'libopie2/opieui/fileselector/ofileselector.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp index 15cadd4..c4d5033 100644 --- a/libopie2/opieui/fileselector/ofileselector.cpp +++ b/libopie2/opieui/fileselector/ofileselector.cpp | |||
@@ -10,98 +10,101 @@ | |||
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 | /* hacky but we need to get FileSelector::filter */ | 29 | /* hacky but we need to get FileSelector::filter */ |
30 | #define private public | 30 | #define private public |
31 | #include <qpe/fileselector.h> | 31 | #include <qpe/fileselector.h> |
32 | #undef private | 32 | #undef private |
33 | 33 | ||
34 | #include "ofileselector_p.h" | 34 | #include "ofileselector_p.h" |
35 | 35 | ||
36 | /* OPIE */ | 36 | /* OPIE */ |
37 | #include <opie2/ofileselector.h> | 37 | #include <opie2/ofileselector.h> |
38 | 38 | ||
39 | #include <qpe/qpeapplication.h> | 39 | #include <qpe/qpeapplication.h> |
40 | #include <qpe/mimetype.h> | 40 | #include <qpe/mimetype.h> |
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | #include <qpe/storage.h> | 42 | #include <qpe/storage.h> |
43 | 43 | ||
44 | /* QT */ | 44 | /* QT */ |
45 | #include <qcombobox.h> | 45 | #include <qcombobox.h> |
46 | #include <qdir.h> | 46 | #include <qdir.h> |
47 | #include <qhbox.h> | 47 | #include <qhbox.h> |
48 | #include <qheader.h> | 48 | #include <qheader.h> |
49 | #include <qlabel.h> | 49 | #include <qlabel.h> |
50 | #include <qlayout.h> | 50 | #include <qlayout.h> |
51 | #include <qlineedit.h> | 51 | #include <qlineedit.h> |
52 | #include <qlistview.h> | 52 | #include <qlistview.h> |
53 | #include <qpopupmenu.h> | 53 | #include <qpopupmenu.h> |
54 | #include <qwidgetstack.h> | 54 | #include <qwidgetstack.h> |
55 | #include <qregexp.h> | 55 | #include <qregexp.h> |
56 | #include <qobjectlist.h> | 56 | #include <qobjectlist.h> |
57 | 57 | ||
58 | using namespace Opie; | 58 | using namespace Opie::Ui::Private; |
59 | 59 | ||
60 | namespace Opie { | ||
61 | namespace Ui { | ||
62 | namespace Private { | ||
60 | OFileViewInterface::OFileViewInterface( OFileSelector* selector ) | 63 | OFileViewInterface::OFileViewInterface( OFileSelector* selector ) |
61 | : m_selector( selector ) | 64 | : m_selector( selector ) |
62 | {} | 65 | {} |
63 | 66 | ||
64 | OFileViewInterface::~OFileViewInterface() | 67 | OFileViewInterface::~OFileViewInterface() |
65 | {} | 68 | {} |
66 | 69 | ||
67 | QString OFileViewInterface::name()const | 70 | QString OFileViewInterface::name()const |
68 | { | 71 | { |
69 | return m_name; | 72 | return m_name; |
70 | } | 73 | } |
71 | 74 | ||
72 | void OFileViewInterface::setName( const QString& name ) | 75 | void OFileViewInterface::setName( const QString& name ) |
73 | { | 76 | { |
74 | m_name = name; | 77 | m_name = name; |
75 | } | 78 | } |
76 | 79 | ||
77 | OFileSelector* OFileViewInterface::selector()const | 80 | OFileSelector* OFileViewInterface::selector()const |
78 | { | 81 | { |
79 | return m_selector; | 82 | return m_selector; |
80 | } | 83 | } |
81 | 84 | ||
82 | DocLnk OFileViewInterface::selectedDocument()const | 85 | DocLnk OFileViewInterface::selectedDocument()const |
83 | { | 86 | { |
84 | return DocLnk( selectedName() ); | 87 | return DocLnk( selectedName() ); |
85 | } | 88 | } |
86 | 89 | ||
87 | bool OFileViewInterface::showNew()const | 90 | bool OFileViewInterface::showNew()const |
88 | { | 91 | { |
89 | return selector()->showNew(); | 92 | return selector()->showNew(); |
90 | } | 93 | } |
91 | 94 | ||
92 | bool OFileViewInterface::showClose()const | 95 | bool OFileViewInterface::showClose()const |
93 | { | 96 | { |
94 | return selector()->showClose(); | 97 | return selector()->showClose(); |
95 | } | 98 | } |
96 | 99 | ||
97 | MimeTypes OFileViewInterface::mimeTypes()const | 100 | MimeTypes OFileViewInterface::mimeTypes()const |
98 | { | 101 | { |
99 | return selector()->mimeTypes(); | 102 | return selector()->mimeTypes(); |
100 | } | 103 | } |
101 | 104 | ||
102 | QStringList OFileViewInterface::currentMimeType()const | 105 | QStringList OFileViewInterface::currentMimeType()const |
103 | { | 106 | { |
104 | return selector()->currentMimeType(); | 107 | return selector()->currentMimeType(); |
105 | } | 108 | } |
106 | 109 | ||
107 | void OFileViewInterface::activate( const QString& ) | 110 | void OFileViewInterface::activate( const QString& ) |
@@ -765,96 +768,98 @@ QString OFileViewFileSystem::selectedName()const | |||
765 | } | 768 | } |
766 | 769 | ||
767 | QString OFileViewFileSystem::selectedPath()const | 770 | QString OFileViewFileSystem::selectedPath()const |
768 | { | 771 | { |
769 | return QString::null; | 772 | return QString::null; |
770 | } | 773 | } |
771 | 774 | ||
772 | QString OFileViewFileSystem::directory()const | 775 | QString OFileViewFileSystem::directory()const |
773 | { | 776 | { |
774 | if (!m_view) | 777 | if (!m_view) |
775 | return QString::null; | 778 | return QString::null; |
776 | 779 | ||
777 | OFileSelectorItem* item = m_view->currentItem(); | 780 | OFileSelectorItem* item = m_view->currentItem(); |
778 | if (!item ) | 781 | if (!item ) |
779 | return QString::null; | 782 | return QString::null; |
780 | 783 | ||
781 | return QDir(item->directory() ).absPath(); | 784 | return QDir(item->directory() ).absPath(); |
782 | } | 785 | } |
783 | 786 | ||
784 | void OFileViewFileSystem::reread() | 787 | void OFileViewFileSystem::reread() |
785 | { | 788 | { |
786 | if (!m_view) | 789 | if (!m_view) |
787 | return; | 790 | return; |
788 | 791 | ||
789 | m_view->reread( m_all ); | 792 | m_view->reread( m_all ); |
790 | } | 793 | } |
791 | 794 | ||
792 | int OFileViewFileSystem::fileCount()const | 795 | int OFileViewFileSystem::fileCount()const |
793 | { | 796 | { |
794 | if (!m_view ) | 797 | if (!m_view ) |
795 | return -1; | 798 | return -1; |
796 | return m_view->fileCount(); | 799 | return m_view->fileCount(); |
797 | } | 800 | } |
798 | 801 | ||
799 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) | 802 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) |
800 | { | 803 | { |
801 | if (!m_view ) | 804 | if (!m_view ) |
802 | { | 805 | { |
803 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); | 806 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); |
804 | } | 807 | } |
805 | return m_view; | 808 | return m_view; |
806 | } | 809 | } |
807 | 810 | ||
808 | void OFileViewFileSystem::activate( const QString& str) | 811 | void OFileViewFileSystem::activate( const QString& str) |
809 | { | 812 | { |
810 | m_all = (str != QObject::tr("Files") ); | 813 | m_all = (str != QObject::tr("Files") ); |
811 | } | 814 | } |
812 | 815 | ||
816 | |||
817 | } | ||
813 | /* Selector */ | 818 | /* Selector */ |
814 | /** | 819 | /** |
815 | * @short new and complete c'tor | 820 | * @short new and complete c'tor |
816 | * | 821 | * |
817 | * Create a OFileSelector to let the user select a file. It can | 822 | * Create a OFileSelector to let the user select a file. It can |
818 | * either be used to open a file, select a save name in a dir or | 823 | * either be used to open a file, select a save name in a dir or |
819 | * as a dropin for the FileSelector. | 824 | * as a dropin for the FileSelector. |
820 | * | 825 | * |
821 | * <pre> | 826 | * <pre> |
822 | * QMap<QString, QStringList> mimeTypes; | 827 | * QMap<QString, QStringList> mimeTypes; |
823 | * QStringList types; | 828 | * QStringList types; |
824 | * types << "text@slash* "; | 829 | * types << "text@slash* "; |
825 | * types << "audio@slash*"; | 830 | * types << "audio@slash*"; |
826 | * mimeTypes.insert( tr("Audio and Text"), types ); | 831 | * mimeTypes.insert( tr("Audio and Text"), types ); |
827 | * mimeTypes.insert( tr("All"), "*@slash*); | 832 | * mimeTypes.insert( tr("All"), "*@slash*); |
828 | * | 833 | * |
829 | * now you could create your fileselector | 834 | * now you could create your fileselector |
830 | * </pre> | 835 | * </pre> |
831 | * | 836 | * |
832 | * | 837 | * |
833 | * @param parent the parent of this widget | 838 | * @param parent the parent of this widget |
834 | * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) | 839 | * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) |
835 | * @param sel The selector to be used | 840 | * @param sel The selector to be used |
836 | * @param dirName The name of the dir to start int | 841 | * @param dirName The name of the dir to start int |
837 | * @param fileName The fileName placed in the fileselector lineedit | 842 | * @param fileName The fileName placed in the fileselector lineedit |
838 | * @param mimetypes The MimeType map of used mimetypes | 843 | * @param mimetypes The MimeType map of used mimetypes |
839 | * @param showNew Show a New Button. Most likely to be used in the FileSelector view. | 844 | * @param showNew Show a New Button. Most likely to be used in the FileSelector view. |
840 | * @param showClose Show a Close Button. Most likely to be used in FileSelector view. | 845 | * @param showClose Show a Close Button. Most likely to be used in FileSelector view. |
841 | * | 846 | * |
842 | */ | 847 | */ |
843 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, | 848 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, |
844 | const QString& dirName, const QString& fileName, | 849 | const QString& dirName, const QString& fileName, |
845 | const MimeTypes& mimetypes, | 850 | const MimeTypes& mimetypes, |
846 | bool showNew, bool showClose) | 851 | bool showNew, bool showClose) |
847 | :QWidget( parent, "OFileSelector" ) | 852 | :QWidget( parent, "OFileSelector" ) |
848 | { | 853 | { |
849 | m_current = 0; | 854 | m_current = 0; |
850 | m_shNew = showNew; | 855 | m_shNew = showNew; |
851 | m_shClose = showClose; | 856 | m_shClose = showClose; |
852 | m_mimeType = mimetypes; | 857 | m_mimeType = mimetypes; |
853 | m_startDir = dirName; | 858 | m_startDir = dirName; |
854 | 859 | ||
855 | m_mode = mode; | 860 | m_mode = mode; |
856 | m_selector = sel; | 861 | m_selector = sel; |
857 | 862 | ||
858 | initUI(); | 863 | initUI(); |
859 | m_lneEdit->setText( fileName ); | 864 | m_lneEdit->setText( fileName ); |
860 | initMime(); | 865 | initMime(); |
@@ -1119,48 +1124,50 @@ void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) | |||
1119 | 1124 | ||
1120 | void OFileSelector::slotFileBridge( const QString& str) | 1125 | void OFileSelector::slotFileBridge( const QString& str) |
1121 | { | 1126 | { |
1122 | DocLnk lnk( str ); | 1127 | DocLnk lnk( str ); |
1123 | emit fileSelected( lnk ); | 1128 | emit fileSelected( lnk ); |
1124 | } | 1129 | } |
1125 | 1130 | ||
1126 | void OFileSelector::slotViewChange( const QString& view ) | 1131 | void OFileSelector::slotViewChange( const QString& view ) |
1127 | { | 1132 | { |
1128 | OFileViewInterface* interface = m_views[view]; | 1133 | OFileViewInterface* interface = m_views[view]; |
1129 | if (!interface) | 1134 | if (!interface) |
1130 | return; | 1135 | return; |
1131 | 1136 | ||
1132 | interface->activate( view ); | 1137 | interface->activate( view ); |
1133 | if (m_current) | 1138 | if (m_current) |
1134 | m_stack->removeWidget( m_current->widget( m_stack ) ); | 1139 | m_stack->removeWidget( m_current->widget( m_stack ) ); |
1135 | 1140 | ||
1136 | static int id = 1; | 1141 | static int id = 1; |
1137 | 1142 | ||
1138 | m_stack->addWidget( interface->widget(m_stack), id ); | 1143 | m_stack->addWidget( interface->widget(m_stack), id ); |
1139 | m_stack->raiseWidget( id ); | 1144 | m_stack->raiseWidget( id ); |
1140 | 1145 | ||
1141 | interface->reread(); | 1146 | interface->reread(); |
1142 | m_current = interface; | 1147 | m_current = interface; |
1143 | 1148 | ||
1144 | id++; | 1149 | id++; |
1145 | } | 1150 | } |
1146 | 1151 | ||
1147 | void OFileSelector::setNewVisible( bool b ) | 1152 | void OFileSelector::setNewVisible( bool b ) |
1148 | { | 1153 | { |
1149 | m_shNew = b; | 1154 | m_shNew = b; |
1150 | currentView()->reread(); | 1155 | currentView()->reread(); |
1151 | } | 1156 | } |
1152 | 1157 | ||
1153 | void OFileSelector::setCloseVisible( bool b ) | 1158 | void OFileSelector::setCloseVisible( bool b ) |
1154 | { | 1159 | { |
1155 | m_shClose = b; | 1160 | m_shClose = b; |
1156 | currentView()->reread(); | 1161 | currentView()->reread(); |
1157 | } | 1162 | } |
1158 | 1163 | ||
1159 | void OFileSelector::setNameVisible( bool b ) | 1164 | void OFileSelector::setNameVisible( bool b ) |
1160 | { | 1165 | { |
1161 | if ( b ) | 1166 | if ( b ) |
1162 | m_nameBox->show(); | 1167 | m_nameBox->show(); |
1163 | else | 1168 | else |
1164 | m_nameBox->hide(); | 1169 | m_nameBox->hide(); |
1165 | } | 1170 | } |
1166 | 1171 | ||
1172 | } | ||
1173 | } | ||