-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,464 +1,464 @@ | |||
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 ){ |
177 | it.deleteCurrent(); | 177 | it.deleteCurrent(); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | void OFileSelector::init() | 180 | void OFileSelector::init() |
181 | { | 181 | { |
182 | 182 | ||
183 | m_stack = new QWidgetStack(this, "wstack" ); | 183 | m_stack = new QWidgetStack(this, "wstack" ); |
184 | if( m_selector == NORMAL ){ | 184 | if( m_selector == NORMAL ){ |
185 | QString currMime; | 185 | QString currMime; |
186 | if( m_mimeCheck != 0 ) | 186 | if( m_mimeCheck != 0 ) |
187 | currMime = m_mimeCheck->currentText(); | 187 | currMime = m_mimeCheck->currentText(); |
188 | 188 | ||
189 | updateMimes(); | 189 | updateMimes(); |
190 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); | 190 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); |
191 | m_stack->addWidget(m_select, NORMAL ); | 191 | m_stack->addWidget(m_select, NORMAL ); |
192 | m_lay->addWidget(m_stack ); | 192 | m_lay->addWidget(m_stack ); |
193 | m_stack->raiseWidget(NORMAL ); | 193 | m_stack->raiseWidget(NORMAL ); |
194 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); | 194 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); |
195 | }else { | 195 | }else { |
196 | initializeListView(); | 196 | initializeListView(); |
197 | } | 197 | } |
198 | 198 | ||
199 | if(m_shLne ){ | 199 | if(m_shLne ){ |
200 | initializeName(); | 200 | initializeName(); |
201 | } | 201 | } |
202 | 202 | ||
203 | if(m_shPerm ){ | 203 | if(m_shPerm ){ |
204 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); | 204 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); |
205 | m_checkPerm->setChecked( false ); | 205 | m_checkPerm->setChecked( false ); |
206 | m_lay->addWidget(m_checkPerm ); | 206 | m_lay->addWidget(m_checkPerm ); |
207 | } | 207 | } |
208 | 208 | ||
209 | if( m_shChooser ) | 209 | if( m_shChooser ) |
210 | initializeChooser(); | 210 | initializeChooser(); |
211 | 211 | ||
212 | if(m_shYesNo ) | 212 | if(m_shYesNo ) |
213 | initializeYes(); | 213 | initializeYes(); |
214 | 214 | ||
215 | 215 | ||
216 | }; | 216 | }; |
217 | 217 | ||
218 | void OFileSelector::setYesCancelVisible( bool show ) | 218 | void OFileSelector::setYesCancelVisible( bool show ) |
219 | { | 219 | { |
220 | if ( show == m_shYesNo ) | 220 | if ( show == m_shYesNo ) |
221 | return; | 221 | return; |
222 | m_shYesNo = show; | 222 | m_shYesNo = show; |
223 | if( !show ){ | 223 | if( !show ){ |
224 | delete m_ok; | 224 | delete m_ok; |
225 | delete m_cancel; | 225 | delete m_cancel; |
226 | m_ok = 0; | 226 | m_ok = 0; |
227 | m_cancel = 0; | 227 | m_cancel = 0; |
228 | // delete m_boxOk; all ready deleted in delItems | 228 | // delete m_boxOk; all ready deleted in delItems |
229 | } | 229 | } |
230 | updateLay(); // recreate it and save the other states | 230 | updateLay(); // recreate it and save the other states |
231 | } | 231 | } |
232 | 232 | ||
233 | void OFileSelector::setToolbarVisible( bool show ) | 233 | void OFileSelector::setToolbarVisible( bool show ) |
234 | { | 234 | { |
235 | if ( m_shTool == show ) | 235 | if ( m_shTool == show ) |
236 | return; | 236 | return; |
237 | if(!m_shTool ){ | 237 | if(!m_shTool ){ |
238 | delete m_boxToolbar; | 238 | delete m_boxToolbar; |
239 | delete m_homeButton; | 239 | delete m_homeButton; |
240 | delete m_docButton; | 240 | delete m_docButton; |
241 | delete m_location; | 241 | delete m_location; |
242 | delete m_up; | 242 | delete m_up; |
243 | m_boxToolbar = 0; | 243 | m_boxToolbar = 0; |
244 | m_homeButton = 0; | 244 | m_homeButton = 0; |
245 | m_docButton = 0; | 245 | m_docButton = 0; |
246 | m_location = 0; | 246 | m_location = 0; |
247 | m_up = 0; | 247 | m_up = 0; |
248 | }; | 248 | }; |
249 | updateLay();// overkill fix it | 249 | updateLay();// overkill fix it |
250 | } | 250 | } |
251 | 251 | ||
252 | void OFileSelector::setPermissionBarVisible( bool show ) | 252 | void OFileSelector::setPermissionBarVisible( bool show ) |
253 | { | 253 | { |
254 | if( show == m_shPerm ) | 254 | if( show == m_shPerm ) |
255 | return; | 255 | return; |
256 | 256 | ||
257 | m_shPerm = show; | 257 | m_shPerm = show; |
258 | 258 | ||
259 | updateLay(); | 259 | updateLay(); |
260 | } | 260 | } |
261 | void OFileSelector::setLineEditVisible( bool show ) | 261 | void OFileSelector::setLineEditVisible( bool show ) |
262 | { | 262 | { |
263 | if( show == m_shLne ) | 263 | if( show == m_shLne ) |
264 | return; | 264 | return; |
265 | 265 | ||
266 | m_shLne = show; | 266 | m_shLne = show; |
267 | if( !show ){ | 267 | if( !show ){ |
268 | delete m_edit; | 268 | delete m_edit; |
269 | delete m_fnLabel; | 269 | delete m_fnLabel; |
270 | m_edit = 0; | 270 | m_edit = 0; |
271 | m_fnLabel = 0; | 271 | m_fnLabel = 0; |
272 | //delete m_boxName; will be deleted | 272 | //delete m_boxName; will be deleted |
273 | } | 273 | } |
274 | updateLay(); | 274 | updateLay(); |
275 | } | 275 | } |
276 | void OFileSelector::setChooserVisible( bool show ) | 276 | void OFileSelector::setChooserVisible( bool show ) |
277 | { | 277 | { |
278 | if( show = m_shChooser ) | 278 | if( show = m_shChooser ) |
279 | return; | 279 | return; |
280 | m_shChooser = show; | 280 | m_shChooser = show; |
281 | if( !show ){ | 281 | if( !show ){ |
282 | delete m_mimeCheck; | 282 | delete m_mimeCheck; |
283 | delete m_viewCheck; | 283 | delete m_viewCheck; |
284 | m_mimeCheck = 0; | 284 | m_mimeCheck = 0; |
285 | m_viewCheck = 0; | 285 | m_viewCheck = 0; |
286 | } | 286 | } |
287 | updateLay(); | 287 | updateLay(); |
288 | } | 288 | } |
289 | QCheckBox* OFileSelector::permissionCheckbox( ) | 289 | QCheckBox* OFileSelector::permissionCheckbox( ) |
290 | { | 290 | { |
291 | return m_checkPerm; | 291 | return m_checkPerm; |
292 | } | 292 | } |
293 | void OFileSelector::setCaseSensetive( bool caSe ) | 293 | void OFileSelector::setCaseSensetive( bool caSe ) |
294 | { | 294 | { |
295 | m_case = caSe; | 295 | m_case = caSe; |
296 | reparse(); | 296 | reparse(); |
297 | } | 297 | } |
298 | void OFileSelector::setShowFiles(bool files ){ | 298 | void OFileSelector::setShowFiles(bool files ){ |
299 | m_files = files; | 299 | m_files = files; |
300 | reparse(); | 300 | reparse(); |
301 | } | 301 | } |
302 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) | 302 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) |
303 | { | 303 | { |
304 | //delete oldpopup; | 304 | //delete oldpopup; |
305 | m_custom = pop; | 305 | m_custom = pop; |
306 | } | 306 | } |
307 | bool OFileSelector::setPermission( ) const | 307 | bool OFileSelector::setPermission( ) const |
308 | { | 308 | { |
309 | if( m_checkPerm == 0 ) | 309 | if( m_checkPerm == 0 ) |
310 | return false; | 310 | return false; |
311 | else | 311 | else |
312 | return m_checkPerm->isChecked(); | 312 | return m_checkPerm->isChecked(); |
313 | } | 313 | } |
314 | void OFileSelector::setPermissionChecked( bool check ) | 314 | void OFileSelector::setPermissionChecked( bool check ) |
315 | { | 315 | { |
316 | if( m_checkPerm == 0 ) | 316 | if( m_checkPerm == 0 ) |
317 | return; | 317 | return; |
318 | m_checkPerm->setChecked( check ); | 318 | m_checkPerm->setChecked( check ); |
319 | } | 319 | } |
320 | QString OFileSelector::selectedName( )const | 320 | QString OFileSelector::selectedName( )const |
321 | { | 321 | { |
322 | QString string; | 322 | QString string; |
323 | if( m_selector == NORMAL ){ | 323 | if( m_selector == NORMAL ){ |
324 | const DocLnk *lnk = m_select->selected(); | 324 | const DocLnk *lnk = m_select->selected(); |
325 | string = lnk->file(); | 325 | string = lnk->file(); |
326 | }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 326 | }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
327 | QListViewItem *item = m_View->currentItem(); | 327 | QListViewItem *item = m_View->currentItem(); |
328 | if(item != 0 ){ | 328 | if(item != 0 ){ |
329 | string = item->text( 1 ); | 329 | string = item->text( 1 ); |
330 | } | 330 | } |
331 | } | 331 | } |
332 | return string; | 332 | return string; |
333 | } | 333 | } |
334 | QStringList OFileSelector::selectedNames()const | 334 | QStringList OFileSelector::selectedNames()const |
335 | { | 335 | { |
336 | QStringList list; | 336 | QStringList list; |
337 | return list; | 337 | return list; |
338 | } | 338 | } |
339 | DocLnk OFileSelector::selectedDocument( )const | 339 | DocLnk OFileSelector::selectedDocument( )const |
340 | { | 340 | { |
341 | DocLnk lnk; | 341 | DocLnk lnk; |
342 | return lnk; | 342 | return lnk; |
343 | } | 343 | } |
344 | void OFileSelector::updateLay() | 344 | void OFileSelector::updateLay() |
345 | { | 345 | { |
346 | /* if( m_shTool ) | 346 | /* if( m_shTool ) |
347 | // | 347 | // |
348 | else | 348 | else |
349 | // hide | 349 | // hide |
350 | */ | 350 | */ |
351 | // save the state | 351 | // save the state |
352 | bool check = false; | 352 | bool check = false; |
353 | if( m_checkPerm != 0 ) | 353 | if( m_checkPerm != 0 ) |
354 | check = m_checkPerm->isChecked(); | 354 | check = m_checkPerm->isChecked(); |
355 | QString text; | 355 | QString text; |
356 | 356 | ||
357 | if( m_edit != 0 ) | 357 | if( m_edit != 0 ) |
358 | text = m_edit->text(); | 358 | text = m_edit->text(); |
359 | // save current mimetype | 359 | // save current mimetype |
360 | 360 | ||
361 | delItems(); | 361 | delItems(); |
362 | delete m_checkPerm; | 362 | delete m_checkPerm; |
363 | m_checkPerm = 0; | 363 | m_checkPerm = 0; |
364 | delete m_edit; | 364 | delete m_edit; |
365 | m_edit = 0; | 365 | m_edit = 0; |
366 | delete m_fnLabel; | 366 | delete m_fnLabel; |
367 | m_fnLabel = 0; | 367 | m_fnLabel = 0; |
368 | delete m_ok; | 368 | delete m_ok; |
369 | m_ok = 0; | 369 | m_ok = 0; |
370 | delete m_cancel; | 370 | delete m_cancel; |
371 | m_cancel = 0; | 371 | m_cancel = 0; |
372 | delete m_mimeCheck; | 372 | delete m_mimeCheck; |
373 | m_mimeCheck = 0; | 373 | m_mimeCheck = 0; |
374 | delete m_viewCheck; | 374 | delete m_viewCheck; |
375 | m_viewCheck = 0; | 375 | m_viewCheck = 0; |
376 | delete m_select; // test | 376 | delete m_select; // test |
377 | delete m_stack; | 377 | delete m_stack; |
378 | //delete m_list; | 378 | //delete m_list; |
379 | init(); | 379 | init(); |
380 | if( m_shLne ) | 380 | if( m_shLne ) |
381 | m_edit->setText(text ); | 381 | m_edit->setText(text ); |
382 | if( m_shPerm ) | 382 | if( m_shPerm ) |
383 | m_checkPerm->setChecked(check ); | 383 | m_checkPerm->setChecked(check ); |
384 | } | 384 | } |
385 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve | 385 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve |
386 | // insert QListViewItems with the right options | 386 | // insert QListViewItems with the right options |
387 | bool OFileSelector::compliesMime(const QString &path, const QString &mime ) | 387 | bool OFileSelector::compliesMime(const QString &path, const QString &mime ) |
388 | { | 388 | { |
389 | if( mime == "All" ) | 389 | if( mime == "All" ) |
390 | return true; | 390 | return true; |
391 | MimeType type( path ); | 391 | MimeType type( path ); |
392 | if( type.id() == mime ) | 392 | if( type.id() == mime ) |
393 | return true; | 393 | return true; |
394 | return false; | 394 | return false; |
395 | } | 395 | } |
396 | 396 | ||
397 | void OFileSelector::reparse() | 397 | void OFileSelector::reparse() |
398 | { | 398 | { |
399 | if(m_View== 0 || m_selector == NORMAL) | 399 | if(m_View== 0 || m_selector == NORMAL) |
400 | return; | 400 | return; |
401 | 401 | ||
402 | m_View->clear(); | 402 | m_View->clear(); |
403 | 403 | ||
404 | 404 | ||
405 | QString currMime =m_mimeCheck->currentText(); | 405 | QString currMime =m_mimeCheck->currentText(); |
406 | // update the mimetype now | 406 | // update the mimetype now |
407 | if( m_autoMime ) { | 407 | if( m_autoMime ) { |
408 | QDir dir( m_currentDir ); | 408 | QDir dir( m_currentDir ); |
409 | m_mimetypes.clear(); | 409 | m_mimetypes.clear(); |
410 | m_mimeCheck->clear(); | 410 | m_mimeCheck->clear(); |
411 | dir.setFilter( QDir::Files | QDir::Readable ); | 411 | dir.setFilter( QDir::Files | QDir::Readable ); |
412 | dir.setSorting(QDir::Size ); | 412 | dir.setSorting(QDir::Size ); |
413 | const QFileInfoList *list = dir.entryInfoList(); | 413 | const QFileInfoList *list = dir.entryInfoList(); |
414 | QFileInfoListIterator it( *list ); | 414 | QFileInfoListIterator it( *list ); |
415 | QFileInfo *fi; | 415 | QFileInfo *fi; |
416 | while( (fi=it.current()) ){ | 416 | while( (fi=it.current()) ){ |
417 | if(fi->extension() == QString::fromLatin1("desktop") ){ | 417 | if(fi->extension() == QString::fromLatin1("desktop") ){ |
418 | ++it; | 418 | ++it; |
419 | continue; | 419 | continue; |
420 | } | 420 | } |
421 | MimeType type(fi->filePath() ); | 421 | MimeType type(fi->filePath() ); |
422 | if( !m_mimetypes.contains( type.id() ) ) | 422 | if( !m_mimetypes.contains( type.id() ) ) |
423 | m_mimetypes.append( type.id() ); | 423 | m_mimetypes.append( type.id() ); |
424 | 424 | ||
425 | ++it; | 425 | ++it; |
426 | } | 426 | } |
427 | m_mimetypes.prepend("All" ); | 427 | m_mimetypes.prepend("All" ); |
428 | m_mimeCheck->insertStringList(m_mimetypes ); | 428 | m_mimeCheck->insertStringList(m_mimetypes ); |
429 | // set it to the current mimetype | 429 | // set it to the current mimetype |
430 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); | 430 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); |
431 | }; | 431 | }; |
432 | QDir dir( m_currentDir ); | 432 | QDir dir( m_currentDir ); |
433 | //dir.setFilter(-1 ); | 433 | //dir.setFilter(-1 ); |
434 | int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; | 434 | int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; |
435 | if( m_case ) | 435 | if( m_case ) |
436 | sort = QDir::IgnoreCase; | 436 | sort = QDir::IgnoreCase; |
437 | dir.setSorting( sort ); | 437 | dir.setSorting( sort ); |
438 | 438 | ||
439 | int filter; | 439 | int filter; |
440 | /* if( m_dir && !m_files) | 440 | /* if( m_dir && !m_files) |
441 | filter |= QDir::Dirs; | 441 | filter |= QDir::Dirs; |
442 | else if( !m_dir && m_files ) | 442 | else if( !m_dir && m_files ) |
443 | filter |= QDir::Files; | 443 | filter |= QDir::Files; |
444 | else | 444 | else |
445 | filter |= QDir::All; | 445 | filter |= QDir::All; |
446 | */ | 446 | */ |
447 | if( m_selector == EXTENDED_ALL ) | 447 | if( m_selector == EXTENDED_ALL ) |
448 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 448 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
449 | else | 449 | else |
450 | filter = QDir::Files | QDir::Dirs | QDir::All; | 450 | filter = QDir::Files | QDir::Dirs | QDir::All; |
451 | dir.setFilter( filter ); | 451 | dir.setFilter( filter ); |
452 | 452 | ||
453 | const QFileInfoList *list = dir.entryInfoList(); | 453 | const QFileInfoList *list = dir.entryInfoList(); |
454 | QFileInfoListIterator it( *list ); | 454 | QFileInfoListIterator it( *list ); |
455 | QFileInfo *fi; | 455 | QFileInfo *fi; |
456 | while( (fi=it.current()) ){ | 456 | while( (fi=it.current()) ){ |
457 | if(fi->fileName() == ".." || fi->fileName() == "." ){ | 457 | if(fi->fileName() == ".." || fi->fileName() == "." ){ |
458 | ++it; | 458 | ++it; |
459 | continue; | 459 | continue; |
460 | } | 460 | } |
461 | qWarning("Test: %s", fi->fileName().latin1() ); | 461 | qWarning("Test: %s", fi->fileName().latin1() ); |
462 | if(fi->isSymLink() ){ | 462 | if(fi->isSymLink() ){ |
463 | qWarning("Symlink %s", fi->fileName().latin1() ); | 463 | qWarning("Symlink %s", fi->fileName().latin1() ); |
464 | QString file = fi->dirPath(true)+"/"+ fi->readLink(); | 464 | QString file = fi->dirPath(true)+"/"+ fi->readLink(); |
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index bf3cb48..5e98a1e 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h | |||
@@ -1,277 +1,278 @@ | |||
1 | /* | 1 | /* |
2 | This is based on code and idea of | 2 | This is based on code and idea of |
3 | L. J. Potter ljp@llornkcor.com | 3 | L. J. Potter ljp@llornkcor.com |
4 | Thanks a lot | 4 | Thanks a lot |
5 | 5 | ||
6 | 6 | ||
7 | =. This file is part of the OPIE Project | 7 | =. This file is part of the OPIE Project |
8 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 8 | .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This library is free software; you can | 10 | _;:, .> :=|. This library is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This library is distributed in the hope that | 17 | .i_,=:_. -<s. This library is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
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 | ||