author | zecke <zecke> | 2002-04-27 22:20:11 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-04-27 22:20:11 (UTC) |
commit | 2dc8c64cfa30a199e4ebd45618e726e9ffc6f7dc (patch) (unidiff) | |
tree | 60d42174dc3898dae0c95a339b49997a8591a86b | |
parent | 7d741c93b423a3ab721071971b2c345d2d8548e2 (diff) | |
download | opie-2dc8c64cfa30a199e4ebd45618e726e9ffc6f7dc.zip opie-2dc8c64cfa30a199e4ebd45618e726e9ffc6f7dc.tar.gz opie-2dc8c64cfa30a199e4ebd45618e726e9ffc6f7dc.tar.bz2 |
Move FileItem class from the header into an anonymous namespace
-rw-r--r-- | libopie/ofileselector.cc | 49 | ||||
-rw-r--r-- | libopie/ofileselector.h | 49 |
2 files changed, 49 insertions, 49 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index 3a11032..0a6e595 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -1,588 +1,635 @@ | |||
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 | #include <qstringlist.h> | 45 | #include <qstringlist.h> |
46 | #include <qmessagebox.h> | 46 | #include <qmessagebox.h> |
47 | 47 | ||
48 | #include <qpe/qpeapplication.h> | 48 | #include <qpe/qpeapplication.h> |
49 | #include <qpe/fileselector.h> | 49 | #include <qpe/fileselector.h> |
50 | #include <qpe/applnk.h> | 50 | #include <qpe/applnk.h> |
51 | #include <qpe/global.h> | 51 | #include <qpe/global.h> |
52 | #include <qpe/mimetype.h> | 52 | #include <qpe/mimetype.h> |
53 | #include <qpe/resource.h> | 53 | #include <qpe/resource.h> |
54 | #include <qpe/storage.h> | 54 | #include <qpe/storage.h> |
55 | 55 | ||
56 | #include <unistd.h> | 56 | #include <unistd.h> |
57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
58 | #include <sys/stat.h> | 58 | #include <sys/stat.h> |
59 | 59 | ||
60 | #include "ofileselector.h" | 60 | #include "ofileselector.h" |
61 | 61 | ||
62 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | 62 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; |
63 | 63 | ||
64 | namespace { | 64 | namespace { |
65 | 65 | ||
66 | int indexByString( const QComboBox *box, const QString &str ){ | 66 | int indexByString( const QComboBox *box, const QString &str ){ |
67 | int index= -1; | 67 | int index= -1; |
68 | for(int i= 0; i < box->count(); i++ ){ | 68 | for(int i= 0; i < box->count(); i++ ){ |
69 | if( str == box->text(i ) ){ | 69 | if( str == box->text(i ) ){ |
70 | index= i; | 70 | index= i; |
71 | break; | 71 | break; |
72 | } | 72 | } |
73 | } | 73 | } |
74 | return index; | 74 | return index; |
75 | } | 75 | } |
76 | 76 | class OFileSelectorItem : public QListViewItem { | |
77 | public: | ||
78 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | ||
79 | const QString &date, const QString &size, const QString &mDir, | ||
80 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { | ||
81 | setPixmap(0, pixmap ); | ||
82 | setText(1, path ); | ||
83 | setText(2, size ); | ||
84 | setText(3, date ); | ||
85 | //setText(4, mDir ); | ||
86 | m_dir = mDir; | ||
87 | dir = isDir; | ||
88 | mLocked = isLocked; | ||
89 | } | ||
90 | bool isLocked() const{ | ||
91 | return mLocked; | ||
92 | } | ||
93 | QString directory()const{ | ||
94 | return m_dir; | ||
95 | } | ||
96 | bool isDir()const{ | ||
97 | return dir; | ||
98 | } | ||
99 | QString path()const{ | ||
100 | return text(1 ); | ||
101 | } | ||
102 | QString key(int id, bool )const { | ||
103 | QString ke; | ||
104 | if( id == 0 || id == 1 ){ // name | ||
105 | if( dir ){ | ||
106 | ke.append("0" ); | ||
107 | ke.append( text(1) ); | ||
108 | }else{ | ||
109 | ke.append("1" ); | ||
110 | ke.append( text(1) ); | ||
111 | } | ||
112 | }else if( id == 2 ){ // size | ||
113 | return text(2); | ||
114 | }else if( id == 3 ){ // date | ||
115 | return text(3); | ||
116 | } | ||
117 | return ke; | ||
118 | }; | ||
119 | private: | ||
120 | bool mLocked:1; | ||
121 | bool dir:1; | ||
122 | QString m_dir; | ||
123 | }; | ||
77 | }; | 124 | }; |
78 | 125 | ||
79 | 126 | ||
80 | OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, | 127 | OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, |
81 | const QString &fileName, const QStringList &mimetypes ) : QWidget( wid ) | 128 | const QString &fileName, const QStringList &mimetypes ) : QWidget( wid ) |
82 | { | 129 | { |
83 | if(wid!=0) | 130 | if(wid!=0) |
84 | resize(wid->width(),wid->height()); | 131 | resize(wid->width(),wid->height()); |
85 | m_selector = selector; | 132 | m_selector = selector; |
86 | m_currentDir = dirName; | 133 | m_currentDir = dirName; |
87 | m_name = fileName; | 134 | m_name = fileName; |
88 | m_mimetypes = mimetypes; | 135 | m_mimetypes = mimetypes; |
89 | 136 | ||
90 | if( mimetypes.isEmpty() ) | 137 | if( mimetypes.isEmpty() ) |
91 | m_autoMime = true; | 138 | m_autoMime = true; |
92 | 139 | ||
93 | qWarning("OFileSelector mimetypes %s", mimetypes.join(" ").latin1() ); | 140 | qWarning("OFileSelector mimetypes %s", mimetypes.join(" ").latin1() ); |
94 | m_mode = mode; | 141 | m_mode = mode; |
95 | m_shTool = true; | 142 | m_shTool = true; |
96 | m_shPerm = true; | 143 | m_shPerm = true; |
97 | m_shLne = true; | 144 | m_shLne = true; |
98 | m_shChooser = true; | 145 | m_shChooser = true; |
99 | m_shYesNo = true; | 146 | m_shYesNo = true; |
100 | 147 | ||
101 | // for FILESELECTOR only view is interesting | 148 | // for FILESELECTOR only view is interesting |
102 | m_location = 0; | 149 | m_location = 0; |
103 | m_homeButton = 0; | 150 | m_homeButton = 0; |
104 | m_docButton = 0; | 151 | m_docButton = 0; |
105 | m_hideButton = 0; | 152 | m_hideButton = 0; |
106 | m_ok = 0; | 153 | m_ok = 0; |
107 | m_cancel = 0; | 154 | m_cancel = 0; |
108 | m_reread = 0; | 155 | m_reread = 0; |
109 | m_up = 0; | 156 | m_up = 0; |
110 | m_View = 0; | 157 | m_View = 0; |
111 | m_select = 0; | 158 | m_select = 0; |
112 | m_stack = 0; | 159 | m_stack = 0; |
113 | 160 | ||
114 | m_select = 0; | 161 | m_select = 0; |
115 | m_stack = 0; | 162 | m_stack = 0; |
116 | m_lay = 0; | 163 | m_lay = 0; |
117 | m_boxToolbar = 0; | 164 | m_boxToolbar = 0; |
118 | m_boxOk = 0; | 165 | m_boxOk = 0; |
119 | m_edit = 0; | 166 | m_edit = 0; |
120 | 167 | ||
121 | m_fnLabel = 0; | 168 | m_fnLabel = 0; |
122 | m_checkPerm = 0; | 169 | m_checkPerm = 0; |
123 | m_mimeCheck = 0; | 170 | m_mimeCheck = 0; |
124 | m_viewCheck = 0; | 171 | m_viewCheck = 0; |
125 | 172 | ||
126 | m_pseudo = 0; | 173 | m_pseudo = 0; |
127 | m_pseudoLayout = 0; | 174 | m_pseudoLayout = 0; |
128 | 175 | ||
129 | m_dir = true; | 176 | m_dir = true; |
130 | m_files = true; | 177 | m_files = true; |
131 | m_custom = 0; | 178 | m_custom = 0; |
132 | m_showPopup = true; | 179 | m_showPopup = true; |
133 | 180 | ||
134 | if(m_pixmaps == 0 ) // init the pixmaps | 181 | if(m_pixmaps == 0 ) // init the pixmaps |
135 | initPics(); | 182 | initPics(); |
136 | 183 | ||
137 | m_lay = new QVBoxLayout(this); | 184 | m_lay = new QVBoxLayout(this); |
138 | init(); | 185 | init(); |
139 | m_edit->setText( fileName ); | 186 | m_edit->setText( fileName ); |
140 | } | 187 | } |
141 | 188 | ||
142 | void OFileSelector::initPics() | 189 | void OFileSelector::initPics() |
143 | { | 190 | { |
144 | qWarning("init pics" ); | 191 | qWarning("init pics" ); |
145 | m_pixmaps = new QMap<QString,QPixmap>; | 192 | m_pixmaps = new QMap<QString,QPixmap>; |
146 | QPixmap pm = Resource::loadPixmap( "folder" ); | 193 | QPixmap pm = Resource::loadPixmap( "folder" ); |
147 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 194 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
148 | QPainter painter( &pm ); | 195 | QPainter painter( &pm ); |
149 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 196 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
150 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 197 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
151 | m_pixmaps->insert("dirsymlink", pm ); | 198 | m_pixmaps->insert("dirsymlink", pm ); |
152 | 199 | ||
153 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | 200 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); |
154 | QPainter pen(&pm2 ); | 201 | QPainter pen(&pm2 ); |
155 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | 202 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); |
156 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | 203 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); |
157 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 204 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
158 | 205 | ||
159 | } | 206 | } |
160 | 207 | ||
161 | // let's initialize the gui | 208 | // let's initialize the gui |
162 | /** | 209 | /** |
163 | -------------------- | 210 | -------------------- |
164 | | cmbBox Button | | 211 | | cmbBox Button | |
165 | -------------------- | 212 | -------------------- |
166 | | FileSlector | | 213 | | FileSlector | |
167 | | or | | 214 | | or | |
168 | | OSelector | | 215 | | OSelector | |
169 | | | | 216 | | | |
170 | | | | 217 | | | |
171 | ____________________ | 218 | ____________________ |
172 | | LineEdit | | 219 | | LineEdit | |
173 | ____________________ | 220 | ____________________ |
174 | | Permission Bar | | 221 | | Permission Bar | |
175 | ____________________ | 222 | ____________________ |
176 | | ViewChoose | | 223 | | ViewChoose | |
177 | ____________________ | 224 | ____________________ |
178 | | Save Cancel| | 225 | | Save Cancel| |
179 | ____________________ | 226 | ____________________ |
180 | */ | 227 | */ |
181 | void OFileSelector::delItems() | 228 | void OFileSelector::delItems() |
182 | { | 229 | { |
183 | QLayoutIterator it = m_lay->iterator(); | 230 | QLayoutIterator it = m_lay->iterator(); |
184 | while ( it.current() != 0 ){ | 231 | while ( it.current() != 0 ){ |
185 | it.deleteCurrent(); | 232 | it.deleteCurrent(); |
186 | } | 233 | } |
187 | } | 234 | } |
188 | 235 | ||
189 | void OFileSelector::init() | 236 | void OFileSelector::init() |
190 | { | 237 | { |
191 | // qDebug("init"); | 238 | // qDebug("init"); |
192 | m_stack = new QWidgetStack(this, "wstack" ); | 239 | m_stack = new QWidgetStack(this, "wstack" ); |
193 | if( m_selector == NORMAL ){ | 240 | if( m_selector == NORMAL ){ |
194 | QString currMime; | 241 | QString currMime; |
195 | if( m_mimeCheck != 0 ) | 242 | if( m_mimeCheck != 0 ) |
196 | currMime = m_mimeCheck->currentText(); | 243 | currMime = m_mimeCheck->currentText(); |
197 | updateMimes(); | 244 | updateMimes(); |
198 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , | 245 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , |
199 | m_stack, "fileselector", FALSE, FALSE ); | 246 | m_stack, "fileselector", FALSE, FALSE ); |
200 | m_stack->addWidget(m_select, NORMAL ); | 247 | m_stack->addWidget(m_select, NORMAL ); |
201 | m_lay->addWidget(m_stack ); | 248 | m_lay->addWidget(m_stack ); |
202 | m_stack->raiseWidget(NORMAL ); | 249 | m_stack->raiseWidget(NORMAL ); |
203 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), | 250 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), |
204 | this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); | 251 | this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); |
205 | m_pseudoLayout = 0l; | 252 | m_pseudoLayout = 0l; |
206 | 253 | ||
207 | } else { | 254 | } else { |
208 | initializeListView(); | 255 | initializeListView(); |
209 | } | 256 | } |
210 | if(m_shLne ){ | 257 | if(m_shLne ){ |
211 | initializeName(); | 258 | initializeName(); |
212 | } | 259 | } |
213 | if(m_shPerm ){ | 260 | if(m_shPerm ){ |
214 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); | 261 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); |
215 | m_checkPerm->setChecked( false ); | 262 | m_checkPerm->setChecked( false ); |
216 | m_lay->addWidget(m_checkPerm ); | 263 | m_lay->addWidget(m_checkPerm ); |
217 | } | 264 | } |
218 | if( m_shChooser ) | 265 | if( m_shChooser ) |
219 | initializeChooser(); | 266 | initializeChooser(); |
220 | if(m_shYesNo ) | 267 | if(m_shYesNo ) |
221 | initializeYes(); | 268 | initializeYes(); |
222 | 269 | ||
223 | // m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, requestedMimeTypesList.first()) ); | 270 | // m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, requestedMimeTypesList.first()) ); |
224 | // reparse(); | 271 | // reparse(); |
225 | 272 | ||
226 | } | 273 | } |
227 | 274 | ||
228 | void OFileSelector::setYesCancelVisible( bool show ) | 275 | void OFileSelector::setYesCancelVisible( bool show ) |
229 | { | 276 | { |
230 | if ( show == m_shYesNo ) | 277 | if ( show == m_shYesNo ) |
231 | return; | 278 | return; |
232 | m_shYesNo = show; | 279 | m_shYesNo = show; |
233 | if( !show ){ | 280 | if( !show ){ |
234 | delete m_ok; | 281 | delete m_ok; |
235 | delete m_cancel; | 282 | delete m_cancel; |
236 | m_ok = 0; | 283 | m_ok = 0; |
237 | m_cancel = 0; | 284 | m_cancel = 0; |
238 | // delete m_boxOk; all ready deleted in delItems | 285 | // delete m_boxOk; all ready deleted in delItems |
239 | } | 286 | } |
240 | updateLay(); // recreate it and save the other states | 287 | updateLay(); // recreate it and save the other states |
241 | } | 288 | } |
242 | 289 | ||
243 | void OFileSelector::setToolbarVisible( bool show ) | 290 | void OFileSelector::setToolbarVisible( bool show ) |
244 | { | 291 | { |
245 | if ( m_shTool == show ) | 292 | if ( m_shTool == show ) |
246 | return; | 293 | return; |
247 | if(!m_shTool ){ | 294 | if(!m_shTool ){ |
248 | delete m_boxToolbar; | 295 | delete m_boxToolbar; |
249 | delete m_homeButton; | 296 | delete m_homeButton; |
250 | delete m_docButton; | 297 | delete m_docButton; |
251 | delete m_location; | 298 | delete m_location; |
252 | delete m_up; | 299 | delete m_up; |
253 | m_boxToolbar = 0; | 300 | m_boxToolbar = 0; |
254 | m_homeButton = 0; | 301 | m_homeButton = 0; |
255 | m_docButton = 0; | 302 | m_docButton = 0; |
256 | m_location = 0; | 303 | m_location = 0; |
257 | m_up = 0; | 304 | m_up = 0; |
258 | }; | 305 | }; |
259 | updateLay();// overkill fix it | 306 | updateLay();// overkill fix it |
260 | } | 307 | } |
261 | 308 | ||
262 | void OFileSelector::setPermissionBarVisible( bool show ) | 309 | void OFileSelector::setPermissionBarVisible( bool show ) |
263 | { | 310 | { |
264 | if( show == m_shPerm ) | 311 | if( show == m_shPerm ) |
265 | return; | 312 | return; |
266 | 313 | ||
267 | m_shPerm = show; | 314 | m_shPerm = show; |
268 | 315 | ||
269 | updateLay(); | 316 | updateLay(); |
270 | } | 317 | } |
271 | 318 | ||
272 | void OFileSelector::setLineEditVisible( bool show ) | 319 | void OFileSelector::setLineEditVisible( bool show ) |
273 | { | 320 | { |
274 | if( show == m_shLne ) | 321 | if( show == m_shLne ) |
275 | return; | 322 | return; |
276 | 323 | ||
277 | m_shLne = show; | 324 | m_shLne = show; |
278 | if( !show ){ | 325 | if( !show ){ |
279 | delete m_edit; | 326 | delete m_edit; |
280 | delete m_fnLabel; | 327 | delete m_fnLabel; |
281 | m_edit = 0; | 328 | m_edit = 0; |
282 | m_fnLabel = 0; | 329 | m_fnLabel = 0; |
283 | //delete m_boxName; will be deleted | 330 | //delete m_boxName; will be deleted |
284 | } | 331 | } |
285 | updateLay(); | 332 | updateLay(); |
286 | } | 333 | } |
287 | 334 | ||
288 | void OFileSelector::setChooserVisible( bool show ) | 335 | void OFileSelector::setChooserVisible( bool show ) |
289 | { | 336 | { |
290 | if( show = m_shChooser ) | 337 | if( show = m_shChooser ) |
291 | return; | 338 | return; |
292 | m_shChooser = show; | 339 | m_shChooser = show; |
293 | if( !show ){ | 340 | if( !show ){ |
294 | delete m_mimeCheck; | 341 | delete m_mimeCheck; |
295 | delete m_viewCheck; | 342 | delete m_viewCheck; |
296 | m_mimeCheck = 0; | 343 | m_mimeCheck = 0; |
297 | m_viewCheck = 0; | 344 | m_viewCheck = 0; |
298 | } | 345 | } |
299 | updateLay(); | 346 | updateLay(); |
300 | } | 347 | } |
301 | 348 | ||
302 | QCheckBox* OFileSelector::permissionCheckbox( ) | 349 | QCheckBox* OFileSelector::permissionCheckbox( ) |
303 | { | 350 | { |
304 | return m_checkPerm; | 351 | return m_checkPerm; |
305 | } | 352 | } |
306 | 353 | ||
307 | void OFileSelector::setCaseSensetive( bool caSe ) | 354 | void OFileSelector::setCaseSensetive( bool caSe ) |
308 | { | 355 | { |
309 | m_case = caSe; | 356 | m_case = caSe; |
310 | reparse(); | 357 | reparse(); |
311 | } | 358 | } |
312 | 359 | ||
313 | void OFileSelector::setShowFiles(bool files ){ | 360 | void OFileSelector::setShowFiles(bool files ){ |
314 | m_files = files; | 361 | m_files = files; |
315 | reparse(); | 362 | reparse(); |
316 | } | 363 | } |
317 | 364 | ||
318 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) | 365 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) |
319 | { | 366 | { |
320 | //delete oldpopup; | 367 | //delete oldpopup; |
321 | m_custom = pop; | 368 | m_custom = pop; |
322 | } | 369 | } |
323 | 370 | ||
324 | bool OFileSelector::setPermission( ) const | 371 | bool OFileSelector::setPermission( ) const |
325 | { | 372 | { |
326 | if( m_checkPerm == 0 ) | 373 | if( m_checkPerm == 0 ) |
327 | return false; | 374 | return false; |
328 | else | 375 | else |
329 | return m_checkPerm->isChecked(); | 376 | return m_checkPerm->isChecked(); |
330 | } | 377 | } |
331 | 378 | ||
332 | void OFileSelector::setPermissionChecked( bool check ) | 379 | void OFileSelector::setPermissionChecked( bool check ) |
333 | { | 380 | { |
334 | if( m_checkPerm == 0 ) | 381 | if( m_checkPerm == 0 ) |
335 | return; | 382 | return; |
336 | m_checkPerm->setChecked( check ); | 383 | m_checkPerm->setChecked( check ); |
337 | } | 384 | } |
338 | 385 | ||
339 | QString OFileSelector::selectedName( )const | 386 | QString OFileSelector::selectedName( )const |
340 | { | 387 | { |
341 | QString string; | 388 | QString string; |
342 | if( m_selector == NORMAL ){ | 389 | if( m_selector == NORMAL ){ |
343 | const DocLnk *lnk = m_select->selected(); | 390 | const DocLnk *lnk = m_select->selected(); |
344 | string = lnk->file(); | 391 | string = lnk->file(); |
345 | }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 392 | }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
346 | QListViewItem *item = m_View->currentItem(); | 393 | QListViewItem *item = m_View->currentItem(); |
347 | if(item != 0 ){ | 394 | if(item != 0 ){ |
348 | string = m_currentDir + "/" + item->text( 1 ); | 395 | string = m_currentDir + "/" + item->text( 1 ); |
349 | } | 396 | } |
350 | } | 397 | } |
351 | return string; | 398 | return string; |
352 | } | 399 | } |
353 | 400 | ||
354 | QStringList OFileSelector::selectedNames()const | 401 | QStringList OFileSelector::selectedNames()const |
355 | { | 402 | { |
356 | QStringList list; | 403 | QStringList list; |
357 | return list; | 404 | return list; |
358 | } | 405 | } |
359 | 406 | ||
360 | DocLnk OFileSelector::selectedDocument( )const | 407 | DocLnk OFileSelector::selectedDocument( )const |
361 | { | 408 | { |
362 | DocLnk lnk; | 409 | DocLnk lnk; |
363 | return lnk; | 410 | return lnk; |
364 | } | 411 | } |
365 | void OFileSelector::updateLay() | 412 | void OFileSelector::updateLay() |
366 | { | 413 | { |
367 | /* if( m_shTool ) | 414 | /* if( m_shTool ) |
368 | // | 415 | // |
369 | else | 416 | else |
370 | // hide | 417 | // hide |
371 | */ | 418 | */ |
372 | // save the state | 419 | // save the state |
373 | bool check = false; | 420 | bool check = false; |
374 | if( m_checkPerm != 0 ) | 421 | if( m_checkPerm != 0 ) |
375 | check = m_checkPerm->isChecked(); | 422 | check = m_checkPerm->isChecked(); |
376 | QString text; | 423 | QString text; |
377 | 424 | ||
378 | if( m_edit != 0 ) | 425 | if( m_edit != 0 ) |
379 | text = m_edit->text(); | 426 | text = m_edit->text(); |
380 | // save current mimetype | 427 | // save current mimetype |
381 | 428 | ||
382 | delItems(); | 429 | delItems(); |
383 | delete m_checkPerm; | 430 | delete m_checkPerm; |
384 | m_checkPerm = 0; | 431 | m_checkPerm = 0; |
385 | delete m_edit; | 432 | delete m_edit; |
386 | m_edit = 0; | 433 | m_edit = 0; |
387 | delete m_fnLabel; | 434 | delete m_fnLabel; |
388 | m_fnLabel = 0; | 435 | m_fnLabel = 0; |
389 | delete m_ok; | 436 | delete m_ok; |
390 | m_ok = 0; | 437 | m_ok = 0; |
391 | delete m_cancel; | 438 | delete m_cancel; |
392 | m_cancel = 0; | 439 | m_cancel = 0; |
393 | delete m_mimeCheck; | 440 | delete m_mimeCheck; |
394 | m_mimeCheck = 0; | 441 | m_mimeCheck = 0; |
395 | delete m_viewCheck; | 442 | delete m_viewCheck; |
396 | m_viewCheck = 0; | 443 | m_viewCheck = 0; |
397 | delete m_select; // test | 444 | delete m_select; // test |
398 | delete m_stack; | 445 | delete m_stack; |
399 | //delete m_list; | 446 | //delete m_list; |
400 | init(); | 447 | init(); |
401 | if( m_shLne ) | 448 | if( m_shLne ) |
402 | m_edit->setText(text ); | 449 | m_edit->setText(text ); |
403 | if( m_shPerm ) | 450 | if( m_shPerm ) |
404 | m_checkPerm->setChecked(check ); | 451 | m_checkPerm->setChecked(check ); |
405 | } | 452 | } |
406 | 453 | ||
407 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve | 454 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve |
408 | // insert QListViewItems with the right options | 455 | // insert QListViewItems with the right options |
409 | bool OFileSelector::compliesMime(const QString &path, const QString &mime ) | 456 | bool OFileSelector::compliesMime(const QString &path, const QString &mime ) |
410 | { | 457 | { |
411 | if( mime == "All" ) | 458 | if( mime == "All" ) |
412 | return true; | 459 | return true; |
413 | MimeType type( path ); | 460 | MimeType type( path ); |
414 | if( type.id() == mime ) | 461 | if( type.id() == mime ) |
415 | return true; | 462 | return true; |
416 | return false; | 463 | return false; |
417 | } | 464 | } |
418 | 465 | ||
419 | void OFileSelector::reparse() | 466 | void OFileSelector::reparse() |
420 | { | 467 | { |
421 | qDebug("reparse"); | 468 | qDebug("reparse"); |
422 | if(m_View== 0 || m_selector == NORMAL) | 469 | if(m_View== 0 || m_selector == NORMAL) |
423 | return; | 470 | return; |
424 | m_View->clear(); | 471 | m_View->clear(); |
425 | QString currMime =m_mimeCheck->currentText(); | 472 | QString currMime =m_mimeCheck->currentText(); |
426 | // update the mimetype now | 473 | // update the mimetype now |
427 | if( m_autoMime ) { | 474 | if( m_autoMime ) { |
428 | QDir dir( m_currentDir ); | 475 | QDir dir( m_currentDir ); |
429 | m_mimetypes.clear(); | 476 | m_mimetypes.clear(); |
430 | m_mimeCheck->clear(); | 477 | m_mimeCheck->clear(); |
431 | dir.setFilter( QDir::Files | QDir::Readable ); | 478 | dir.setFilter( QDir::Files | QDir::Readable ); |
432 | dir.setSorting(QDir::Size ); | 479 | dir.setSorting(QDir::Size ); |
433 | const QFileInfoList *list = dir.entryInfoList(); | 480 | const QFileInfoList *list = dir.entryInfoList(); |
434 | QFileInfoListIterator it( *list ); | 481 | QFileInfoListIterator it( *list ); |
435 | QFileInfo *fi; | 482 | QFileInfo *fi; |
436 | while( (fi=it.current()) ){ | 483 | while( (fi=it.current()) ){ |
437 | if(fi->extension() == QString::fromLatin1("desktop") ){ | 484 | if(fi->extension() == QString::fromLatin1("desktop") ){ |
438 | ++it; | 485 | ++it; |
439 | continue; | 486 | continue; |
440 | } | 487 | } |
441 | MimeType type(fi->filePath() ); | 488 | MimeType type(fi->filePath() ); |
442 | if( !m_mimetypes.contains( type.id() ) ) | 489 | if( !m_mimetypes.contains( type.id() ) ) |
443 | m_mimetypes.append( type.id() ); | 490 | m_mimetypes.append( type.id() ); |
444 | 491 | ||
445 | ++it; | 492 | ++it; |
446 | } | 493 | } |
447 | m_mimetypes.prepend("All" ); | 494 | m_mimetypes.prepend("All" ); |
448 | m_mimeCheck->insertStringList(m_mimetypes ); | 495 | m_mimeCheck->insertStringList(m_mimetypes ); |
449 | // set it to the current mimetype | 496 | // set it to the current mimetype |
450 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); | 497 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); |
451 | }else{ | 498 | }else{ |
452 | m_mimeCheck->clear(); | 499 | m_mimeCheck->clear(); |
453 | m_mimeCheck->insertItem( m_mimetypes.join(";") ); | 500 | m_mimeCheck->insertItem( m_mimetypes.join(";") ); |
454 | } | 501 | } |
455 | 502 | ||
456 | QDir dir( m_currentDir ); | 503 | QDir dir( m_currentDir ); |
457 | //dir.setFilter(-1 ); | 504 | //dir.setFilter(-1 ); |
458 | int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; | 505 | int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; |
459 | if( m_case ) | 506 | if( m_case ) |
460 | sort = QDir::IgnoreCase; | 507 | sort = QDir::IgnoreCase; |
461 | dir.setSorting( sort ); | 508 | dir.setSorting( sort ); |
462 | 509 | ||
463 | int filter; | 510 | int filter; |
464 | /* if( m_dir && !m_files) | 511 | /* if( m_dir && !m_files) |
465 | filter |= QDir::Dirs; | 512 | filter |= QDir::Dirs; |
466 | else if( !m_dir && m_files ) | 513 | else if( !m_dir && m_files ) |
467 | filter |= QDir::Files; | 514 | filter |= QDir::Files; |
468 | else | 515 | else |
469 | filter |= QDir::All; | 516 | filter |= QDir::All; |
470 | */ | 517 | */ |
471 | if( m_selector == EXTENDED_ALL ) | 518 | if( m_selector == EXTENDED_ALL ) |
472 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 519 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
473 | else | 520 | else |
474 | filter = QDir::Files | QDir::Dirs | QDir::All; | 521 | filter = QDir::Files | QDir::Dirs | QDir::All; |
475 | dir.setFilter( filter ); | 522 | dir.setFilter( filter ); |
476 | qDebug("infoList"); | 523 | qDebug("infoList"); |
477 | const QFileInfoList *list = dir.entryInfoList(); | 524 | const QFileInfoList *list = dir.entryInfoList(); |
478 | QFileInfoListIterator it( *list ); | 525 | QFileInfoListIterator it( *list ); |
479 | QFileInfo *fi; | 526 | QFileInfo *fi; |
480 | while( (fi=it.current()) ){ | 527 | while( (fi=it.current()) ){ |
481 | if(fi->fileName() == ".." || fi->fileName() == "." ){ | 528 | if(fi->fileName() == ".." || fi->fileName() == "." ){ |
482 | ++it; | 529 | ++it; |
483 | continue; | 530 | continue; |
484 | } | 531 | } |
485 | // qWarning("Test: %s", fi->fileName().latin1() ); | 532 | // qWarning("Test: %s", fi->fileName().latin1() ); |
486 | if(fi->isSymLink() ){ | 533 | if(fi->isSymLink() ){ |
487 | // qWarning("Symlink %s", fi->fileName().latin1() ); | 534 | // qWarning("Symlink %s", fi->fileName().latin1() ); |
488 | QString file = fi->dirPath(true)+"/"+ fi->readLink(); | 535 | QString file = fi->dirPath(true)+"/"+ fi->readLink(); |
489 | // qWarning("File ->%s", file.latin1() ); | 536 | // qWarning("File ->%s", file.latin1() ); |
490 | for(int i=0; i<=4; i++ ){ // prepend from dos | 537 | for(int i=0; i<=4; i++ ){ // prepend from dos |
491 | QFileInfo info( file ); | 538 | QFileInfo info( file ); |
492 | if( !info.exists() ){ | 539 | if( !info.exists() ){ |
493 | // qWarning("does not exist" ); | 540 | // qWarning("does not exist" ); |
494 | addSymlink(currMime, fi, TRUE ); | 541 | addSymlink(currMime, fi, TRUE ); |
495 | break; | 542 | break; |
496 | }else if( info.isDir() ){ | 543 | }else if( info.isDir() ){ |
497 | // qWarning("isDir" ); | 544 | // qWarning("isDir" ); |
498 | addDir(currMime, fi, TRUE ); | 545 | addDir(currMime, fi, TRUE ); |
499 | break; | 546 | break; |
500 | }else if( info.isFile() ){ | 547 | }else if( info.isFile() ){ |
501 | // qWarning("isFile" ); | 548 | // qWarning("isFile" ); |
502 | addFile(currMime, fi, TRUE ); | 549 | addFile(currMime, fi, TRUE ); |
503 | break; | 550 | break; |
504 | }else if( info.isSymLink() ){ | 551 | }else if( info.isSymLink() ){ |
505 | file = info.dirPath(true)+ "/"+ info.readLink(); | 552 | file = info.dirPath(true)+ "/"+ info.readLink(); |
506 | // qWarning("isSymlink again %s", file.latin1() ); | 553 | // qWarning("isSymlink again %s", file.latin1() ); |
507 | }else if( i == 4 ){ // just insert it and have the symlink symbol | 554 | }else if( i == 4 ){ // just insert it and have the symlink symbol |
508 | addSymlink(currMime, fi ); | 555 | addSymlink(currMime, fi ); |
509 | // qWarning("level too deep" ); | 556 | // qWarning("level too deep" ); |
510 | } | 557 | } |
511 | } | 558 | } |
512 | }else if( fi->isDir() ){ | 559 | }else if( fi->isDir() ){ |
513 | addDir(currMime, fi ); | 560 | addDir(currMime, fi ); |
514 | }else if( fi->isFile() ) { // file ? | 561 | }else if( fi->isFile() ) { // file ? |
515 | addFile(currMime, fi ); | 562 | addFile(currMime, fi ); |
516 | } | 563 | } |
517 | ++it; | 564 | ++it; |
518 | } | 565 | } |
519 | m_View->sort(); | 566 | m_View->sort(); |
520 | // m_View->ensureItemVisible(); | 567 | // m_View->ensureItemVisible(); |
521 | } | 568 | } |
522 | 569 | ||
523 | QString OFileSelector::directory()const | 570 | QString OFileSelector::directory()const |
524 | { | 571 | { |
525 | QDir d( m_currentDir); | 572 | QDir d( m_currentDir); |
526 | return d.absPath(); | 573 | return d.absPath(); |
527 | } | 574 | } |
528 | 575 | ||
529 | int OFileSelector::fileCount() | 576 | int OFileSelector::fileCount() |
530 | { | 577 | { |
531 | return 0; | 578 | return 0; |
532 | } | 579 | } |
533 | 580 | ||
534 | void OFileSelector::slotOk( ) | 581 | void OFileSelector::slotOk( ) |
535 | { | 582 | { |
536 | emit ok(); | 583 | emit ok(); |
537 | } | 584 | } |
538 | 585 | ||
539 | void OFileSelector::slotCancel( ) | 586 | void OFileSelector::slotCancel( ) |
540 | { | 587 | { |
541 | emit cancel(); | 588 | emit cancel(); |
542 | } | 589 | } |
543 | 590 | ||
544 | void OFileSelector::initializeName() | 591 | void OFileSelector::initializeName() |
545 | { | 592 | { |
546 | m_boxName = new QHBoxLayout(this ); | 593 | m_boxName = new QHBoxLayout(this ); |
547 | m_edit = new QLineEdit(this ); | 594 | m_edit = new QLineEdit(this ); |
548 | m_fnLabel = new QLabel(this ); | 595 | m_fnLabel = new QLabel(this ); |
549 | m_fnLabel->setText(tr("Name:") ); | 596 | m_fnLabel->setText(tr("Name:") ); |
550 | m_boxName->addWidget(m_fnLabel ); | 597 | m_boxName->addWidget(m_fnLabel ); |
551 | m_boxName->insertSpacing(1, 8 ); | 598 | m_boxName->insertSpacing(1, 8 ); |
552 | m_boxName->addWidget(m_edit, 100 ); | 599 | m_boxName->addWidget(m_edit, 100 ); |
553 | 600 | ||
554 | m_lay->addLayout(m_boxName); | 601 | m_lay->addLayout(m_boxName); |
555 | } | 602 | } |
556 | 603 | ||
557 | void OFileSelector::initializeYes() | 604 | void OFileSelector::initializeYes() |
558 | { | 605 | { |
559 | m_ok = new QPushButton("&Save", this, "save" ); | 606 | m_ok = new QPushButton("&Save", this, "save" ); |
560 | m_cancel = new QPushButton("C&ancel", this, "cancel" ); | 607 | m_cancel = new QPushButton("C&ancel", this, "cancel" ); |
561 | m_boxOk = new QHBoxLayout(this ); | 608 | m_boxOk = new QHBoxLayout(this ); |
562 | m_boxOk->addWidget( m_ok, Qt::AlignHCenter ); | 609 | m_boxOk->addWidget( m_ok, Qt::AlignHCenter ); |
563 | m_boxOk->insertSpacing(1, 8 ); | 610 | m_boxOk->insertSpacing(1, 8 ); |
564 | m_boxOk->addWidget( m_cancel, Qt::AlignHCenter); | 611 | m_boxOk->addWidget( m_cancel, Qt::AlignHCenter); |
565 | m_lay->addLayout(m_boxOk ); | 612 | m_lay->addLayout(m_boxOk ); |
566 | connect(m_ok, SIGNAL(clicked() ), | 613 | connect(m_ok, SIGNAL(clicked() ), |
567 | this, SLOT(slotOk() ) ); | 614 | this, SLOT(slotOk() ) ); |
568 | connect(m_cancel, SIGNAL(clicked() ), | 615 | connect(m_cancel, SIGNAL(clicked() ), |
569 | this, SLOT(slotCancel() ) ); | 616 | this, SLOT(slotCancel() ) ); |
570 | 617 | ||
571 | } | 618 | } |
572 | 619 | ||
573 | void OFileSelector::initializeChooser() | 620 | void OFileSelector::initializeChooser() |
574 | { | 621 | { |
575 | m_boxView = new QHBoxLayout(this ); | 622 | m_boxView = new QHBoxLayout(this ); |
576 | 623 | ||
577 | m_mimeCheck = new QComboBox(this, "mime check"); | 624 | m_mimeCheck = new QComboBox(this, "mime check"); |
578 | m_viewCheck = new QComboBox(this, "view check"); | 625 | m_viewCheck = new QComboBox(this, "view check"); |
579 | m_boxView->addWidget(m_viewCheck, 0 ); | 626 | m_boxView->addWidget(m_viewCheck, 0 ); |
580 | m_boxView->insertSpacing(2, 8 ); | 627 | m_boxView->insertSpacing(2, 8 ); |
581 | m_boxView->addWidget(m_mimeCheck, 0 ); | 628 | m_boxView->addWidget(m_mimeCheck, 0 ); |
582 | m_lay->addLayout(m_boxView ); | 629 | m_lay->addLayout(m_boxView ); |
583 | m_lay->insertSpacing( 4, 8); | 630 | m_lay->insertSpacing( 4, 8); |
584 | 631 | ||
585 | m_viewCheck->insertItem(tr("Documents") ); | 632 | m_viewCheck->insertItem(tr("Documents") ); |
586 | m_viewCheck->insertItem(tr("Files") ); | 633 | m_viewCheck->insertItem(tr("Files") ); |
587 | m_viewCheck->insertItem(tr("All Files") ); | 634 | m_viewCheck->insertItem(tr("All Files") ); |
588 | 635 | ||
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index babe09f..8173d76 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h | |||
@@ -1,281 +1,234 @@ | |||
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 | |
68 | public: | ||
69 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | ||
70 | const QString &date, const QString &size, const QString &mDir, | ||
71 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { | ||
72 | setPixmap(0, pixmap ); | ||
73 | setText(1, path ); | ||
74 | setText(2, size ); | ||
75 | setText(3, date ); | ||
76 | //setText(4, mDir ); | ||
77 | m_dir = mDir; | ||
78 | dir = isDir; | ||
79 | mLocked = isLocked; | ||
80 | } | ||
81 | bool isLocked() const{ | ||
82 | return mLocked; | ||
83 | } | ||
84 | QString directory()const{ | ||
85 | return m_dir; | ||
86 | } | ||
87 | bool isDir()const{ | ||
88 | return dir; | ||
89 | } | ||
90 | QString path()const{ | ||
91 | return text(1 ); | ||
92 | } | ||
93 | QString key(int id, bool )const { | ||
94 | QString ke; | ||
95 | if( id == 0 || id == 1 ){ // name | ||
96 | if( dir ){ | ||
97 | ke.append("0" ); | ||
98 | ke.append( text(1) ); | ||
99 | }else{ | ||
100 | ke.append("1" ); | ||
101 | ke.append( text(1) ); | ||
102 | } | ||
103 | }else if( id == 2 ){ // size | ||
104 | return text(2); | ||
105 | }else if( id == 3 ){ // date | ||
106 | return text(3); | ||
107 | } | ||
108 | return ke; | ||
109 | }; | ||
110 | private: | ||
111 | bool mLocked:1; | ||
112 | bool dir:1; | ||
113 | QString m_dir; | ||
114 | }; | ||
115 | 68 | ||
116 | class OFileSelector : public QWidget { | 69 | class OFileSelector : public QWidget { |
117 | Q_OBJECT | 70 | Q_OBJECT |
118 | public: | 71 | public: |
119 | enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 }; | 72 | enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 }; |
120 | enum Selector{NORMAL=1, EXTENDED = 2, EXTENDED_ALL =4 }; | 73 | enum Selector{NORMAL=1, EXTENDED = 2, EXTENDED_ALL =4 }; |
121 | enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; | 74 | 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() ); | 75 | OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const QStringList &mimetypes = QStringList() ); |
123 | ~OFileSelector() {}; | 76 | ~OFileSelector() {}; |
124 | bool isToolbarVisible() const { return m_shTool; }; | 77 | bool isToolbarVisible() const { return m_shTool; }; |
125 | bool isPermissionBarVisible() const { return m_shPerm; }; | 78 | bool isPermissionBarVisible() const { return m_shPerm; }; |
126 | bool isLineEditVisible()const { return m_shLne; }; | 79 | bool isLineEditVisible()const { return m_shLne; }; |
127 | bool isChooserVisible( )const { return m_shChooser; }; | 80 | bool isChooserVisible( )const { return m_shChooser; }; |
128 | bool isYesCancelVisible()const { return m_shYesNo; }; | 81 | bool isYesCancelVisible()const { return m_shYesNo; }; |
129 | void setYesCancelVisible( bool show ); | 82 | void setYesCancelVisible( bool show ); |
130 | void setToolbarVisible( bool show ); | 83 | void setToolbarVisible( bool show ); |
131 | void setPermissionBarVisible( bool show ); | 84 | void setPermissionBarVisible( bool show ); |
132 | void setLineEditVisible(bool show) ; | 85 | void setLineEditVisible(bool show) ; |
133 | void setChooserVisible( bool chooser ); | 86 | void setChooserVisible( bool chooser ); |
134 | 87 | ||
135 | QCheckBox* permissionCheckbox(); | 88 | QCheckBox* permissionCheckbox(); |
136 | bool setPermission() const; | 89 | bool setPermission() const; |
137 | void setPermissionChecked( bool check ); | 90 | void setPermissionChecked( bool check ); |
138 | 91 | ||
139 | void setMode( int ); | 92 | void setMode( int ); |
140 | 93 | ||
141 | bool showDirs()const { return m_dir; } | 94 | bool showDirs()const { return m_dir; } |
142 | void setShowDirs(bool ); | 95 | void setShowDirs(bool ); |
143 | 96 | ||
144 | const QListView* listView() { return m_View; }; | 97 | const QListView* listView() { return m_View; }; |
145 | 98 | ||
146 | bool isCaseSensetive()const { return m_case; } | 99 | bool isCaseSensetive()const { return m_case; } |
147 | void setCaseSensetive(bool caSe ); | 100 | void setCaseSensetive(bool caSe ); |
148 | 101 | ||
149 | bool showFiles()const { return m_files; }; | 102 | bool showFiles()const { return m_files; }; |
150 | void setShowFiles(bool ); | 103 | void setShowFiles(bool ); |
151 | bool cd(const QString &path ); | 104 | bool cd(const QString &path ); |
152 | 105 | ||
153 | 106 | ||
154 | int mode()const { return m_mode; }; | 107 | int mode()const { return m_mode; }; |
155 | int selector()const { return m_selector; }; | 108 | int selector()const { return m_selector; }; |
156 | void setSelector( int ); | 109 | void setSelector( int ); |
157 | 110 | ||
158 | bool showPopup()const { return m_showPopup; }; | 111 | bool showPopup()const { return m_showPopup; }; |
159 | void setShowPopup( bool pop ) { m_showPopup = pop; }; | 112 | void setShowPopup( bool pop ) { m_showPopup = pop; }; |
160 | void setPopupMenu( QPopupMenu * ); | 113 | void setPopupMenu( QPopupMenu * ); |
161 | 114 | ||
162 | void updateLay(); | 115 | void updateLay(); |
163 | 116 | ||
164 | void reparse(); // re reads the dir | 117 | void reparse(); // re reads the dir |
165 | 118 | ||
166 | QString selectedName( )const; | 119 | QString selectedName( )const; |
167 | QStringList selectedNames()const; | 120 | QStringList selectedNames()const; |
168 | 121 | ||
169 | QString selectedPath() const; | 122 | QString selectedPath() const; |
170 | QStringList selectedPaths() const; | 123 | QStringList selectedPaths() const; |
171 | 124 | ||
172 | QString directory()const; | 125 | QString directory()const; |
173 | int fileCount(); | 126 | int fileCount(); |
174 | 127 | ||
175 | /* the user needs to delete it */ | 128 | /* the user needs to delete it */ |
176 | DocLnk selectedDocument()const; | 129 | DocLnk selectedDocument()const; |
177 | /* the user needs to delete it */ | 130 | /* the user needs to delete it */ |
178 | QValueList<DocLnk> selectedDocuments()const; | 131 | QValueList<DocLnk> selectedDocuments()const; |
179 | 132 | ||
180 | signals: | 133 | signals: |
181 | void fileSelected( const DocLnk & ); | 134 | void fileSelected( const DocLnk & ); |
182 | void fileSelected( const QString & ); | 135 | void fileSelected( const QString & ); |
183 | void dirSelected(const QString &dir ); | 136 | void dirSelected(const QString &dir ); |
184 | void closeMe(); | 137 | void closeMe(); |
185 | void ok(); | 138 | void ok(); |
186 | void cancel(); | 139 | void cancel(); |
187 | 140 | ||
188 | protected slots: | 141 | protected slots: |
189 | void slotOk(); | 142 | void slotOk(); |
190 | void slotCancel(); | 143 | void slotCancel(); |
191 | void slotViewCheck(const QString & ); | 144 | void slotViewCheck(const QString & ); |
192 | void slotMimeCheck(const QString & ); | 145 | void slotMimeCheck(const QString & ); |
193 | void locationComboActivated(const QString & ); | 146 | void locationComboActivated(const QString & ); |
194 | void insertLocationPath(const QString &, int); | 147 | void insertLocationPath(const QString &, int); |
195 | void locationComboChanged(); | 148 | void locationComboChanged(); |
196 | protected: | 149 | protected: |
197 | void init(); | 150 | void init(); |
198 | void updateMimes(); | 151 | void updateMimes(); |
199 | 152 | ||
200 | protected: | 153 | protected: |
201 | 154 | ||
202 | private: | 155 | private: |
203 | int m_mode, m_selector; | 156 | int m_mode, m_selector; |
204 | QComboBox *m_location, *m_mimeCheck, *m_viewCheck; | 157 | QComboBox *m_location, *m_mimeCheck, *m_viewCheck; |
205 | QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; | 158 | QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; |
206 | QPushButton *m_reread, *m_up; | 159 | QPushButton *m_reread, *m_up; |
207 | QListView *m_View; | 160 | QListView *m_View; |
208 | QCheckBox *m_checkPerm; | 161 | QCheckBox *m_checkPerm; |
209 | QWidget *m_pseudo; | 162 | QWidget *m_pseudo; |
210 | QVBoxLayout *m_pseudoLayout; | 163 | QVBoxLayout *m_pseudoLayout; |
211 | 164 | ||
212 | QString m_currentDir; | 165 | QString m_currentDir; |
213 | QString m_name; | 166 | QString m_name; |
214 | QStringList m_mimetypes, requestedMimeTypesList; | 167 | QStringList m_mimetypes, requestedMimeTypesList; |
215 | 168 | ||
216 | FileSelector *m_select; | 169 | FileSelector *m_select; |
217 | QWidgetStack *m_stack; | 170 | QWidgetStack *m_stack; |
218 | QVBoxLayout *m_lay; | 171 | QVBoxLayout *m_lay; |
219 | QGridLayout *m_Oselector; | 172 | QGridLayout *m_Oselector; |
220 | 173 | ||
221 | QHBoxLayout *m_boxToolbar; | 174 | QHBoxLayout *m_boxToolbar; |
222 | QHBoxLayout *m_boxOk; | 175 | QHBoxLayout *m_boxOk; |
223 | QHBoxLayout *m_boxName; | 176 | QHBoxLayout *m_boxName; |
224 | QHBoxLayout *m_boxView; | 177 | QHBoxLayout *m_boxView; |
225 | 178 | ||
226 | QPopupMenu *m_custom; | 179 | QPopupMenu *m_custom; |
227 | 180 | ||
228 | QLineEdit *m_edit; | 181 | QLineEdit *m_edit; |
229 | QLabel *m_fnLabel; | 182 | QLabel *m_fnLabel; |
230 | bool m_shTool:1; | 183 | bool m_shTool:1; |
231 | bool m_shPerm:1; | 184 | bool m_shPerm:1; |
232 | bool m_shLne:1; | 185 | bool m_shLne:1; |
233 | bool m_shChooser:1; | 186 | bool m_shChooser:1; |
234 | bool m_shYesNo:1; | 187 | bool m_shYesNo:1; |
235 | bool m_boCheckPerm:1; | 188 | bool m_boCheckPerm:1; |
236 | bool m_autoMime:1; | 189 | bool m_autoMime:1; |
237 | bool m_case:1; | 190 | bool m_case:1; |
238 | bool m_dir:1; | 191 | bool m_dir:1; |
239 | bool m_files:1; | 192 | bool m_files:1; |
240 | bool m_showPopup:1; | 193 | bool m_showPopup:1; |
241 | 194 | ||
242 | // implementation todo | 195 | // implementation todo |
243 | virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); | 196 | virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); |
244 | virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); | 197 | virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); |
245 | virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){}; | 198 | virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){}; |
246 | void delItems(); | 199 | void delItems(); |
247 | void initializeName(); | 200 | void initializeName(); |
248 | void initializeYes(); | 201 | void initializeYes(); |
249 | void initializeChooser(); | 202 | void initializeChooser(); |
250 | void initializeListView(); | 203 | void initializeListView(); |
251 | void initPics(); | 204 | void initPics(); |
252 | bool compliesMime(const QString &path, const QString &mime); | 205 | bool compliesMime(const QString &path, const QString &mime); |
253 | 206 | ||
254 | class OFileSelectorPrivate; | 207 | class OFileSelectorPrivate; |
255 | OFileSelectorPrivate *d; | 208 | OFileSelectorPrivate *d; |
256 | static QMap<QString,QPixmap> *m_pixmaps; | 209 | static QMap<QString,QPixmap> *m_pixmaps; |
257 | 210 | ||
258 | private slots: | 211 | private slots: |
259 | void slotFileSelected(const QString & ); // not really meant to be a slot | 212 | void slotFileSelected(const QString & ); // not really meant to be a slot |
260 | void slotFileBridgeSelected( const DocLnk & ); | 213 | void slotFileBridgeSelected( const DocLnk & ); |
261 | virtual void slotSelectionChanged(); | 214 | virtual void slotSelectionChanged(); |
262 | virtual void slotCurrentChanged(QListViewItem* ); | 215 | virtual void slotCurrentChanged(QListViewItem* ); |
263 | virtual void slotClicked( int, QListViewItem *item, const QPoint &, int); | 216 | virtual void slotClicked( int, QListViewItem *item, const QPoint &, int); |
264 | virtual void slotRightButton(int, QListViewItem *, const QPoint &, int ); | 217 | virtual void slotRightButton(int, QListViewItem *, const QPoint &, int ); |
265 | virtual void slotContextMenu( QListViewItem *item); | 218 | virtual void slotContextMenu( QListViewItem *item); |
266 | // listview crap see above | 219 | // listview crap see above |
267 | // PopupMenu crap | 220 | // PopupMenu crap |
268 | virtual void slotChangedDir(); | 221 | virtual void slotChangedDir(); |
269 | virtual void slotOpen(); | 222 | virtual void slotOpen(); |
270 | virtual void slotRescan(); | 223 | virtual void slotRescan(); |
271 | virtual void slotRename(); | 224 | virtual void slotRename(); |
272 | virtual void slotDelete(); | 225 | virtual void slotDelete(); |
273 | virtual void cdUP(); | 226 | virtual void cdUP(); |
274 | virtual void slotHome(); | 227 | virtual void slotHome(); |
275 | virtual void slotDoc(); | 228 | virtual void slotDoc(); |
276 | virtual void slotNavigate( ); | 229 | virtual void slotNavigate( ); |
277 | }; | 230 | }; |
278 | 231 | ||
279 | 232 | ||
280 | #endif | 233 | #endif |
281 | 234 | ||