-rw-r--r-- | libopie/ofiledialog.cc | 110 | ||||
-rw-r--r-- | libopie/ofiledialog.h | 77 | ||||
-rw-r--r-- | libopie/ofileselector.cc | 2 | ||||
-rw-r--r-- | libopie/ofileselector.h | 7 |
4 files changed, 192 insertions, 4 deletions
diff --git a/libopie/ofiledialog.cc b/libopie/ofiledialog.cc new file mode 100644 index 0000000..92b0d0a --- a/dev/null +++ b/libopie/ofiledialog.cc | |||
@@ -0,0 +1,110 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 <> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include <qpe/applnk.h> | ||
30 | #include <qstring.h> | ||
31 | #include <qapplication.h> | ||
32 | #include <qlayout.h> | ||
33 | |||
34 | #include "ofiledialog.h" | ||
35 | |||
36 | OFileDialog::OFileDialog(const QString &caption, | ||
37 | QWidget *wid, int mode, int selector, | ||
38 | const QString &dirName, | ||
39 | const QString &fileName, | ||
40 | const QStringList &mimetypes ) | ||
41 | : QDialog( wid, "OFileDialog", true ) | ||
42 | { | ||
43 | QVBoxLayout *lay = new QVBoxLayout(this); | ||
44 | |||
45 | file = new OFileSelector(0 , mode, selector, | ||
46 | dirName, fileName, | ||
47 | mimetypes ); | ||
48 | lay->addWidget( file ); | ||
49 | //showFullScreen(); | ||
50 | setCaption( caption.isEmpty() ? tr("FileDialog") : caption ); | ||
51 | connect(file, SIGNAL(fileSelected(const QString&) ), | ||
52 | this, SLOT(slotFileSelected(const QString&) ) ); | ||
53 | |||
54 | connect(file, SIGNAL(dirSelected(const QString &) ), | ||
55 | this, SLOT(slotDirSelected(const QString &) ) ); | ||
56 | showMaximized(); | ||
57 | file->setYesCancelVisible( false ); // relayout | ||
58 | } | ||
59 | QString OFileDialog::mimetype()const | ||
60 | { | ||
61 | return QString::null; | ||
62 | } | ||
63 | QString OFileDialog::fileName()const | ||
64 | { | ||
65 | return file->selectedName(); | ||
66 | } | ||
67 | DocLnk OFileDialog::selectedDocument()const | ||
68 | { | ||
69 | return file->selectedDocument(); | ||
70 | } | ||
71 | QString OFileDialog::getOpenFileName(int selector, | ||
72 | const QString &startDir, | ||
73 | const QString &file, | ||
74 | const QStringList &mimes, | ||
75 | QWidget *wid, | ||
76 | const QString &caption ) | ||
77 | { | ||
78 | QString ret; | ||
79 | OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption, | ||
80 | wid, OFileSelector::OPEN, selector, startDir, file, mimes); | ||
81 | if( dlg.exec() ) | ||
82 | ret = dlg.fileName(); | ||
83 | |||
84 | return ret; | ||
85 | } | ||
86 | QString OFileDialog::getSaveFileName(int selector, | ||
87 | const QString &startDir, | ||
88 | const QString &file, | ||
89 | const QStringList &mimes, | ||
90 | QWidget *wid, | ||
91 | const QString &caption ) | ||
92 | { | ||
93 | QString ret; | ||
94 | OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption, | ||
95 | wid, OFileSelector::SAVE, selector, startDir, file, mimes); | ||
96 | if( dlg.exec() ) | ||
97 | ret = dlg.fileName(); | ||
98 | |||
99 | return ret; | ||
100 | } | ||
101 | |||
102 | void OFileDialog::slotFileSelected(const QString & ) | ||
103 | { | ||
104 | accept(); | ||
105 | } | ||
106 | void OFileDialog::slotDirSelected(const QString & ) | ||
107 | { | ||
108 | // if mode | ||
109 | //accept(); | ||
110 | } | ||
diff --git a/libopie/ofiledialog.h b/libopie/ofiledialog.h new file mode 100644 index 0000000..40d147e --- a/dev/null +++ b/libopie/ofiledialog.h | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 zecke <zecke@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | |||
30 | #ifndef OpieFileDialog_h | ||
31 | #define OpieFileDialog_h | ||
32 | |||
33 | #include <qdialog.h> | ||
34 | |||
35 | #include <opie/ofileselector.h> | ||
36 | |||
37 | class OFileDialog : public QDialog { | ||
38 | Q_OBJECT | ||
39 | public: | ||
40 | OFileDialog(const QString &caption, | ||
41 | QWidget *, int mode, int selector, | ||
42 | const QString &dirName, | ||
43 | const QString &fileName = QString::null, | ||
44 | const QStringList &mimetypes = QStringList() ); | ||
45 | QString mimetype() const; | ||
46 | QString fileName() const; | ||
47 | DocLnk selectedDocument()const; | ||
48 | |||
49 | // static methods | ||
50 | static QString getOpenFileName(int selector, | ||
51 | const QString& startDir = QString::null, | ||
52 | const QString &fileName = QString::null, | ||
53 | const QStringList& mimefilter = QStringList(), | ||
54 | QWidget *wid = 0, | ||
55 | const QString &caption = QString::null ); | ||
56 | |||
57 | static QString getSaveFileName(int selector, | ||
58 | const QString& startDir = QString::null, | ||
59 | const QString& fileName = QString::null, | ||
60 | const QStringList& mimefilter = QStringList(), | ||
61 | QWidget *wid = 0, | ||
62 | const QString &caption = QString::null ); | ||
63 | |||
64 | //let's OFileSelector catch up first | ||
65 | //static QString getExistingDirectory(const QString& startDir = QString::null, | ||
66 | // QWidget *parent = 0, | ||
67 | // const QString& caption = QString::null ); | ||
68 | private: | ||
69 | class OFileDialogPrivate; | ||
70 | OFileDialogPrivate *d; | ||
71 | OFileSelector *file; | ||
72 | |||
73 | private slots: | ||
74 | void slotFileSelected( const QString & ); | ||
75 | void slotDirSelected(const QString & ); | ||
76 | }; | ||
77 | #endif | ||
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index fbe69ed..bc7c6c2 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -1,176 +1,176 @@ | |||
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 Holger Freyther <zecke@handhelds.org> | 3 | .=l. Copyright (c) 2002 Holger Freyther <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 | #include <qnamespace.h> | 29 | #include <qnamespace.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
32 | #include <qhbox.h> | 32 | #include <qhbox.h> |
33 | #include <qvbox.h> | 33 | #include <qvbox.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qwidgetstack.h> | 35 | #include <qwidgetstack.h> |
36 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
37 | #include <qcheckbox.h> | 37 | #include <qcheckbox.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qheader.h> | 39 | #include <qheader.h> |
40 | #include <qdir.h> | 40 | #include <qdir.h> |
41 | #include <qpainter.h> | 41 | #include <qpainter.h> |
42 | #include <qaction.h> | 42 | #include <qaction.h> |
43 | #include <qpopupmenu.h> | 43 | #include <qpopupmenu.h> |
44 | #include <qcursor.h> | 44 | #include <qcursor.h> |
45 | 45 | ||
46 | #include <qpe/qpeapplication.h> | 46 | #include <qpe/qpeapplication.h> |
47 | #include <qpe/fileselector.h> | 47 | #include <qpe/fileselector.h> |
48 | #include <qpe/applnk.h> | 48 | #include <qpe/applnk.h> |
49 | #include <qpe/global.h> | 49 | #include <qpe/global.h> |
50 | #include <qpe/mimetype.h> | 50 | #include <qpe/mimetype.h> |
51 | #include <qpe/resource.h> | 51 | #include <qpe/resource.h> |
52 | #include <qpe/storage.h> | 52 | #include <qpe/storage.h> |
53 | 53 | ||
54 | #include <unistd.h> | 54 | #include <unistd.h> |
55 | #include <stdlib.h> | 55 | #include <stdlib.h> |
56 | #include <sys/stat.h> | 56 | #include <sys/stat.h> |
57 | 57 | ||
58 | #include "ofileselector.h" | 58 | #include "ofileselector.h" |
59 | 59 | ||
60 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | 60 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; |
61 | 61 | ||
62 | namespace { | 62 | namespace { |
63 | 63 | ||
64 | int indexByString( const QComboBox *box, const QString &str ){ | 64 | int indexByString( const QComboBox *box, const QString &str ){ |
65 | int index= -1; | 65 | int index= -1; |
66 | for(int i= 0; i < box->count(); i++ ){ | 66 | for(int i= 0; i < box->count(); i++ ){ |
67 | qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() ); | 67 | qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() ); |
68 | if( str == box->text(i ) ){ | 68 | if( str == box->text(i ) ){ |
69 | index= i; | 69 | index= i; |
70 | break; | 70 | break; |
71 | } | 71 | } |
72 | } | 72 | } |
73 | return index; | 73 | return index; |
74 | } | 74 | } |
75 | 75 | ||
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 | m_selector = selector; | 82 | m_selector = selector; |
83 | m_currentDir = dirName; | 83 | m_currentDir = dirName; |
84 | m_name = fileName; | 84 | m_name = fileName; |
85 | m_mimetypes = mimetypes; | 85 | m_mimetypes = mimetypes; |
86 | if( mimetypes.isEmpty() ) | 86 | if( mimetypes.isEmpty() ) |
87 | m_autoMime = true; | 87 | m_autoMime = true; |
88 | 88 | ||
89 | m_mode = mode; | 89 | m_mode = mode; |
90 | m_shTool = true; | 90 | m_shTool = true; |
91 | m_shPerm = true; | 91 | m_shPerm = true; |
92 | m_shLne = true; | 92 | m_shLne = true; |
93 | m_shChooser = true; | 93 | m_shChooser = true; |
94 | m_shYesNo = true; | 94 | m_shYesNo = true; |
95 | // for FILESELECTOR only view is interesting | 95 | // for FILESELECTOR only view is interesting |
96 | m_location = 0; | 96 | m_location = 0; |
97 | m_homeButton = 0; | 97 | m_homeButton = 0; |
98 | m_docButton = 0; | 98 | m_docButton = 0; |
99 | m_hideButton = 0; | 99 | m_hideButton = 0; |
100 | m_ok = 0; | 100 | m_ok = 0; |
101 | m_cancel = 0; | 101 | m_cancel = 0; |
102 | m_reread = 0; | 102 | m_reread = 0; |
103 | m_up = 0; | 103 | m_up = 0; |
104 | m_View = 0; | 104 | m_View = 0; |
105 | m_select = 0; | 105 | m_select = 0; |
106 | m_stack = 0; | 106 | m_stack = 0; |
107 | 107 | ||
108 | m_select = 0; | 108 | m_select = 0; |
109 | m_stack = 0; | 109 | m_stack = 0; |
110 | m_lay = 0; | 110 | m_lay = 0; |
111 | m_boxToolbar = 0; | 111 | m_boxToolbar = 0; |
112 | m_boxOk = 0; | 112 | m_boxOk = 0; |
113 | m_edit = 0; | 113 | m_edit = 0; |
114 | 114 | ||
115 | m_fnLabel = 0; | 115 | m_fnLabel = 0; |
116 | m_checkPerm = 0; | 116 | m_checkPerm = 0; |
117 | m_mimeCheck = 0; | 117 | m_mimeCheck = 0; |
118 | m_viewCheck = 0; | 118 | m_viewCheck = 0; |
119 | 119 | ||
120 | m_pseudo = 0; | 120 | m_pseudo = 0; |
121 | m_pseudoLayout = 0; | 121 | m_pseudoLayout = 0; |
122 | 122 | ||
123 | m_dir = true; | 123 | m_dir = true; |
124 | m_files = true; | 124 | m_files = true; |
125 | m_custom = 0; | 125 | m_custom = 0; |
126 | m_showPopup = true; | 126 | m_showPopup = true; |
127 | 127 | ||
128 | if(m_pixmaps == 0 ) // init the pixmaps | 128 | if(m_pixmaps == 0 ) // init the pixmaps |
129 | initPics(); | 129 | initPics(); |
130 | 130 | ||
131 | m_lay = new QVBoxLayout(this); | 131 | m_lay = new QVBoxLayout(this); |
132 | init(); | 132 | init(); |
133 | m_edit->setText( fileName ); | 133 | m_edit->setText( fileName ); |
134 | } | 134 | } |
135 | void OFileSelector::initPics() | 135 | void OFileSelector::initPics() |
136 | { | 136 | { |
137 | qWarning("init pics" ); | 137 | qWarning("init pics" ); |
138 | m_pixmaps = new QMap<QString,QPixmap>; | 138 | m_pixmaps = new QMap<QString,QPixmap>; |
139 | QPixmap pm = Resource::loadPixmap( "folder" ); | 139 | QPixmap pm = Resource::loadPixmap( "folder" ); |
140 | QPixmap lnk = Resource::loadPixmap( "symlink" ); | 140 | QPixmap lnk = Resource::loadPixmap( "symlink" ); |
141 | QPainter painter( &pm ); | 141 | QPainter painter( &pm ); |
142 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 142 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
143 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 143 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
144 | m_pixmaps->insert("dirsymlink", pm ); | 144 | m_pixmaps->insert("dirsymlink", pm ); |
145 | 145 | ||
146 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | 146 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); |
147 | QPainter pen(&pm2 ); | 147 | QPainter pen(&pm2 ); |
148 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | 148 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); |
149 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | 149 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); |
150 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 150 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
151 | 151 | ||
152 | }; | 152 | }; |
153 | // let's initialize the gui | 153 | // let's initialize the gui |
154 | /** | 154 | /** |
155 | -------------------- | 155 | -------------------- |
156 | | cmbBox Button | | 156 | | cmbBox Button | |
157 | -------------------- | 157 | -------------------- |
158 | | FileSlector | | 158 | | FileSlector | |
159 | | or | | 159 | | or | |
160 | | OSelector | | 160 | | OSelector | |
161 | | | | 161 | | | |
162 | | | | 162 | | | |
163 | ____________________ | 163 | ____________________ |
164 | | LineEdit | | 164 | | LineEdit | |
165 | ____________________ | 165 | ____________________ |
166 | | Permission Bar | | 166 | | Permission Bar | |
167 | ____________________ | 167 | ____________________ |
168 | | ViewChoose | | 168 | | ViewChoose | |
169 | ____________________ | 169 | ____________________ |
170 | | Save Cancel| | 170 | | Save Cancel| |
171 | ____________________ | 171 | ____________________ |
172 | */ | 172 | */ |
173 | void OFileSelector::delItems() | 173 | void OFileSelector::delItems() |
174 | { | 174 | { |
175 | QLayoutIterator it = m_lay->iterator(); | 175 | QLayoutIterator it = m_lay->iterator(); |
176 | while ( it.current() != 0 ){ | 176 | while ( it.current() != 0 ){ |
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index bf3cb48..5e98a1e 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h | |||
@@ -23,255 +23,256 @@ | |||
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef opiefileselector_h | 34 | #ifndef opiefileselector_h |
35 | #define opiefileselector_h | 35 | #define opiefileselector_h |
36 | 36 | ||
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | #include <qpixmap.h> | 39 | #include <qpixmap.h> |
40 | #include <qstringlist.h> | 40 | #include <qstringlist.h> |
41 | #include <qmap.h> | 41 | #include <qmap.h> |
42 | #include <qvaluelist.h> | 42 | #include <qvaluelist.h> |
43 | 43 | ||
44 | #include <qpe/applnk.h> | 44 | #include <qpe/applnk.h> |
45 | #include <qlistview.h> | 45 | #include <qlistview.h> |
46 | /** This is OPIEs FileDialog Widget. You can use it | 46 | /** This is OPIEs FileDialog Widget. You can use it |
47 | * as a dropin replacement of the fileselector and | 47 | * as a dropin replacement of the fileselector and |
48 | * or use any of the new features. | 48 | * or use any of the new features. |
49 | * This is also a complete FileSave and FileLoad widget | 49 | * This is also a complete FileSave and FileLoad widget |
50 | * If you look for a Dialog check OFileDialog | 50 | * If you look for a Dialog check OFileDialog |
51 | * | 51 | * |
52 | */ | 52 | */ |
53 | class DocLnk; | 53 | class DocLnk; |
54 | class QCheckBox; | 54 | class QCheckBox; |
55 | class QComboBox; | 55 | class QComboBox; |
56 | class QPushButton; | 56 | class QPushButton; |
57 | class FileSelector; | 57 | class FileSelector; |
58 | class QGridLayout; | 58 | class QGridLayout; |
59 | class QLineEdit; | 59 | class QLineEdit; |
60 | class QLabel; | 60 | class QLabel; |
61 | class QWidgetStack; | 61 | class QWidgetStack; |
62 | class QHBoxLayout; | 62 | class QHBoxLayout; |
63 | class QVBoxLayout; | 63 | class QVBoxLayout; |
64 | class QPopupMenu; | 64 | class QPopupMenu; |
65 | class QFileInfo; | 65 | class QFileInfo; |
66 | // | 66 | // |
67 | class OFileSelectorItem : public QListViewItem { | 67 | class OFileSelectorItem : public QListViewItem { |
68 | public: | 68 | public: |
69 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | 69 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, |
70 | const QString &date, const QString &size, const QString &mDir, | 70 | const QString &date, const QString &size, const QString &mDir, |
71 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { | 71 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { |
72 | setPixmap(0, pixmap ); | 72 | setPixmap(0, pixmap ); |
73 | setText(1, path ); | 73 | setText(1, path ); |
74 | setText(2, size ); | 74 | setText(2, size ); |
75 | setText(3, date ); | 75 | setText(3, date ); |
76 | //setText(4, mDir ); | 76 | //setText(4, mDir ); |
77 | m_dir = mDir; | 77 | m_dir = mDir; |
78 | dir = isDir; | 78 | dir = isDir; |
79 | mLocked = isLocked; | 79 | mLocked = isLocked; |
80 | } | 80 | } |
81 | bool isLocked() const{ | 81 | bool isLocked() const{ |
82 | return mLocked; | 82 | return mLocked; |
83 | } | 83 | } |
84 | QString directory()const{ | 84 | QString directory()const{ |
85 | return m_dir; | 85 | return m_dir; |
86 | } | 86 | } |
87 | bool isDir()const{ | 87 | bool isDir()const{ |
88 | return dir; | 88 | return dir; |
89 | } | 89 | } |
90 | QString path()const{ | 90 | QString path()const{ |
91 | return text(1 ); | 91 | return text(1 ); |
92 | } | 92 | } |
93 | QString key(int id, bool )const { | 93 | QString key(int id, bool )const { |
94 | QString ke; | 94 | QString ke; |
95 | if( id == 0 || id == 1 ){ // name | 95 | if( id == 0 || id == 1 ){ // name |
96 | if( dir ){ | 96 | if( dir ){ |
97 | ke.append("0" ); | 97 | ke.append("0" ); |
98 | ke.append( text(1) ); | 98 | ke.append( text(1) ); |
99 | }else{ | 99 | }else{ |
100 | ke.append("1" ); | 100 | ke.append("1" ); |
101 | ke.append( text(1) ); | 101 | ke.append( text(1) ); |
102 | } | 102 | } |
103 | }else if( id == 2 ){ // size | 103 | }else if( id == 2 ){ // size |
104 | return text(2); | 104 | return text(2); |
105 | }else if( id == 3 ){ // date | 105 | }else if( id == 3 ){ // date |
106 | return text(3); | 106 | return text(3); |
107 | } | 107 | } |
108 | return ke; | 108 | return ke; |
109 | }; | 109 | }; |
110 | private: | 110 | private: |
111 | bool mLocked:1; | 111 | bool mLocked:1; |
112 | bool dir:1; | 112 | bool dir:1; |
113 | QString m_dir; | 113 | QString m_dir; |
114 | }; | 114 | }; |
115 | 115 | ||
116 | class OFileSelector : public QWidget { | 116 | class OFileSelector : public QWidget { |
117 | Q_OBJECT | 117 | Q_OBJECT |
118 | public: | 118 | public: |
119 | enum Mode {OPEN=1, SAVE, FILESELECTOR }; | 119 | enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 }; |
120 | enum Selector{NORMAL=1, EXTENDED = 2, EXTENDED_ALL =4 }; | 120 | enum Selector{NORMAL=1, EXTENDED = 2, EXTENDED_ALL =4 }; |
121 | enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; | 121 | enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; |
122 | OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const QStringList mimetypes = QStringList() ); | 122 | OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const QStringList &mimetypes = QStringList() ); |
123 | 123 | ~OFileSelector() {}; | |
124 | bool isToolbarVisible() const { return m_shTool; }; | 124 | bool isToolbarVisible() const { return m_shTool; }; |
125 | bool isPermissionBarVisible() const { return m_shPerm; }; | 125 | bool isPermissionBarVisible() const { return m_shPerm; }; |
126 | bool isLineEditVisible()const { return m_shLne; }; | 126 | bool isLineEditVisible()const { return m_shLne; }; |
127 | bool isChooserVisible( )const { return m_shChooser; }; | 127 | bool isChooserVisible( )const { return m_shChooser; }; |
128 | bool isYesCancelVisible()const { return m_shYesNo; }; | 128 | bool isYesCancelVisible()const { return m_shYesNo; }; |
129 | void setYesCancelVisible( bool show ); | 129 | void setYesCancelVisible( bool show ); |
130 | void setToolbarVisible( bool show ); | 130 | void setToolbarVisible( bool show ); |
131 | void setPermissionBarVisible( bool show ); | 131 | void setPermissionBarVisible( bool show ); |
132 | void setLineEditVisible(bool show) ; | 132 | void setLineEditVisible(bool show) ; |
133 | void setChooserVisible( bool chooser ); | 133 | void setChooserVisible( bool chooser ); |
134 | 134 | ||
135 | QCheckBox* permissionCheckbox(); | 135 | QCheckBox* permissionCheckbox(); |
136 | bool setPermission() const; | 136 | bool setPermission() const; |
137 | void setPermissionChecked( bool check ); | 137 | void setPermissionChecked( bool check ); |
138 | 138 | ||
139 | void setMode( int ); | 139 | void setMode( int ); |
140 | 140 | ||
141 | bool showDirs()const { return m_dir; } | 141 | bool showDirs()const { return m_dir; } |
142 | void setShowDirs(bool ); | 142 | void setShowDirs(bool ); |
143 | 143 | ||
144 | const QListView* listView() { return m_View; }; | 144 | const QListView* listView() { return m_View; }; |
145 | 145 | ||
146 | bool isCaseSensetive()const { return m_case; } | 146 | bool isCaseSensetive()const { return m_case; } |
147 | void setCaseSensetive(bool caSe ); | 147 | void setCaseSensetive(bool caSe ); |
148 | 148 | ||
149 | bool showFiles()const { return m_files; }; | 149 | bool showFiles()const { return m_files; }; |
150 | void setShowFiles(bool ); | 150 | void setShowFiles(bool ); |
151 | bool cd(const QString &path ); | 151 | bool cd(const QString &path ); |
152 | 152 | ||
153 | 153 | ||
154 | int mode()const { return m_mode; }; | 154 | int mode()const { return m_mode; }; |
155 | int selector()const { return m_selector; }; | 155 | int selector()const { return m_selector; }; |
156 | void setSelector( int ); | 156 | void setSelector( int ); |
157 | 157 | ||
158 | bool showPopup()const { return m_showPopup; }; | 158 | bool showPopup()const { return m_showPopup; }; |
159 | void setShowPopup( bool pop ) { m_showPopup = pop; }; | 159 | void setShowPopup( bool pop ) { m_showPopup = pop; }; |
160 | void setPopupMenu( QPopupMenu * ); | 160 | void setPopupMenu( QPopupMenu * ); |
161 | 161 | ||
162 | void updateLay(); | 162 | void updateLay(); |
163 | 163 | ||
164 | void reparse(); // re reads the dir | 164 | void reparse(); // re reads the dir |
165 | 165 | ||
166 | QString selectedName( )const; | 166 | QString selectedName( )const; |
167 | QStringList selectedNames()const; | 167 | QStringList selectedNames()const; |
168 | 168 | ||
169 | QString selectedPath() const; | 169 | QString selectedPath() const; |
170 | QStringList selectedPaths() const; | 170 | QStringList selectedPaths() const; |
171 | 171 | ||
172 | QString directory()const; | 172 | QString directory()const; |
173 | int fileCount(); | 173 | int fileCount(); |
174 | 174 | ||
175 | /* the user needs to delete it */ | 175 | /* the user needs to delete it */ |
176 | DocLnk selectedDocument()const; | 176 | DocLnk selectedDocument()const; |
177 | /* the user needs to delete it */ | 177 | /* the user needs to delete it */ |
178 | QValueList<DocLnk> selectedDocuments()const; | 178 | QValueList<DocLnk> selectedDocuments()const; |
179 | 179 | ||
180 | signals: | 180 | signals: |
181 | void fileSelected( const DocLnk & ); | 181 | void fileSelected( const DocLnk & ); |
182 | void fileSelected( const QString & ); | 182 | void fileSelected( const QString & ); |
183 | void dirSelected(const QString &dir ); | ||
183 | void closeMe(); | 184 | void closeMe(); |
184 | void ok(); | 185 | void ok(); |
185 | void cancel(); | 186 | void cancel(); |
186 | 187 | ||
187 | protected slots: | 188 | protected slots: |
188 | void slotOk(); | 189 | void slotOk(); |
189 | void slotCancel(); | 190 | void slotCancel(); |
190 | void slotViewCheck(const QString & ); | 191 | void slotViewCheck(const QString & ); |
191 | void slotMimeCheck(const QString & ); | 192 | void slotMimeCheck(const QString & ); |
192 | protected: | 193 | protected: |
193 | void init(); | 194 | void init(); |
194 | void updateMimes(); | 195 | void updateMimes(); |
195 | 196 | ||
196 | protected: | 197 | protected: |
197 | 198 | ||
198 | private: | 199 | private: |
199 | int m_mode, m_selector; | 200 | int m_mode, m_selector; |
200 | QComboBox *m_location, *m_mimeCheck, *m_viewCheck; | 201 | QComboBox *m_location, *m_mimeCheck, *m_viewCheck; |
201 | QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; | 202 | QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; |
202 | QPushButton *m_reread, *m_up; | 203 | QPushButton *m_reread, *m_up; |
203 | QListView *m_View; | 204 | QListView *m_View; |
204 | QCheckBox *m_checkPerm; | 205 | QCheckBox *m_checkPerm; |
205 | QWidget *m_pseudo; | 206 | QWidget *m_pseudo; |
206 | QVBoxLayout *m_pseudoLayout; | 207 | QVBoxLayout *m_pseudoLayout; |
207 | 208 | ||
208 | QString m_currentDir; | 209 | QString m_currentDir; |
209 | QString m_name; | 210 | QString m_name; |
210 | QStringList m_mimetypes; | 211 | QStringList m_mimetypes; |
211 | 212 | ||
212 | FileSelector *m_select; | 213 | FileSelector *m_select; |
213 | QWidgetStack *m_stack; | 214 | QWidgetStack *m_stack; |
214 | QVBoxLayout *m_lay; | 215 | QVBoxLayout *m_lay; |
215 | QGridLayout *m_Oselector; | 216 | QGridLayout *m_Oselector; |
216 | 217 | ||
217 | QHBoxLayout *m_boxToolbar; | 218 | QHBoxLayout *m_boxToolbar; |
218 | QHBoxLayout *m_boxOk; | 219 | QHBoxLayout *m_boxOk; |
219 | QHBoxLayout *m_boxName; | 220 | QHBoxLayout *m_boxName; |
220 | QHBoxLayout *m_boxView; | 221 | QHBoxLayout *m_boxView; |
221 | 222 | ||
222 | QPopupMenu *m_custom; | 223 | QPopupMenu *m_custom; |
223 | 224 | ||
224 | QLineEdit *m_edit; | 225 | QLineEdit *m_edit; |
225 | QLabel *m_fnLabel; | 226 | QLabel *m_fnLabel; |
226 | bool m_shTool:1; | 227 | bool m_shTool:1; |
227 | bool m_shPerm:1; | 228 | bool m_shPerm:1; |
228 | bool m_shLne:1; | 229 | bool m_shLne:1; |
229 | bool m_shChooser:1; | 230 | bool m_shChooser:1; |
230 | bool m_shYesNo:1; | 231 | bool m_shYesNo:1; |
231 | bool m_boCheckPerm:1; | 232 | bool m_boCheckPerm:1; |
232 | bool m_autoMime:1; | 233 | bool m_autoMime:1; |
233 | bool m_case:1; | 234 | bool m_case:1; |
234 | bool m_dir:1; | 235 | bool m_dir:1; |
235 | bool m_files:1; | 236 | bool m_files:1; |
236 | bool m_showPopup:1; | 237 | bool m_showPopup:1; |
237 | 238 | ||
238 | // implementation todo | 239 | // implementation todo |
239 | virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); | 240 | virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); |
240 | virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); | 241 | virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); |
241 | virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){}; | 242 | virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){}; |
242 | void delItems(); | 243 | void delItems(); |
243 | void initializeName(); | 244 | void initializeName(); |
244 | void initializeYes(); | 245 | void initializeYes(); |
245 | void initializeChooser(); | 246 | void initializeChooser(); |
246 | void initializeListView(); | 247 | void initializeListView(); |
247 | void initPics(); | 248 | void initPics(); |
248 | bool compliesMime(const QString &path, const QString &mime); | 249 | bool compliesMime(const QString &path, const QString &mime); |
249 | 250 | ||
250 | class OFileSelectorPrivate; | 251 | class OFileSelectorPrivate; |
251 | OFileSelectorPrivate *d; | 252 | OFileSelectorPrivate *d; |
252 | static QMap<QString,QPixmap> *m_pixmaps; | 253 | static QMap<QString,QPixmap> *m_pixmaps; |
253 | 254 | ||
254 | private slots: | 255 | private slots: |
255 | void slotFileSelected(const QString & ); // not really meant to be a slot | 256 | void slotFileSelected(const QString & ); // not really meant to be a slot |
256 | void slotFileBridgeSelected( const DocLnk & ); | 257 | void slotFileBridgeSelected( const DocLnk & ); |
257 | virtual void slotSelectionChanged(); | 258 | virtual void slotSelectionChanged(); |
258 | virtual void slotCurrentChanged(QListViewItem* ); | 259 | virtual void slotCurrentChanged(QListViewItem* ); |
259 | virtual void slotClicked( int, QListViewItem *item, const QPoint &, int); | 260 | virtual void slotClicked( int, QListViewItem *item, const QPoint &, int); |
260 | virtual void slotRightButton(int, QListViewItem *, const QPoint &, int ); | 261 | virtual void slotRightButton(int, QListViewItem *, const QPoint &, int ); |
261 | virtual void slotContextMenu( QListViewItem *item); | 262 | virtual void slotContextMenu( QListViewItem *item); |
262 | // listview crap see above | 263 | // listview crap see above |
263 | // PopupMenu crap | 264 | // PopupMenu crap |
264 | virtual void slotChangedDir(); | 265 | virtual void slotChangedDir(); |
265 | virtual void slotOpen(); | 266 | virtual void slotOpen(); |
266 | virtual void slotRescan(); | 267 | virtual void slotRescan(); |
267 | virtual void slotRename(); | 268 | virtual void slotRename(); |
268 | virtual void slotDelete(); | 269 | virtual void slotDelete(); |
269 | virtual void cdUP(); | 270 | virtual void cdUP(); |
270 | virtual void slotHome(); | 271 | virtual void slotHome(); |
271 | virtual void slotDoc(); | 272 | virtual void slotDoc(); |
272 | virtual void slotNavigate( ); | 273 | virtual void slotNavigate( ); |
273 | }; | 274 | }; |
274 | 275 | ||
275 | 276 | ||
276 | #endif | 277 | #endif |
277 | 278 | ||