-rw-r--r-- | libopie/ofileselector.cc | 135 | ||||
-rw-r--r-- | libopie/ofileselector.h | 4 |
2 files changed, 69 insertions, 70 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index d1f1e1f..ce66f51 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -1,1138 +1,1137 @@ | |||
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 | qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() ); | 69 | qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() ); |
70 | if( str == box->text(i ) ){ | 70 | if( str == box->text(i ) ){ |
71 | index= i; | 71 | index= i; |
72 | break; | 72 | break; |
73 | } | 73 | } |
74 | } | 74 | } |
75 | return index; | 75 | return index; |
76 | } | 76 | } |
77 | 77 | ||
78 | }; | 78 | }; |
79 | 79 | ||
80 | 80 | ||
81 | OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, | 81 | OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, |
82 | const QString &fileName, const QStringList &mimetypes ) : QWidget( wid ) | 82 | const QString &fileName, const QStringList &mimetypes ) : QWidget( wid ) |
83 | { | 83 | { |
84 | if(wid!=0) | 84 | if(wid!=0) |
85 | resize(wid->width(),wid->height()); | 85 | resize(wid->width(),wid->height()); |
86 | m_selector = selector; | 86 | m_selector = selector; |
87 | m_currentDir = dirName; | 87 | m_currentDir = dirName; |
88 | m_name = fileName; | 88 | m_name = fileName; |
89 | m_mimetypes = mimetypes; | 89 | requestedMimeTypesList = m_mimetypes = mimetypes; |
90 | |||
90 | // if( mimetypes.isEmpty() ) | 91 | // if( mimetypes.isEmpty() ) |
91 | // m_autoMime = true; | 92 | // m_autoMime = true; |
92 | 93 | ||
93 | m_mode = mode; | 94 | m_mode = mode; |
94 | m_shTool = true; | 95 | m_shTool = true; |
95 | m_shPerm = true; | 96 | m_shPerm = true; |
96 | m_shLne = true; | 97 | m_shLne = true; |
97 | m_shChooser = true; | 98 | m_shChooser = true; |
98 | m_shYesNo = true; | 99 | m_shYesNo = true; |
99 | // for FILESELECTOR only view is interesting | 100 | // for FILESELECTOR only view is interesting |
100 | m_location = 0; | 101 | m_location = 0; |
101 | m_homeButton = 0; | 102 | m_homeButton = 0; |
102 | m_docButton = 0; | 103 | m_docButton = 0; |
103 | m_hideButton = 0; | 104 | m_hideButton = 0; |
104 | m_ok = 0; | 105 | m_ok = 0; |
105 | m_cancel = 0; | 106 | m_cancel = 0; |
106 | m_reread = 0; | 107 | m_reread = 0; |
107 | m_up = 0; | 108 | m_up = 0; |
108 | m_View = 0; | 109 | m_View = 0; |
109 | m_select = 0; | 110 | m_select = 0; |
110 | m_stack = 0; | 111 | m_stack = 0; |
111 | 112 | ||
112 | m_select = 0; | 113 | m_select = 0; |
113 | m_stack = 0; | 114 | m_stack = 0; |
114 | m_lay = 0; | 115 | m_lay = 0; |
115 | m_boxToolbar = 0; | 116 | m_boxToolbar = 0; |
116 | m_boxOk = 0; | 117 | m_boxOk = 0; |
117 | m_edit = 0; | 118 | m_edit = 0; |
118 | 119 | ||
119 | m_fnLabel = 0; | 120 | m_fnLabel = 0; |
120 | m_checkPerm = 0; | 121 | m_checkPerm = 0; |
121 | m_mimeCheck = 0; | 122 | m_mimeCheck = 0; |
122 | m_viewCheck = 0; | 123 | m_viewCheck = 0; |
123 | 124 | ||
124 | m_pseudo = 0; | 125 | m_pseudo = 0; |
125 | m_pseudoLayout = 0; | 126 | m_pseudoLayout = 0; |
126 | 127 | ||
127 | m_dir = true; | 128 | m_dir = true; |
128 | m_files = true; | 129 | m_files = true; |
129 | m_custom = 0; | 130 | m_custom = 0; |
130 | m_showPopup = true; | 131 | m_showPopup = true; |
131 | 132 | ||
132 | if(m_pixmaps == 0 ) // init the pixmaps | 133 | if(m_pixmaps == 0 ) // init the pixmaps |
133 | initPics(); | 134 | initPics(); |
134 | 135 | ||
135 | m_lay = new QVBoxLayout(this); | 136 | m_lay = new QVBoxLayout(this); |
136 | init(); | 137 | init(); |
137 | m_edit->setText( fileName ); | 138 | m_edit->setText( fileName ); |
138 | } | 139 | } |
139 | 140 | ||
140 | void OFileSelector::initPics() | 141 | void OFileSelector::initPics() |
141 | { | 142 | { |
142 | qWarning("init pics" ); | 143 | qWarning("init pics" ); |
143 | m_pixmaps = new QMap<QString,QPixmap>; | 144 | m_pixmaps = new QMap<QString,QPixmap>; |
144 | QPixmap pm = Resource::loadPixmap( "folder" ); | 145 | QPixmap pm = Resource::loadPixmap( "folder" ); |
145 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 146 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
146 | QPainter painter( &pm ); | 147 | QPainter painter( &pm ); |
147 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 148 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
148 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 149 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
149 | m_pixmaps->insert("dirsymlink", pm ); | 150 | m_pixmaps->insert("dirsymlink", pm ); |
150 | 151 | ||
151 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | 152 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); |
152 | QPainter pen(&pm2 ); | 153 | QPainter pen(&pm2 ); |
153 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | 154 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); |
154 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | 155 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); |
155 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 156 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
156 | 157 | ||
157 | } | 158 | } |
158 | 159 | ||
159 | // let's initialize the gui | 160 | // let's initialize the gui |
160 | /** | 161 | /** |
161 | -------------------- | 162 | -------------------- |
162 | | cmbBox Button | | 163 | | cmbBox Button | |
163 | -------------------- | 164 | -------------------- |
164 | | FileSlector | | 165 | | FileSlector | |
165 | | or | | 166 | | or | |
166 | | OSelector | | 167 | | OSelector | |
167 | | | | 168 | | | |
168 | | | | 169 | | | |
169 | ____________________ | 170 | ____________________ |
170 | | LineEdit | | 171 | | LineEdit | |
171 | ____________________ | 172 | ____________________ |
172 | | Permission Bar | | 173 | | Permission Bar | |
173 | ____________________ | 174 | ____________________ |
174 | | ViewChoose | | 175 | | ViewChoose | |
175 | ____________________ | 176 | ____________________ |
176 | | Save Cancel| | 177 | | Save Cancel| |
177 | ____________________ | 178 | ____________________ |
178 | */ | 179 | */ |
179 | void OFileSelector::delItems() | 180 | void OFileSelector::delItems() |
180 | { | 181 | { |
181 | QLayoutIterator it = m_lay->iterator(); | 182 | QLayoutIterator it = m_lay->iterator(); |
182 | while ( it.current() != 0 ){ | 183 | while ( it.current() != 0 ){ |
183 | it.deleteCurrent(); | 184 | it.deleteCurrent(); |
184 | } | 185 | } |
185 | } | 186 | } |
186 | 187 | ||
187 | void OFileSelector::init() | 188 | void OFileSelector::init() |
188 | { | 189 | { |
189 | 190 | // qDebug("init"); | |
190 | m_stack = new QWidgetStack(this, "wstack" ); | 191 | m_stack = new QWidgetStack(this, "wstack" ); |
191 | if( m_selector == NORMAL ){ | ||
192 | QString currMime; | 192 | QString currMime; |
193 | if( m_mimeCheck != 0 ) | 193 | if( m_mimeCheck != 0 ) |
194 | currMime = m_mimeCheck->currentText(); | 194 | currMime = m_mimeCheck->currentText(); |
195 | |||
196 | updateMimes(); | 195 | updateMimes(); |
197 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); | 196 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); |
198 | m_stack->addWidget(m_select, NORMAL ); | 197 | m_stack->addWidget(m_select, NORMAL ); |
199 | m_lay->addWidget(m_stack ); | 198 | m_lay->addWidget(m_stack ); |
200 | m_stack->raiseWidget(NORMAL ); | 199 | m_stack->raiseWidget(NORMAL ); |
201 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); | 200 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); |
202 | m_pseudoLayout = 0l; | 201 | m_pseudoLayout = 0l; |
203 | }else { | 202 | if( m_selector != NORMAL ) { |
204 | initializeListView(); | 203 | initializeListView(); |
205 | } | 204 | } |
206 | |||
207 | if(m_shLne ){ | 205 | if(m_shLne ){ |
208 | initializeName(); | 206 | initializeName(); |
209 | } | 207 | } |
210 | |||
211 | if(m_shPerm ){ | 208 | if(m_shPerm ){ |
212 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); | 209 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); |
213 | m_checkPerm->setChecked( false ); | 210 | m_checkPerm->setChecked( false ); |
214 | m_lay->addWidget(m_checkPerm ); | 211 | m_lay->addWidget(m_checkPerm ); |
215 | } | 212 | } |
216 | |||
217 | if( m_shChooser ) | 213 | if( m_shChooser ) |
218 | initializeChooser(); | 214 | initializeChooser(); |
219 | |||
220 | if(m_shYesNo ) | 215 | if(m_shYesNo ) |
221 | initializeYes(); | 216 | initializeYes(); |
222 | 217 | ||
218 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, requestedMimeTypesList.first()) ); | ||
219 | reparse(); | ||
223 | 220 | ||
224 | } | 221 | } |
225 | 222 | ||
226 | void OFileSelector::setYesCancelVisible( bool show ) | 223 | void OFileSelector::setYesCancelVisible( bool show ) |
227 | { | 224 | { |
228 | if ( show == m_shYesNo ) | 225 | if ( show == m_shYesNo ) |
229 | return; | 226 | return; |
230 | m_shYesNo = show; | 227 | m_shYesNo = show; |
231 | if( !show ){ | 228 | if( !show ){ |
232 | delete m_ok; | 229 | delete m_ok; |
233 | delete m_cancel; | 230 | delete m_cancel; |
234 | m_ok = 0; | 231 | m_ok = 0; |
235 | m_cancel = 0; | 232 | m_cancel = 0; |
236 | // delete m_boxOk; all ready deleted in delItems | 233 | // delete m_boxOk; all ready deleted in delItems |
237 | } | 234 | } |
238 | updateLay(); // recreate it and save the other states | 235 | updateLay(); // recreate it and save the other states |
239 | } | 236 | } |
240 | 237 | ||
241 | void OFileSelector::setToolbarVisible( bool show ) | 238 | void OFileSelector::setToolbarVisible( bool show ) |
242 | { | 239 | { |
243 | if ( m_shTool == show ) | 240 | if ( m_shTool == show ) |
244 | return; | 241 | return; |
245 | if(!m_shTool ){ | 242 | if(!m_shTool ){ |
246 | delete m_boxToolbar; | 243 | delete m_boxToolbar; |
247 | delete m_homeButton; | 244 | delete m_homeButton; |
248 | delete m_docButton; | 245 | delete m_docButton; |
249 | delete m_location; | 246 | delete m_location; |
250 | delete m_up; | 247 | delete m_up; |
251 | m_boxToolbar = 0; | 248 | m_boxToolbar = 0; |
252 | m_homeButton = 0; | 249 | m_homeButton = 0; |
253 | m_docButton = 0; | 250 | m_docButton = 0; |
254 | m_location = 0; | 251 | m_location = 0; |
255 | m_up = 0; | 252 | m_up = 0; |
256 | }; | 253 | }; |
257 | updateLay();// overkill fix it | 254 | updateLay();// overkill fix it |
258 | } | 255 | } |
259 | 256 | ||
260 | void OFileSelector::setPermissionBarVisible( bool show ) | 257 | void OFileSelector::setPermissionBarVisible( bool show ) |
261 | { | 258 | { |
262 | if( show == m_shPerm ) | 259 | if( show == m_shPerm ) |
263 | return; | 260 | return; |
264 | 261 | ||
265 | m_shPerm = show; | 262 | m_shPerm = show; |
266 | 263 | ||
267 | updateLay(); | 264 | updateLay(); |
268 | } | 265 | } |
269 | 266 | ||
270 | void OFileSelector::setLineEditVisible( bool show ) | 267 | void OFileSelector::setLineEditVisible( bool show ) |
271 | { | 268 | { |
272 | if( show == m_shLne ) | 269 | if( show == m_shLne ) |
273 | return; | 270 | return; |
274 | 271 | ||
275 | m_shLne = show; | 272 | m_shLne = show; |
276 | if( !show ){ | 273 | if( !show ){ |
277 | delete m_edit; | 274 | delete m_edit; |
278 | delete m_fnLabel; | 275 | delete m_fnLabel; |
279 | m_edit = 0; | 276 | m_edit = 0; |
280 | m_fnLabel = 0; | 277 | m_fnLabel = 0; |
281 | //delete m_boxName; will be deleted | 278 | //delete m_boxName; will be deleted |
282 | } | 279 | } |
283 | updateLay(); | 280 | updateLay(); |
284 | } | 281 | } |
285 | 282 | ||
286 | void OFileSelector::setChooserVisible( bool show ) | 283 | void OFileSelector::setChooserVisible( bool show ) |
287 | { | 284 | { |
288 | if( show = m_shChooser ) | 285 | if( show = m_shChooser ) |
289 | return; | 286 | return; |
290 | m_shChooser = show; | 287 | m_shChooser = show; |
291 | if( !show ){ | 288 | if( !show ){ |
292 | delete m_mimeCheck; | 289 | delete m_mimeCheck; |
293 | delete m_viewCheck; | 290 | delete m_viewCheck; |
294 | m_mimeCheck = 0; | 291 | m_mimeCheck = 0; |
295 | m_viewCheck = 0; | 292 | m_viewCheck = 0; |
296 | } | 293 | } |
297 | updateLay(); | 294 | updateLay(); |
298 | } | 295 | } |
299 | 296 | ||
300 | QCheckBox* OFileSelector::permissionCheckbox( ) | 297 | QCheckBox* OFileSelector::permissionCheckbox( ) |
301 | { | 298 | { |
302 | return m_checkPerm; | 299 | return m_checkPerm; |
303 | } | 300 | } |
304 | 301 | ||
305 | void OFileSelector::setCaseSensetive( bool caSe ) | 302 | void OFileSelector::setCaseSensetive( bool caSe ) |
306 | { | 303 | { |
307 | m_case = caSe; | 304 | m_case = caSe; |
308 | reparse(); | 305 | reparse(); |
309 | } | 306 | } |
310 | 307 | ||
311 | void OFileSelector::setShowFiles(bool files ){ | 308 | void OFileSelector::setShowFiles(bool files ){ |
312 | m_files = files; | 309 | m_files = files; |
313 | reparse(); | 310 | reparse(); |
314 | } | 311 | } |
315 | 312 | ||
316 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) | 313 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) |
317 | { | 314 | { |
318 | //delete oldpopup; | 315 | //delete oldpopup; |
319 | m_custom = pop; | 316 | m_custom = pop; |
320 | } | 317 | } |
321 | 318 | ||
322 | bool OFileSelector::setPermission( ) const | 319 | bool OFileSelector::setPermission( ) const |
323 | { | 320 | { |
324 | if( m_checkPerm == 0 ) | 321 | if( m_checkPerm == 0 ) |
325 | return false; | 322 | return false; |
326 | else | 323 | else |
327 | return m_checkPerm->isChecked(); | 324 | return m_checkPerm->isChecked(); |
328 | } | 325 | } |
329 | 326 | ||
330 | void OFileSelector::setPermissionChecked( bool check ) | 327 | void OFileSelector::setPermissionChecked( bool check ) |
331 | { | 328 | { |
332 | if( m_checkPerm == 0 ) | 329 | if( m_checkPerm == 0 ) |
333 | return; | 330 | return; |
334 | m_checkPerm->setChecked( check ); | 331 | m_checkPerm->setChecked( check ); |
335 | } | 332 | } |
336 | 333 | ||
337 | QString OFileSelector::selectedName( )const | 334 | QString OFileSelector::selectedName( )const |
338 | { | 335 | { |
339 | QString string; | 336 | QString string; |
340 | if( m_selector == NORMAL ){ | 337 | if( m_selector == NORMAL ){ |
341 | const DocLnk *lnk = m_select->selected(); | 338 | const DocLnk *lnk = m_select->selected(); |
342 | string = lnk->file(); | 339 | string = lnk->file(); |
343 | }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 340 | }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
344 | QListViewItem *item = m_View->currentItem(); | 341 | QListViewItem *item = m_View->currentItem(); |
345 | if(item != 0 ){ | 342 | if(item != 0 ){ |
346 | string = m_currentDir + "/" + item->text( 1 ); | 343 | string = m_currentDir + "/" + item->text( 1 ); |
347 | } | 344 | } |
348 | } | 345 | } |
349 | return string; | 346 | return string; |
350 | } | 347 | } |
351 | 348 | ||
352 | QStringList OFileSelector::selectedNames()const | 349 | QStringList OFileSelector::selectedNames()const |
353 | { | 350 | { |
354 | QStringList list; | 351 | QStringList list; |
355 | return list; | 352 | return list; |
356 | } | 353 | } |
357 | 354 | ||
358 | DocLnk OFileSelector::selectedDocument( )const | 355 | DocLnk OFileSelector::selectedDocument( )const |
359 | { | 356 | { |
360 | DocLnk lnk; | 357 | DocLnk lnk; |
361 | return lnk; | 358 | return lnk; |
362 | } | 359 | } |
363 | void OFileSelector::updateLay() | 360 | void OFileSelector::updateLay() |
364 | { | 361 | { |
365 | /* if( m_shTool ) | 362 | /* if( m_shTool ) |
366 | // | 363 | // |
367 | else | 364 | else |
368 | // hide | 365 | // hide |
369 | */ | 366 | */ |
370 | // save the state | 367 | // save the state |
371 | bool check = false; | 368 | bool check = false; |
372 | if( m_checkPerm != 0 ) | 369 | if( m_checkPerm != 0 ) |
373 | check = m_checkPerm->isChecked(); | 370 | check = m_checkPerm->isChecked(); |
374 | QString text; | 371 | QString text; |
375 | 372 | ||
376 | if( m_edit != 0 ) | 373 | if( m_edit != 0 ) |
377 | text = m_edit->text(); | 374 | text = m_edit->text(); |
378 | // save current mimetype | 375 | // save current mimetype |
379 | 376 | ||
380 | delItems(); | 377 | delItems(); |
381 | delete m_checkPerm; | 378 | delete m_checkPerm; |
382 | m_checkPerm = 0; | 379 | m_checkPerm = 0; |
383 | delete m_edit; | 380 | delete m_edit; |
384 | m_edit = 0; | 381 | m_edit = 0; |
385 | delete m_fnLabel; | 382 | delete m_fnLabel; |
386 | m_fnLabel = 0; | 383 | m_fnLabel = 0; |
387 | delete m_ok; | 384 | delete m_ok; |
388 | m_ok = 0; | 385 | m_ok = 0; |
389 | delete m_cancel; | 386 | delete m_cancel; |
390 | m_cancel = 0; | 387 | m_cancel = 0; |
391 | delete m_mimeCheck; | 388 | delete m_mimeCheck; |
392 | m_mimeCheck = 0; | 389 | m_mimeCheck = 0; |
393 | delete m_viewCheck; | 390 | delete m_viewCheck; |
394 | m_viewCheck = 0; | 391 | m_viewCheck = 0; |
395 | delete m_select; // test | 392 | delete m_select; // test |
396 | delete m_stack; | 393 | delete m_stack; |
397 | //delete m_list; | 394 | //delete m_list; |
398 | init(); | 395 | init(); |
399 | if( m_shLne ) | 396 | if( m_shLne ) |
400 | m_edit->setText(text ); | 397 | m_edit->setText(text ); |
401 | if( m_shPerm ) | 398 | if( m_shPerm ) |
402 | m_checkPerm->setChecked(check ); | 399 | m_checkPerm->setChecked(check ); |
403 | } | 400 | } |
404 | 401 | ||
405 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve | 402 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve |
406 | // insert QListViewItems with the right options | 403 | // insert QListViewItems with the right options |
407 | bool OFileSelector::compliesMime(const QString &path, const QString &mime ) | 404 | bool OFileSelector::compliesMime(const QString &path, const QString &mime ) |
408 | { | 405 | { |
409 | if( mime == "All" ) | 406 | if( mime == "All" ) |
410 | return true; | 407 | return true; |
411 | MimeType type( path ); | 408 | MimeType type( path ); |
412 | if( type.id() == mime ) | 409 | if( type.id() == mime ) |
413 | return true; | 410 | return true; |
414 | return false; | 411 | return false; |
415 | } | 412 | } |
416 | 413 | ||
417 | void OFileSelector::reparse() | 414 | void OFileSelector::reparse() |
418 | { | 415 | { |
416 | qDebug("reparse"); | ||
419 | if(m_View== 0 || m_selector == NORMAL) | 417 | if(m_View== 0 || m_selector == NORMAL) |
420 | return; | 418 | return; |
421 | |||
422 | m_View->clear(); | 419 | m_View->clear(); |
423 | |||
424 | |||
425 | QString currMime =m_mimeCheck->currentText(); | 420 | QString currMime =m_mimeCheck->currentText(); |
426 | // update the mimetype now | 421 | // update the mimetype now |
427 | if( m_autoMime ) { | 422 | if( m_autoMime ) { |
428 | QDir dir( m_currentDir ); | 423 | QDir dir( m_currentDir ); |
429 | m_mimetypes.clear(); | 424 | m_mimetypes.clear(); |
430 | m_mimeCheck->clear(); | 425 | m_mimeCheck->clear(); |
431 | dir.setFilter( QDir::Files | QDir::Readable ); | 426 | dir.setFilter( QDir::Files | QDir::Readable ); |
432 | dir.setSorting(QDir::Size ); | 427 | dir.setSorting(QDir::Size ); |
433 | const QFileInfoList *list = dir.entryInfoList(); | 428 | const QFileInfoList *list = dir.entryInfoList(); |
434 | QFileInfoListIterator it( *list ); | 429 | QFileInfoListIterator it( *list ); |
435 | QFileInfo *fi; | 430 | QFileInfo *fi; |
436 | while( (fi=it.current()) ){ | 431 | while( (fi=it.current()) ){ |
437 | if(fi->extension() == QString::fromLatin1("desktop") ){ | 432 | if(fi->extension() == QString::fromLatin1("desktop") ){ |
438 | ++it; | 433 | ++it; |
439 | continue; | 434 | continue; |
440 | } | 435 | } |
441 | MimeType type(fi->filePath() ); | 436 | MimeType type(fi->filePath() ); |
442 | if( !m_mimetypes.contains( type.id() ) ) | 437 | if( !m_mimetypes.contains( type.id() ) ) |
443 | m_mimetypes.append( type.id() ); | 438 | m_mimetypes.append( type.id() ); |
444 | 439 | ||
445 | ++it; | 440 | ++it; |
446 | } | 441 | } |
447 | m_mimetypes.prepend("All" ); | 442 | m_mimetypes.prepend("All" ); |
448 | m_mimeCheck->insertStringList(m_mimetypes ); | 443 | m_mimeCheck->insertStringList(m_mimetypes ); |
449 | // set it to the current mimetype | 444 | // set it to the current mimetype |
450 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); | 445 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); |
451 | }; | 446 | }; |
452 | 447 | ||
453 | QDir dir( m_currentDir ); | 448 | QDir dir( m_currentDir ); |
454 | //dir.setFilter(-1 ); | 449 | //dir.setFilter(-1 ); |
455 | int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; | 450 | int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; |
456 | if( m_case ) | 451 | if( m_case ) |
457 | sort = QDir::IgnoreCase; | 452 | sort = QDir::IgnoreCase; |
458 | dir.setSorting( sort ); | 453 | dir.setSorting( sort ); |
459 | 454 | ||
460 | int filter; | 455 | int filter; |
461 | /* if( m_dir && !m_files) | 456 | /* if( m_dir && !m_files) |
462 | filter |= QDir::Dirs; | 457 | filter |= QDir::Dirs; |
463 | else if( !m_dir && m_files ) | 458 | else if( !m_dir && m_files ) |
464 | filter |= QDir::Files; | 459 | filter |= QDir::Files; |
465 | else | 460 | else |
466 | filter |= QDir::All; | 461 | filter |= QDir::All; |
467 | */ | 462 | */ |
468 | if( m_selector == EXTENDED_ALL ) | 463 | if( m_selector == EXTENDED_ALL ) |
469 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 464 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
470 | else | 465 | else |
471 | filter = QDir::Files | QDir::Dirs | QDir::All; | 466 | filter = QDir::Files | QDir::Dirs | QDir::All; |
472 | dir.setFilter( filter ); | 467 | dir.setFilter( filter ); |
473 | 468 | qDebug("infoList"); | |
474 | const QFileInfoList *list = dir.entryInfoList(); | 469 | const QFileInfoList *list = dir.entryInfoList(); |
475 | QFileInfoListIterator it( *list ); | 470 | QFileInfoListIterator it( *list ); |
476 | QFileInfo *fi; | 471 | QFileInfo *fi; |
477 | while( (fi=it.current()) ){ | 472 | while( (fi=it.current()) ){ |
478 | if(fi->fileName() == ".." || fi->fileName() == "." ){ | 473 | if(fi->fileName() == ".." || fi->fileName() == "." ){ |
479 | ++it; | 474 | ++it; |
480 | continue; | 475 | continue; |
481 | } | 476 | } |
482 | qWarning("Test: %s", fi->fileName().latin1() ); | 477 | // qWarning("Test: %s", fi->fileName().latin1() ); |
483 | if(fi->isSymLink() ){ | 478 | if(fi->isSymLink() ){ |
484 | qWarning("Symlink %s", fi->fileName().latin1() ); | 479 | // qWarning("Symlink %s", fi->fileName().latin1() ); |
485 | QString file = fi->dirPath(true)+"/"+ fi->readLink(); | 480 | QString file = fi->dirPath(true)+"/"+ fi->readLink(); |
486 | qWarning("File ->%s", file.latin1() ); | 481 | // qWarning("File ->%s", file.latin1() ); |
487 | for(int i=0; i<=4; i++ ){ // prepend from dos | 482 | for(int i=0; i<=4; i++ ){ // prepend from dos |
488 | QFileInfo info( file ); | 483 | QFileInfo info( file ); |
489 | if( !info.exists() ){ | 484 | if( !info.exists() ){ |
490 | qWarning("does not exist" ); | 485 | // qWarning("does not exist" ); |
491 | addSymlink(currMime, fi, TRUE ); | 486 | addSymlink(currMime, fi, TRUE ); |
492 | break; | 487 | break; |
493 | }else if( info.isDir() ){ | 488 | }else if( info.isDir() ){ |
494 | qWarning("isDir" ); | 489 | // qWarning("isDir" ); |
495 | addDir(currMime, fi, TRUE ); | 490 | addDir(currMime, fi, TRUE ); |
496 | break; | 491 | break; |
497 | }else if( info.isFile() ){ | 492 | }else if( info.isFile() ){ |
498 | qWarning("isFile" ); | 493 | // qWarning("isFile" ); |
499 | addFile(currMime, fi, TRUE ); | 494 | addFile(currMime, fi, TRUE ); |
500 | break; | 495 | break; |
501 | }else if( info.isSymLink() ){ | 496 | }else if( info.isSymLink() ){ |
502 | file = info.dirPath(true)+ "/"+ info.readLink(); | 497 | file = info.dirPath(true)+ "/"+ info.readLink(); |
503 | qWarning("isSymlink again %s", file.latin1() ); | 498 | // qWarning("isSymlink again %s", file.latin1() ); |
504 | }else if( i == 4 ){ // just insert it and have the symlink symbol | 499 | }else if( i == 4 ){ // just insert it and have the symlink symbol |
505 | addSymlink(currMime, fi ); | 500 | addSymlink(currMime, fi ); |
506 | qWarning("level too deep" ); | 501 | // qWarning("level too deep" ); |
507 | } | 502 | } |
508 | } | 503 | } |
509 | }else if( fi->isDir() ){ | 504 | }else if( fi->isDir() ){ |
510 | addDir(currMime, fi ); | 505 | addDir(currMime, fi ); |
511 | }else if( fi->isFile() ) { // file ? | 506 | }else if( fi->isFile() ) { // file ? |
512 | addFile(currMime, fi ); | 507 | addFile(currMime, fi ); |
513 | } | 508 | } |
514 | ++it; | 509 | ++it; |
515 | } | 510 | } |
516 | m_View->sort(); | 511 | m_View->sort(); |
512 | // m_View->ensureItemVisible(); | ||
517 | } | 513 | } |
518 | 514 | ||
519 | QString OFileSelector::directory()const | 515 | QString OFileSelector::directory()const |
520 | { | 516 | { |
521 | QDir d( m_currentDir); | 517 | QDir d( m_currentDir); |
522 | return d.absPath(); | 518 | return d.absPath(); |
523 | } | 519 | } |
524 | 520 | ||
525 | int OFileSelector::fileCount() | 521 | int OFileSelector::fileCount() |
526 | { | 522 | { |
527 | return 0; | 523 | return 0; |
528 | } | 524 | } |
529 | 525 | ||
530 | void OFileSelector::slotOk( ) | 526 | void OFileSelector::slotOk( ) |
531 | { | 527 | { |
532 | emit ok(); | 528 | emit ok(); |
533 | } | 529 | } |
534 | 530 | ||
535 | void OFileSelector::slotCancel( ) | 531 | void OFileSelector::slotCancel( ) |
536 | { | 532 | { |
537 | emit cancel(); | 533 | emit cancel(); |
538 | } | 534 | } |
539 | 535 | ||
540 | void OFileSelector::initializeName() | 536 | void OFileSelector::initializeName() |
541 | { | 537 | { |
542 | m_boxName = new QHBoxLayout(this ); | 538 | m_boxName = new QHBoxLayout(this ); |
543 | m_edit = new QLineEdit(this ); | 539 | m_edit = new QLineEdit(this ); |
544 | m_fnLabel = new QLabel(this ); | 540 | m_fnLabel = new QLabel(this ); |
545 | m_fnLabel->setText(tr("Name:") ); | 541 | m_fnLabel->setText(tr("Name:") ); |
546 | m_boxName->addWidget(m_fnLabel ); | 542 | m_boxName->addWidget(m_fnLabel ); |
547 | m_boxName->insertSpacing(1, 8 ); | 543 | m_boxName->insertSpacing(1, 8 ); |
548 | m_boxName->addWidget(m_edit, 100 ); | 544 | m_boxName->addWidget(m_edit, 100 ); |
549 | 545 | ||
550 | m_lay->addLayout(m_boxName); | 546 | m_lay->addLayout(m_boxName); |
551 | } | 547 | } |
552 | 548 | ||
553 | void OFileSelector::initializeYes() | 549 | void OFileSelector::initializeYes() |
554 | { | 550 | { |
555 | m_ok = new QPushButton("&Save", this, "save" ); | 551 | m_ok = new QPushButton("&Save", this, "save" ); |
556 | m_cancel = new QPushButton("C&ancel", this, "cancel" ); | 552 | m_cancel = new QPushButton("C&ancel", this, "cancel" ); |
557 | m_boxOk = new QHBoxLayout(this ); | 553 | m_boxOk = new QHBoxLayout(this ); |
558 | m_boxOk->addWidget( m_ok, Qt::AlignHCenter ); | 554 | m_boxOk->addWidget( m_ok, Qt::AlignHCenter ); |
559 | m_boxOk->insertSpacing(1, 8 ); | 555 | m_boxOk->insertSpacing(1, 8 ); |
560 | m_boxOk->addWidget( m_cancel, Qt::AlignHCenter); | 556 | m_boxOk->addWidget( m_cancel, Qt::AlignHCenter); |
561 | m_lay->addLayout(m_boxOk ); | 557 | m_lay->addLayout(m_boxOk ); |
562 | connect(m_ok, SIGNAL(clicked() ), | 558 | connect(m_ok, SIGNAL(clicked() ), |
563 | this, SLOT(slotOk() ) ); | 559 | this, SLOT(slotOk() ) ); |
564 | connect(m_cancel, SIGNAL(clicked() ), | 560 | connect(m_cancel, SIGNAL(clicked() ), |
565 | this, SLOT(slotCancel() ) ); | 561 | this, SLOT(slotCancel() ) ); |
566 | 562 | ||
567 | } | 563 | } |
568 | 564 | ||
569 | void OFileSelector::initializeChooser() | 565 | void OFileSelector::initializeChooser() |
570 | { | 566 | { |
571 | m_boxView = new QHBoxLayout(this ); | 567 | m_boxView = new QHBoxLayout(this ); |
572 | 568 | ||
573 | m_mimeCheck = new QComboBox(this, "mime check"); | 569 | m_mimeCheck = new QComboBox(this, "mime check"); |
574 | m_viewCheck = new QComboBox(this, "view check"); | 570 | m_viewCheck = new QComboBox(this, "view check"); |
575 | m_boxView->addWidget(m_viewCheck, 0 ); | 571 | m_boxView->addWidget(m_viewCheck, 0 ); |
576 | m_boxView->insertSpacing(2, 8 ); | 572 | m_boxView->insertSpacing(2, 8 ); |
577 | m_boxView->addWidget(m_mimeCheck, 0 ); | 573 | m_boxView->addWidget(m_mimeCheck, 0 ); |
578 | m_lay->addLayout(m_boxView ); | 574 | m_lay->addLayout(m_boxView ); |
579 | m_lay->insertSpacing( 4, 8); | 575 | m_lay->insertSpacing( 4, 8); |
580 | 576 | ||
581 | m_viewCheck->insertItem(tr("Documents") ); | 577 | m_viewCheck->insertItem(tr("Documents") ); |
582 | m_viewCheck->insertItem(tr("Files") ); | 578 | m_viewCheck->insertItem(tr("Files") ); |
583 | m_viewCheck->insertItem(tr("All Files") ); | 579 | m_viewCheck->insertItem(tr("All Files") ); |
584 | 580 | ||
585 | // if(!m_autoMime ) | 581 | // if(!m_autoMime ) |
586 | // m_mimeCheck->insertItem(m_mimetypes.join("," ) ); | 582 | // m_mimeCheck->insertItem(m_mimetypes.join("," ) ); |
587 | // else{ // check | 583 | // else{ // check |
588 | updateMimes(); | 584 | updateMimes(); |
589 | m_mimeCheck->insertStringList( m_mimetypes ); | 585 | m_mimeCheck->insertStringList( m_mimetypes ); |
590 | // } | 586 | // } |
591 | 587 | ||
592 | connect( m_viewCheck, SIGNAL(activated(const QString &) ), | 588 | connect( m_viewCheck, SIGNAL(activated(const QString &) ), |
593 | this, SLOT(slotViewCheck(const QString & ) ) ); | 589 | this, SLOT(slotViewCheck(const QString & ) ) ); |
594 | 590 | ||
595 | connect( m_mimeCheck, SIGNAL(activated(const QString &) ), | 591 | connect( m_mimeCheck, SIGNAL(activated(const QString &) ), |
596 | this, SLOT(slotMimeCheck(const QString & ) ) ); | 592 | this, SLOT(slotMimeCheck(const QString & ) ) ); |
597 | } | 593 | } |
598 | 594 | ||
599 | void OFileSelector::slotMimeCheck(const QString &view ){ | 595 | void OFileSelector::slotMimeCheck(const QString &view ){ |
600 | if(m_selector == NORMAL ){ | 596 | if(m_selector == NORMAL ){ |
601 | delete m_select; | 597 | delete m_select; |
602 | m_select = new FileSelector(view == "All" ? QString::null : view | 598 | m_select = new FileSelector(view == "All" ? QString::null : view |
603 | , m_stack, "fileselector", FALSE, FALSE ); | 599 | , m_stack, "fileselector", FALSE, FALSE ); |
604 | m_stack->addWidget( m_select, NORMAL ); | 600 | m_stack->addWidget( m_select, NORMAL ); |
605 | m_stack->raiseWidget( NORMAL ); | 601 | m_stack->raiseWidget( NORMAL ); |
606 | }else{ | 602 | }else{ |
607 | reparse(); | 603 | reparse(); |
608 | } | 604 | } |
609 | } | 605 | } |
610 | 606 | ||
611 | void OFileSelector::slotViewCheck(const QString &view ){ | 607 | void OFileSelector::slotViewCheck(const QString &view ){ |
612 | qWarning("changed: show %s", view.latin1() ); | 608 | qWarning("changed: show %s", view.latin1() ); |
613 | // if the current view is the one | 609 | // if the current view is the one |
614 | QString currMime = m_mimeCheck->currentText(); | 610 | QString currMime = m_mimeCheck->currentText(); |
615 | if( view == QString::fromLatin1("Documents") ){ | 611 | if( view == QString::fromLatin1("Documents") ){ |
616 | // get the mimetype now | 612 | // get the mimetype now |
617 | // check if we're the current widget and return | 613 | // check if we're the current widget and return |
618 | if( m_View != 0) { // delete 0 shouldn't crash but it did :( | 614 | if( m_View != 0) { // delete 0 shouldn't crash but it did :( |
619 | delete m_View; | 615 | delete m_View; |
620 | delete m_boxToolbar; | 616 | delete m_boxToolbar; |
621 | delete m_homeButton; | 617 | delete m_homeButton; |
622 | delete m_docButton; | 618 | delete m_docButton; |
623 | delete m_location; | 619 | delete m_location; |
624 | delete m_up; | 620 | delete m_up; |
625 | delete m_pseudo; | 621 | delete m_pseudo; |
626 | //if(m_pseudoLayout!=0 ) | 622 | //if(m_pseudoLayout!=0 ) |
627 | // delete m_pseudoLayout; | 623 | // delete m_pseudoLayout; |
628 | } | 624 | } |
629 | m_View = 0; | 625 | m_View = 0; |
630 | m_boxToolbar = 0; | 626 | m_boxToolbar = 0; |
631 | m_homeButton = 0; | 627 | m_homeButton = 0; |
632 | m_docButton = 0; | 628 | m_docButton = 0; |
633 | m_location = 0; | 629 | m_location = 0; |
634 | m_up = 0; | 630 | m_up = 0; |
635 | m_pseudo = 0; | 631 | m_pseudo = 0; |
636 | m_pseudoLayout = 0; | 632 | m_pseudoLayout = 0; |
637 | 633 | ||
638 | delete m_select; | 634 | delete m_select; |
639 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime, | 635 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime, |
640 | m_stack,"fileselector", FALSE, FALSE ); | 636 | m_stack,"fileselector", FALSE, FALSE ); |
641 | m_stack->addWidget( m_select, NORMAL ); | 637 | m_stack->addWidget( m_select, NORMAL ); |
642 | m_mimeCheck->clear(); | 638 | m_mimeCheck->clear(); |
643 | m_selector = NORMAL; | 639 | m_selector = NORMAL; |
644 | updateMimes(); | 640 | updateMimes(); |
645 | m_mimeCheck->insertStringList( m_mimetypes ); | 641 | m_mimeCheck->insertStringList( m_mimetypes ); |
646 | m_stack->raiseWidget( NORMAL ); | 642 | m_stack->raiseWidget( NORMAL ); |
647 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); | 643 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); |
648 | 644 | ||
649 | }else if(view == QString::fromLatin1("Files") ){ | 645 | } else if(view == QString::fromLatin1("Files") ){ |
650 | // remove from the stack | 646 | // remove from the stack |
651 | delete m_select; | 647 | delete m_select; |
652 | m_select = 0; | 648 | m_select = 0; |
653 | delete m_View; | 649 | delete m_View; |
654 | m_View = 0; | 650 | m_View = 0; |
655 | 651 | ||
656 | |||
657 | |||
658 | m_selector = EXTENDED; | 652 | m_selector = EXTENDED; |
659 | // create the ListView or IconView | ||
660 | initializeListView(); | 653 | initializeListView(); |
661 | |||
662 | reparse(); | 654 | reparse(); |
663 | }else if(view == QString::fromLatin1("All Files") ) { | 655 | } else if(view == QString::fromLatin1("All Files") ) { |
664 | // remove from the stack | 656 | // remove from the stack |
665 | delete m_select; | 657 | delete m_select; |
666 | m_select = 0; | 658 | m_select = 0; |
667 | delete m_View; | 659 | delete m_View; |
668 | m_View = 0; | 660 | m_View = 0; |
669 | 661 | ||
670 | m_selector = EXTENDED_ALL; | 662 | m_selector = EXTENDED_ALL; |
671 | initializeListView(); | 663 | initializeListView(); |
672 | reparse(); | 664 | reparse(); |
673 | }; | 665 | } |
674 | } | 666 | } |
675 | 667 | ||
676 | 668 | ||
677 | void OFileSelector::updateMimes() // lets check which mode is active | 669 | void OFileSelector::updateMimes() // lets check which mode is active |
678 | // check the current dir for items then | 670 | // check the current dir for items then |
679 | { | 671 | { |
680 | m_mimetypes.clear(); | 672 | m_mimetypes.clear(); |
681 | m_mimetypes.append("All" ); | 673 | m_mimetypes.append("All" ); |
682 | if( m_selector == NORMAL ){ | 674 | // if( m_selector == NORMAL ){ |
683 | DocLnkSet set; | 675 | DocLnkSet set; |
684 | Global::findDocuments(&set, QString::null ); | 676 | Global::findDocuments(&set, QString::null ); |
685 | QListIterator<DocLnk> dit( set.children() ); | 677 | QListIterator<DocLnk> dit( set.children() ); |
686 | for ( ; dit.current(); ++dit ) { | 678 | for ( ; dit.current(); ++dit ) { |
687 | if( !m_mimetypes.contains((*dit)->type() ) ) | 679 | if( !m_mimetypes.contains((*dit)->type() ) ) |
688 | m_mimetypes.append( (*dit)->type() ); | 680 | m_mimetypes.append( (*dit)->type() ); |
689 | } | 681 | } |
690 | }else{ | 682 | // }else{ |
691 | // should be allreday updatet | 683 | // should be allreday updatet |
692 | ; | 684 | // ; |
693 | } | 685 | // } |
694 | } | 686 | } |
695 | 687 | ||
696 | void OFileSelector::initializeListView() | 688 | void OFileSelector::initializeListView() |
697 | { | 689 | { |
690 | // in the instance that a developer selected the view to be Files or Entended, | ||
691 | // in the initial initialization, you are deleting objects here | ||
692 | // that aren't even existing yet. | ||
693 | |||
698 | // just to make sure but clean it up better FIXME | 694 | // just to make sure but clean it up better FIXME |
699 | delete m_View; | 695 | // if( m_View) delete m_View; |
700 | m_View = 0; | 696 | // m_View = 0; |
701 | delete m_boxToolbar; | 697 | // if(m_boxToolbar) delete m_boxToolbar; |
702 | delete m_homeButton; | 698 | // if(m_homeButton) delete m_homeButton; |
703 | delete m_docButton; | 699 | // if(m_docButton) delete m_docButton; |
704 | delete m_location; | 700 | // if( m_location) delete m_location; |
705 | delete m_up; | 701 | // if(m_up) delete m_up; |
706 | //delete m_pseudo; | 702 | //delete m_pseudo; |
707 | //if(m_pseudoLayout!=0 ) // why did you overload malloc | 703 | //if(m_pseudoLayout!=0 ) // why did you overload malloc |
708 | //delete m_pseudoLayout; | 704 | //delete m_pseudoLayout; |
709 | m_boxToolbar = 0; | 705 | m_boxToolbar = 0; |
710 | m_homeButton = 0; | 706 | m_homeButton = 0; |
711 | m_docButton = 0; | 707 | m_docButton = 0; |
712 | m_location = 0; | 708 | m_location = 0; |
713 | m_up = 0; | 709 | m_up = 0; |
714 | m_pseudo = 0; | 710 | m_pseudo = 0; |
715 | m_pseudoLayout = 0; | 711 | m_pseudoLayout = 0; |
716 | // time for the toolbar | 712 | qDebug(" time for the toolbar "); |
717 | m_pseudo = new QWidget(m_stack, "Pseudo Widget"); | 713 | m_pseudo = new QWidget(m_stack, "Pseudo Widget"); |
718 | m_pseudoLayout = new QVBoxLayout(m_pseudo ); | 714 | m_pseudoLayout = new QVBoxLayout(m_pseudo ); |
719 | if(m_shTool ){ | 715 | if(m_shTool ){ |
720 | m_boxToolbar = new QHBoxLayout( ); | 716 | m_boxToolbar = new QHBoxLayout( ); |
721 | m_boxToolbar->setAutoAdd( true ); | 717 | m_boxToolbar->setAutoAdd( true ); |
722 | m_location = new QComboBox(m_pseudo ); | 718 | m_location = new QComboBox(m_pseudo ); |
719 | m_location ->setEditable(TRUE); | ||
723 | connect( m_location, SIGNAL(activated(const QString &) ), this, SLOT( locationComboActivated(const QString & ) ) ); | 720 | connect( m_location, SIGNAL(activated(const QString &) ), this, SLOT( locationComboActivated(const QString & ) ) ); |
721 | connect( m_location->lineEdit(),SIGNAL(returnPressed()), this,SLOT( locationComboChanged())); | ||
724 | 722 | ||
725 | m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton"); | 723 | m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton"); |
726 | m_up->setFixedSize( QSize( 20, 20 ) ); | 724 | m_up->setFixedSize( QSize( 20, 20 ) ); |
727 | connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); | 725 | connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); |
728 | m_up->setFlat(TRUE); | 726 | m_up->setFlat(TRUE); |
729 | 727 | ||
730 | m_homeButton = new QPushButton(Resource::loadIconSet("home") , "", m_pseudo); | 728 | m_homeButton = new QPushButton(Resource::loadIconSet("home") , "", m_pseudo); |
731 | m_homeButton->setFixedSize( QSize( 20, 20 ) ); | 729 | m_homeButton->setFixedSize( QSize( 20, 20 ) ); |
732 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); | 730 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); |
733 | m_homeButton->setFlat(TRUE); | 731 | m_homeButton->setFlat(TRUE); |
734 | 732 | ||
735 | m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", m_pseudo,"docsButton"); | 733 | m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", m_pseudo,"docsButton"); |
736 | m_docButton->setFixedSize( QSize( 20, 20 ) ); | 734 | m_docButton->setFixedSize( QSize( 20, 20 ) ); |
737 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); | 735 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); |
738 | m_docButton->setFlat(TRUE); | 736 | m_docButton->setFlat(TRUE); |
739 | 737 | ||
740 | m_boxToolbar->addWidget(m_location ); | 738 | m_boxToolbar->addWidget(m_location ); |
741 | m_boxToolbar->addWidget(m_up ); | 739 | m_boxToolbar->addWidget(m_up ); |
742 | m_boxToolbar->addWidget(m_homeButton ); | 740 | m_boxToolbar->addWidget(m_homeButton ); |
743 | m_boxToolbar->addWidget(m_docButton ); | 741 | m_boxToolbar->addWidget(m_docButton ); |
744 | m_pseudoLayout->addLayout(m_boxToolbar ); | 742 | m_pseudoLayout->addLayout(m_boxToolbar ); |
745 | // lets fill the combobox | 743 | qDebug("lets fill the combobox"); |
746 | StorageInfo storage; | 744 | StorageInfo storage; |
747 | const QList<FileSystem> &fs = storage.fileSystems(); | 745 | const QList<FileSystem> &fs = storage.fileSystems(); |
748 | QListIterator<FileSystem> it ( fs ); | 746 | QListIterator<FileSystem> it ( fs ); |
749 | for( ; it.current(); ++it ){ | 747 | for( ; it.current(); ++it ){ |
750 | const QString disk = (*it)->name(); | 748 | const QString disk = (*it)->name(); |
751 | const QString path = (*it)->path(); | 749 | const QString path = (*it)->path(); |
752 | m_location->insertItem(path+ "<-"+disk ); | 750 | m_location->insertItem(path+ "<-"+disk ); |
753 | } | 751 | } |
754 | int count = m_location->count(); | 752 | int count = m_location->count(); |
755 | m_location->insertItem(m_currentDir ); | 753 | m_location->insertItem(m_currentDir ); |
756 | m_location->setCurrentItem( count ); | 754 | m_location->setCurrentItem( count ); |
757 | }; | 755 | }; |
756 | |||
758 | m_View = new QListView(m_pseudo, "Extended view" ); | 757 | m_View = new QListView(m_pseudo, "Extended view" ); |
759 | m_stack->addWidget( m_pseudo, EXTENDED ); | 758 | m_stack->addWidget( m_pseudo, EXTENDED ); |
760 | m_stack->raiseWidget( EXTENDED ); | 759 | m_stack->raiseWidget( EXTENDED ); |
761 | m_pseudoLayout->addWidget(m_View ); | 760 | m_pseudoLayout->addWidget(m_View ); |
762 | QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold); | 761 | QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold); |
763 | // set up the stuff | 762 | // set up the stuff |
764 | // Pixmap Name Date Size mime | 763 | // Pixmap Name Date Size mime |
765 | //(m_View->header() )->hide(); | 764 | //(m_View->header() )->hide(); |
766 | //m_View->setRootIsDecorated(false); | 765 | //m_View->setRootIsDecorated(false); |
767 | m_View->addColumn(" "); | 766 | m_View->addColumn(" "); |
768 | m_View->addColumn(tr("Name"),135 ); | 767 | m_View->addColumn(tr("Name"),135 ); |
769 | m_View->addColumn(tr("Size"),-1 ); | 768 | m_View->addColumn(tr("Size"),-1 ); |
770 | m_View->addColumn(tr("Date"), 60 ); | 769 | m_View->addColumn(tr("Date"), 60 ); |
771 | m_View->addColumn(tr("Mime Type"),-1 ); | 770 | m_View->addColumn(tr("Mime Type"),-1 ); |
772 | QHeader *header = m_View->header(); | 771 | QHeader *header = m_View->header(); |
773 | header->hide(); | 772 | header->hide(); |
774 | m_View->setSorting(1 ); | 773 | m_View->setSorting(1 ); |
775 | m_View->setAllColumnsShowFocus( TRUE); | 774 | m_View->setAllColumnsShowFocus( TRUE); |
776 | // connect now | 775 | // connect now |
777 | connect(m_View, SIGNAL(selectionChanged() ), this, SLOT(slotSelectionChanged() ) ); | 776 | connect(m_View, SIGNAL(selectionChanged() ), this, SLOT(slotSelectionChanged() ) ); |
778 | connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); | 777 | connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); |
779 | connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), | 778 | connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), |
780 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); | 779 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); |
781 | connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), | 780 | connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), |
782 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); | 781 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); |
783 | 782 | ||
784 | 783 | ||
785 | }; | 784 | }; |
785 | |||
786 | /* If a item is locked depends on the mode | 786 | /* If a item is locked depends on the mode |
787 | if we're in OPEN !isReadable is locked | 787 | if we're in OPEN !isReadable is locked |
788 | if we're in SAVE !isWriteable is locked | 788 | if we're in SAVE !isWriteable is locked |
789 | 789 | ||
790 | 790 | ||
791 | */ | 791 | */ |
792 | 792 | ||
793 | 793 | ||
794 | void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){ | 794 | void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){ |
795 | qWarning("Add Files" ); | 795 | // qWarning("Add Files" ); |
796 | if( !m_files ){ | 796 | if( !m_files ){ |
797 | qWarning("not mfiles" ); | 797 | // qWarning("not mfiles" ); |
798 | return; | 798 | return; |
799 | } | 799 | } |
800 | 800 | ||
801 | MimeType type( info->filePath() ); | 801 | MimeType type( info->filePath() ); |
802 | QString name; | 802 | QString name; |
803 | QString dir; | 803 | QString dir; |
804 | bool locked= false; | 804 | bool locked= false; |
805 | if(mime == "All" ){ | 805 | if(mime == "All" ){ |
806 | ; | 806 | ; |
807 | }else if( type.id() != mime ) { | 807 | }else if( type.id() != mime ) { |
808 | return; | 808 | return; |
809 | } | 809 | } |
810 | QPixmap pix = type.pixmap(); | 810 | QPixmap pix = type.pixmap(); |
811 | if(pix.isNull() ) | 811 | if(pix.isNull() ) |
812 | pix = Resource::loadPixmap( "UnknownDocument-14" ); | 812 | pix = Resource::loadPixmap( "UnknownDocument-14" ); |
813 | dir = info->dirPath( true ); | 813 | dir = info->dirPath( true ); |
814 | if( symlink ) { // check if the readLink is readable | 814 | if( symlink ) { // check if the readLink is readable |
815 | // do it right later | 815 | // do it right later |
816 | name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); | 816 | name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); |
817 | }else{ // keep track of the icons | 817 | }else{ // keep track of the icons |
818 | name = info->fileName(); | 818 | name = info->fileName(); |
819 | if( m_mode == OPEN ){ | 819 | if( m_mode == OPEN ){ |
820 | if( !info->isReadable() ){ | 820 | if( !info->isReadable() ){ |
821 | locked = true; | 821 | locked = true; |
822 | pix = Resource::loadPixmap("locked" ); | 822 | pix = Resource::loadPixmap("locked" ); |
823 | } | 823 | } |
824 | }else if( m_mode == SAVE ){ | 824 | }else if( m_mode == SAVE ){ |
825 | if( !info->isWritable() ){ | 825 | if( !info->isWritable() ){ |
826 | locked = true; | 826 | locked = true; |
827 | pix = Resource::loadPixmap("locked" ); | 827 | pix = Resource::loadPixmap("locked" ); |
828 | } | 828 | } |
829 | } | 829 | } |
830 | } | 830 | } |
831 | new OFileSelectorItem( m_View, pix, name, | 831 | new OFileSelectorItem( m_View, pix, name, |
832 | info->lastModified().toString(), | 832 | info->lastModified().toString(), |
833 | QString::number( info->size() ), | 833 | QString::number( info->size() ), |
834 | dir, locked ); | 834 | dir, locked ); |
835 | } | 835 | } |
836 | 836 | ||
837 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) | 837 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) |
838 | { | 838 | { |
839 | if(!m_dir ) | 839 | if(!m_dir ) |
840 | return; | 840 | return; |
841 | //if( showDirs ) | 841 | //if( showDirs ) |
842 | { | 842 | { |
843 | bool locked=false; | 843 | bool locked=false; |
844 | QString name; | 844 | QString name; |
845 | QPixmap pix; | 845 | QPixmap pix; |
846 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ | 846 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ |
847 | locked = true; | 847 | locked = true; |
848 | if( symlink ){ | 848 | if( symlink ){ |
849 | pix = (*m_pixmaps)["symlinkedlocked"]; | 849 | pix = (*m_pixmaps)["symlinkedlocked"]; |
850 | }else{ | 850 | }else{ |
851 | pix = Resource::loadPixmap("lockedfolder" ); | 851 | pix = Resource::loadPixmap("lockedfolder" ); |
852 | } | 852 | } |
853 | }else{ | 853 | }else{ |
854 | if( symlink ){ | 854 | if( symlink ){ |
855 | pix = (*m_pixmaps)["dirsymlink" ]; | 855 | pix = (*m_pixmaps)["dirsymlink" ]; |
856 | }else{ | 856 | }else{ |
857 | pix = Resource::loadPixmap("folder" ); | 857 | pix = Resource::loadPixmap("folder" ); |
858 | } | 858 | } |
859 | } | 859 | } |
860 | if( symlink){ | 860 | if( symlink){ |
861 | name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink(); | 861 | name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink(); |
862 | 862 | ||
863 | }else{ | 863 | }else{ |
864 | //if(info->isReadable() ) | 864 | //if(info->isReadable() ) |
865 | name = info->fileName(); | 865 | name = info->fileName(); |
866 | } | 866 | } |
867 | 867 | ||
868 | new OFileSelectorItem(m_View, pix, | 868 | new OFileSelectorItem(m_View, pix, |
869 | name, info->lastModified().toString(), | 869 | name, info->lastModified().toString(), |
870 | QString::number(info->size() ),info->dirPath(true), locked, true ); | 870 | QString::number(info->size() ),info->dirPath(true), locked, true ); |
871 | 871 | ||
872 | } | 872 | } |
873 | } | 873 | } |
874 | 874 | ||
875 | void OFileSelector::setShowDirs(bool dir ) | 875 | void OFileSelector::setShowDirs(bool dir ) |
876 | { | 876 | { |
877 | m_dir = dir; | 877 | m_dir = dir; |
878 | reparse(); | 878 | reparse(); |
879 | } | 879 | } |
880 | 880 | ||
881 | void OFileSelector::slotFileSelected(const QString &string ) | 881 | void OFileSelector::slotFileSelected(const QString &string ) |
882 | { | 882 | { |
883 | if(m_shLne ) | 883 | if(m_shLne ) |
884 | m_edit->setText( string ); | 884 | m_edit->setText( string ); |
885 | 885 | ||
886 | emit fileSelected( string ); | 886 | emit fileSelected( string ); |
887 | // do AppLnk stuff | 887 | // do AppLnk stuff |
888 | } | 888 | } |
889 | 889 | ||
890 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) | 890 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) |
891 | { | 891 | { |
892 | slotFileSelected(lnk.name() ); | 892 | slotFileSelected(lnk.name() ); |
893 | emit fileSelected( lnk ); | 893 | emit fileSelected( lnk ); |
894 | } | 894 | } |
895 | 895 | ||
896 | void OFileSelector::slotSelectionChanged() // get the current items | 896 | void OFileSelector::slotSelectionChanged() // get the current items |
897 | // fixme | 897 | // fixme |
898 | { | 898 | { |
899 | qWarning("selection changed" ); | 899 | qWarning("selection changed" ); |
900 | } | 900 | } |
901 | 901 | ||
902 | void OFileSelector::slotCurrentChanged(QListViewItem *item ) | 902 | void OFileSelector::slotCurrentChanged(QListViewItem *item ) |
903 | { | 903 | { |
904 | qWarning("current changed" ); | 904 | // qWarning("current changed" ); |
905 | if( item == 0 ) | 905 | if( item == 0 ) |
906 | return; | 906 | return; |
907 | 907 | ||
908 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 908 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
909 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | 909 | OFileSelectorItem *sel = (OFileSelectorItem*)item; |
910 | if(!sel->isDir() ){ | 910 | if(!sel->isDir() ){ |
911 | qWarning("is not dir" ); | 911 | // qWarning("is not dir" ); |
912 | if(m_shLne ){ | 912 | if(m_shLne ){ |
913 | m_edit->setText(sel->text(1) ); | 913 | m_edit->setText(sel->text(1) ); |
914 | qWarning("setTexy" ); | 914 | // qWarning("setTexy" ); |
915 | } | 915 | } |
916 | } | 916 | } |
917 | }else { | 917 | }else { |
918 | qWarning("mode not extended" ); | 918 | qWarning("mode not extended" ); |
919 | } | 919 | } |
920 | } | 920 | } |
921 | 921 | ||
922 | // either select or change dir | 922 | // either select or change dir |
923 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int ) | 923 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int ) |
924 | { | 924 | { |
925 | if( item == 0 ) | 925 | if( item == 0 ) |
926 | return; | 926 | return; |
927 | 927 | ||
928 | if( button != Qt::LeftButton ) | 928 | if( button != Qt::LeftButton ) |
929 | return; | 929 | return; |
930 | 930 | ||
931 | qWarning("clicked" ); | 931 | // qWarning("clicked" ); |
932 | if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 932 | if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
933 | qWarning("inside" ); | 933 | // qWarning("inside" ); |
934 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | 934 | OFileSelectorItem *sel = (OFileSelectorItem*)item; |
935 | if(!sel->isLocked() ){ // not locked either changedir or open | 935 | if(!sel->isLocked() ){ // not locked either changedir or open |
936 | QStringList str = QStringList::split("->", sel->text(1) ); | 936 | QStringList str = QStringList::split("->", sel->text(1) ); |
937 | if(sel->isDir() ){ | 937 | if(sel->isDir() ){ |
938 | cd( sel->directory() + "/" + str[0] ); | 938 | cd( sel->directory() + "/" + str[0] ); |
939 | } else { | 939 | } else { |
940 | qWarning("file" ); | 940 | // qWarning("file" ); |
941 | if(m_shLne ) | 941 | if(m_shLne ) |
942 | m_edit->setText(str[0] ); | 942 | m_edit->setText(str[0] ); |
943 | emit fileSelected(str[0] ); | 943 | emit fileSelected(str[0] ); |
944 | // emit DocLnk need to do it | 944 | // emit DocLnk need to do it |
945 | } | 945 | } |
946 | } else { | 946 | } else { |
947 | qWarning( "locked" ); | 947 | qWarning( "locked" ); |
948 | } | 948 | } |
949 | }; | 949 | }; |
950 | } | 950 | } |
951 | 951 | ||
952 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) | 952 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) |
953 | { | 953 | { |
954 | if (item == 0 ) | 954 | if (item == 0 ) |
955 | return; | 955 | return; |
956 | 956 | ||
957 | if( button != Qt::RightButton ) | 957 | if( button != Qt::RightButton ) |
958 | return; | 958 | return; |
959 | qWarning("right button" ); | 959 | // qWarning("right button" ); |
960 | slotContextMenu(item); | 960 | slotContextMenu(item); |
961 | } | 961 | } |
962 | 962 | ||
963 | void OFileSelector::slotContextMenu(QListViewItem *item) | 963 | void OFileSelector::slotContextMenu(QListViewItem *item) |
964 | { | 964 | { |
965 | qWarning("context menu" ); | 965 | // qWarning("context menu" ); |
966 | if( item ==0 || !m_showPopup ) | 966 | if( item ==0 || !m_showPopup ) |
967 | return; | 967 | return; |
968 | 968 | ||
969 | if( m_custom !=0){ | 969 | if( m_custom !=0){ |
970 | m_custom->exec(); | 970 | m_custom->exec(); |
971 | }else{ | 971 | }else{ |
972 | QPopupMenu menu; | 972 | QPopupMenu menu; |
973 | QAction up; | 973 | QAction up; |
974 | up.setText("cd up"); | 974 | up.setText("cd up"); |
975 | up.addTo( &menu ); | 975 | up.addTo( &menu ); |
976 | connect(&up, SIGNAL(activated() ), | 976 | connect(&up, SIGNAL(activated() ), |
977 | this, SLOT(cdUP() ) ); | 977 | this, SLOT(cdUP() ) ); |
978 | 978 | ||
979 | QAction act; | 979 | QAction act; |
980 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | 980 | OFileSelectorItem *sel = (OFileSelectorItem*)item; |
981 | if(sel->isDir() ){ | 981 | if(sel->isDir() ){ |
982 | act.setText( tr("Change Directory") ); | 982 | act.setText( tr("Change Directory") ); |
983 | act.addTo(&menu ); | 983 | act.addTo(&menu ); |
984 | connect(&act, SIGNAL(activated() ), | 984 | connect(&act, SIGNAL(activated() ), |
985 | this, SLOT(slotChangedDir() ) ); | 985 | this, SLOT(slotChangedDir() ) ); |
986 | }else{ | 986 | }else{ |
987 | act.setText( tr("Open file" ) ); | 987 | act.setText( tr("Open file" ) ); |
988 | act.addTo( &menu ); | 988 | act.addTo( &menu ); |
989 | connect(&act, SIGNAL(activated() ), | 989 | connect(&act, SIGNAL(activated() ), |
990 | this, SLOT(slotOpen() ) ); | 990 | this, SLOT(slotOpen() ) ); |
991 | } | 991 | } |
992 | QAction rescan; | 992 | QAction rescan; |
993 | rescan.setText( tr("Rescan") ); | 993 | rescan.setText( tr("Rescan") ); |
994 | rescan.addTo( &menu ); | 994 | rescan.addTo( &menu ); |
995 | connect(&rescan, SIGNAL(activated() ), | 995 | connect(&rescan, SIGNAL(activated() ), |
996 | this, SLOT(slotRescan() ) ); | 996 | this, SLOT(slotRescan() ) ); |
997 | 997 | ||
998 | QAction rename; | 998 | QAction rename; |
999 | rename.setText( tr("Rename") ); | 999 | rename.setText( tr("Rename") ); |
1000 | rename.addTo( &menu ); | 1000 | rename.addTo( &menu ); |
1001 | connect(&rename, SIGNAL(activated() ), | 1001 | connect(&rename, SIGNAL(activated() ), |
1002 | this, SLOT(slotRename() ) ); | 1002 | this, SLOT(slotRename() ) ); |
1003 | 1003 | ||
1004 | menu.insertSeparator(); | 1004 | menu.insertSeparator(); |
1005 | QAction delItem; | 1005 | QAction delItem; |
1006 | delItem.setText( tr("Delete") ); | 1006 | delItem.setText( tr("Delete") ); |
1007 | delItem.addTo(&menu ); | 1007 | delItem.addTo(&menu ); |
1008 | connect(&delItem, SIGNAL(activated() ), | 1008 | connect(&delItem, SIGNAL(activated() ), |
1009 | this, SLOT(slotDelete() ) ); | 1009 | this, SLOT(slotDelete() ) ); |
1010 | 1010 | ||
1011 | menu.exec(QCursor::pos() ); | 1011 | menu.exec(QCursor::pos() ); |
1012 | } | 1012 | } |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | bool OFileSelector::cd(const QString &str ) | 1015 | bool OFileSelector::cd(const QString &str ) |
1016 | { | 1016 | { |
1017 | qWarning(" dir %s", str.latin1() ); | 1017 | // qWarning(" dir %s", str.latin1() ); |
1018 | QDir dir( str); | 1018 | QDir dir( str); |
1019 | if(dir.exists() ){ | 1019 | if(dir.exists() ){ |
1020 | m_currentDir = dir.absPath(); | 1020 | m_currentDir = dir.absPath(); |
1021 | reparse(); | 1021 | reparse(); |
1022 | if(m_shTool ){ | 1022 | if(m_shTool ){ |
1023 | int count = m_location->count(); | 1023 | int count = m_location->count(); |
1024 | insertLocationPath( str ,count ); | 1024 | insertLocationPath( str ,count ); |
1025 | m_location->setCurrentItem( count ); | 1025 | m_location->setCurrentItem( count ); |
1026 | } | 1026 | } |
1027 | return true; | 1027 | return true; |
1028 | } | 1028 | } |
1029 | return false; | 1029 | return false; |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | void OFileSelector::insertLocationPath(const QString ¤tPath, int count) { | 1032 | void OFileSelector::insertLocationPath(const QString ¤tPath, int count) { |
1033 | QStringList pathList; | 1033 | QStringList pathList; |
1034 | bool underDog = FALSE; | ||
1034 | for(int i=0;i<count;i++) { | 1035 | for(int i=0;i<count;i++) { |
1035 | pathList << m_location->text(i); | 1036 | pathList << m_location->text(i); |
1037 | if( m_location->text(i) == currentPath) | ||
1038 | underDog = TRUE; | ||
1036 | } | 1039 | } |
1037 | if( pathList.grep( currentPath,TRUE).isEmpty() ) { | 1040 | if( !underDog) { |
1038 | m_location->clear(); | 1041 | m_location->clear(); |
1039 | if( currentPath.left(2)=="//") | 1042 | if( currentPath.left(2)=="//") |
1040 | pathList.append( currentPath.right(currentPath.length()-1) ); | 1043 | pathList.append( currentPath.right(currentPath.length()-1) ); |
1041 | else | 1044 | else |
1042 | pathList.append( currentPath ); | 1045 | pathList.append( currentPath ); |
1043 | m_location->insertStringList( pathList,-1); | 1046 | m_location->insertStringList( pathList,-1); |
1044 | } | 1047 | } |
1045 | } | 1048 | } |
1046 | 1049 | ||
1047 | void OFileSelector::slotChangedDir() | 1050 | void OFileSelector::slotChangedDir() |
1048 | { | 1051 | { |
1049 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 1052 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
1050 | if(sel->isDir() ){ | 1053 | if(sel->isDir() ){ |
1051 | QStringList str = QStringList::split("->", sel->text(1) ); | 1054 | QStringList str = QStringList::split("->", sel->text(1) ); |
1052 | cd( sel->directory() + "/" + str[0] ); | 1055 | cd( sel->directory() + "/" + str[0] ); |
1053 | 1056 | ||
1054 | } | 1057 | } |
1055 | } | 1058 | } |
1056 | 1059 | ||
1057 | void OFileSelector::slotOpen() | 1060 | void OFileSelector::slotOpen() |
1058 | { | 1061 | { |
1059 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 1062 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
1060 | if(!sel->isDir() ){ | 1063 | if(!sel->isDir() ){ |
1061 | QStringList str = QStringList::split("->", sel->text(1) ); | 1064 | QStringList str = QStringList::split("->", sel->text(1) ); |
1062 | slotFileSelected( str[0] ); | 1065 | slotFileSelected( str[0] ); |
1063 | } | 1066 | } |
1064 | } | 1067 | } |
1065 | 1068 | ||
1066 | void OFileSelector::slotRescan() | 1069 | void OFileSelector::slotRescan() |
1067 | { | 1070 | { |
1068 | reparse(); | 1071 | reparse(); |
1069 | } | 1072 | } |
1070 | 1073 | ||
1071 | void OFileSelector::slotRename() | 1074 | void OFileSelector::slotRename() |
1072 | { | 1075 | { |
1073 | // rename inline | 1076 | // rename inline |
1074 | } | 1077 | } |
1075 | 1078 | ||
1076 | void OFileSelector::slotDelete() | 1079 | void OFileSelector::slotDelete() |
1077 | { | 1080 | { |
1078 | qWarning("delete slot" ); | 1081 | // qWarning("delete slot" ); |
1079 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 1082 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
1080 | QStringList list = QStringList::split("->", sel->text(1) ); | 1083 | QStringList list = QStringList::split("->", sel->text(1) ); |
1081 | if( sel->isDir() ){ | 1084 | if( sel->isDir() ){ |
1082 | QString str = QString::fromLatin1("rm -rf ") + list[0]; //better safe than sorry | 1085 | QString str = QString::fromLatin1("rm -rf ") + list[0]; //better safe than sorry |
1083 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], | 1086 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], |
1084 | tr("Yes"),tr("No"),0,1,1) ) { | 1087 | tr("Yes"),tr("No"),0,1,1) ) { |
1085 | case 0: | 1088 | case 0: |
1086 | ::system(str.utf8().data() ); | 1089 | ::system(str.utf8().data() ); |
1087 | break; | 1090 | break; |
1088 | } | 1091 | } |
1089 | } else { | 1092 | } else { |
1090 | QFile::remove( list[0] ); | 1093 | QFile::remove( list[0] ); |
1091 | } | 1094 | } |
1092 | m_View->takeItem( sel ); | 1095 | m_View->takeItem( sel ); |
1093 | delete sel; | 1096 | delete sel; |
1094 | } | 1097 | } |
1095 | 1098 | ||
1096 | void OFileSelector::cdUP() | 1099 | void OFileSelector::cdUP() |
1097 | { | 1100 | { |
1098 | QDir dir( m_currentDir ); | 1101 | QDir dir( m_currentDir ); |
1099 | dir.cdUp(); | 1102 | dir.cdUp(); |
1100 | if(dir.exists() ){ | 1103 | if(dir.exists() ){ |
1101 | m_currentDir = dir.absPath(); | 1104 | m_currentDir = dir.absPath(); |
1102 | reparse(); | 1105 | reparse(); |
1103 | int count = m_location->count(); | 1106 | int count = m_location->count(); |
1104 | insertLocationPath( m_currentDir,count ); | 1107 | insertLocationPath( m_currentDir, count); |
1105 | m_location->setCurrentItem( indexFromString(m_currentDir )); | 1108 | m_location->setCurrentItem( indexByString( m_location, m_currentDir)); |
1106 | //this wont work in all instances | 1109 | //this wont work in all instances |
1107 | // FIXME | 1110 | // FIXME |
1108 | } | 1111 | } |
1109 | } | 1112 | } |
1110 | 1113 | ||
1111 | int OFileSelector::indexFromString(const QString &str) { | ||
1112 | |||
1113 | for(int i=0;i< m_location->count();i++) { | ||
1114 | if(str == m_location->text(i)) | ||
1115 | return i; | ||
1116 | } | ||
1117 | return 0; | ||
1118 | } | ||
1119 | |||
1120 | void OFileSelector::slotHome() | 1114 | void OFileSelector::slotHome() |
1121 | { | 1115 | { |
1122 | cd(QDir::homeDirPath() ); | 1116 | cd(QDir::homeDirPath() ); |
1123 | } | 1117 | } |
1124 | 1118 | ||
1125 | void OFileSelector::slotDoc() | 1119 | void OFileSelector::slotDoc() |
1126 | { | 1120 | { |
1127 | cd(QDir::homeDirPath() + "/Documents" ); | 1121 | cd(QDir::homeDirPath() + "/Documents" ); |
1128 | } | 1122 | } |
1129 | 1123 | ||
1130 | void OFileSelector::slotNavigate() | 1124 | void OFileSelector::slotNavigate() |
1131 | { | 1125 | { |
1132 | 1126 | ||
1133 | } | 1127 | } |
1134 | 1128 | ||
1135 | void OFileSelector::locationComboActivated(const QString & file ) { | 1129 | void OFileSelector::locationComboActivated(const QString & file ) { |
1136 | cd(file.left(file.find("<-",0,TRUE))); | 1130 | cd(file.left(file.find("<-",0,TRUE))); |
1137 | reparse(); | 1131 | reparse(); |
1138 | } | 1132 | } |
1133 | |||
1134 | void OFileSelector::locationComboChanged() { | ||
1135 | cd( m_location->lineEdit()->text()); | ||
1136 | reparse(); | ||
1137 | } | ||
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index 81a9e63..babe09f 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h | |||
@@ -1,281 +1,281 @@ | |||
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=2, FILESELECTOR=4, DIR=8 }; | 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 | ~OFileSelector() {}; | 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 dirSelected(const QString &dir ); |
184 | void closeMe(); | 184 | void closeMe(); |
185 | void ok(); | 185 | void ok(); |
186 | void cancel(); | 186 | void cancel(); |
187 | 187 | ||
188 | protected slots: | 188 | protected slots: |
189 | void slotOk(); | 189 | void slotOk(); |
190 | void slotCancel(); | 190 | void slotCancel(); |
191 | void slotViewCheck(const QString & ); | 191 | void slotViewCheck(const QString & ); |
192 | void slotMimeCheck(const QString & ); | 192 | void slotMimeCheck(const QString & ); |
193 | void locationComboActivated(const QString & ); | 193 | void locationComboActivated(const QString & ); |
194 | void insertLocationPath(const QString &, int); | 194 | void insertLocationPath(const QString &, int); |
195 | int indexFromString(const QString &); | 195 | void locationComboChanged(); |
196 | protected: | 196 | protected: |
197 | void init(); | 197 | void init(); |
198 | void updateMimes(); | 198 | void updateMimes(); |
199 | 199 | ||
200 | protected: | 200 | protected: |
201 | 201 | ||
202 | private: | 202 | private: |
203 | int m_mode, m_selector; | 203 | int m_mode, m_selector; |
204 | QComboBox *m_location, *m_mimeCheck, *m_viewCheck; | 204 | QComboBox *m_location, *m_mimeCheck, *m_viewCheck; |
205 | QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; | 205 | QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; |
206 | QPushButton *m_reread, *m_up; | 206 | QPushButton *m_reread, *m_up; |
207 | QListView *m_View; | 207 | QListView *m_View; |
208 | QCheckBox *m_checkPerm; | 208 | QCheckBox *m_checkPerm; |
209 | QWidget *m_pseudo; | 209 | QWidget *m_pseudo; |
210 | QVBoxLayout *m_pseudoLayout; | 210 | QVBoxLayout *m_pseudoLayout; |
211 | 211 | ||
212 | QString m_currentDir; | 212 | QString m_currentDir; |
213 | QString m_name; | 213 | QString m_name; |
214 | QStringList m_mimetypes; | 214 | QStringList m_mimetypes, requestedMimeTypesList; |
215 | 215 | ||
216 | FileSelector *m_select; | 216 | FileSelector *m_select; |
217 | QWidgetStack *m_stack; | 217 | QWidgetStack *m_stack; |
218 | QVBoxLayout *m_lay; | 218 | QVBoxLayout *m_lay; |
219 | QGridLayout *m_Oselector; | 219 | QGridLayout *m_Oselector; |
220 | 220 | ||
221 | QHBoxLayout *m_boxToolbar; | 221 | QHBoxLayout *m_boxToolbar; |
222 | QHBoxLayout *m_boxOk; | 222 | QHBoxLayout *m_boxOk; |
223 | QHBoxLayout *m_boxName; | 223 | QHBoxLayout *m_boxName; |
224 | QHBoxLayout *m_boxView; | 224 | QHBoxLayout *m_boxView; |
225 | 225 | ||
226 | QPopupMenu *m_custom; | 226 | QPopupMenu *m_custom; |
227 | 227 | ||
228 | QLineEdit *m_edit; | 228 | QLineEdit *m_edit; |
229 | QLabel *m_fnLabel; | 229 | QLabel *m_fnLabel; |
230 | bool m_shTool:1; | 230 | bool m_shTool:1; |
231 | bool m_shPerm:1; | 231 | bool m_shPerm:1; |
232 | bool m_shLne:1; | 232 | bool m_shLne:1; |
233 | bool m_shChooser:1; | 233 | bool m_shChooser:1; |
234 | bool m_shYesNo:1; | 234 | bool m_shYesNo:1; |
235 | bool m_boCheckPerm:1; | 235 | bool m_boCheckPerm:1; |
236 | bool m_autoMime:1; | 236 | bool m_autoMime:1; |
237 | bool m_case:1; | 237 | bool m_case:1; |
238 | bool m_dir:1; | 238 | bool m_dir:1; |
239 | bool m_files:1; | 239 | bool m_files:1; |
240 | bool m_showPopup:1; | 240 | bool m_showPopup:1; |
241 | 241 | ||
242 | // implementation todo | 242 | // implementation todo |
243 | virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); | 243 | virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); |
244 | virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); | 244 | virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); |
245 | virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){}; | 245 | virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){}; |
246 | void delItems(); | 246 | void delItems(); |
247 | void initializeName(); | 247 | void initializeName(); |
248 | void initializeYes(); | 248 | void initializeYes(); |
249 | void initializeChooser(); | 249 | void initializeChooser(); |
250 | void initializeListView(); | 250 | void initializeListView(); |
251 | void initPics(); | 251 | void initPics(); |
252 | bool compliesMime(const QString &path, const QString &mime); | 252 | bool compliesMime(const QString &path, const QString &mime); |
253 | 253 | ||
254 | class OFileSelectorPrivate; | 254 | class OFileSelectorPrivate; |
255 | OFileSelectorPrivate *d; | 255 | OFileSelectorPrivate *d; |
256 | static QMap<QString,QPixmap> *m_pixmaps; | 256 | static QMap<QString,QPixmap> *m_pixmaps; |
257 | 257 | ||
258 | private slots: | 258 | private slots: |
259 | void slotFileSelected(const QString & ); // not really meant to be a slot | 259 | void slotFileSelected(const QString & ); // not really meant to be a slot |
260 | void slotFileBridgeSelected( const DocLnk & ); | 260 | void slotFileBridgeSelected( const DocLnk & ); |
261 | virtual void slotSelectionChanged(); | 261 | virtual void slotSelectionChanged(); |
262 | virtual void slotCurrentChanged(QListViewItem* ); | 262 | virtual void slotCurrentChanged(QListViewItem* ); |
263 | virtual void slotClicked( int, QListViewItem *item, const QPoint &, int); | 263 | virtual void slotClicked( int, QListViewItem *item, const QPoint &, int); |
264 | virtual void slotRightButton(int, QListViewItem *, const QPoint &, int ); | 264 | virtual void slotRightButton(int, QListViewItem *, const QPoint &, int ); |
265 | virtual void slotContextMenu( QListViewItem *item); | 265 | virtual void slotContextMenu( QListViewItem *item); |
266 | // listview crap see above | 266 | // listview crap see above |
267 | // PopupMenu crap | 267 | // PopupMenu crap |
268 | virtual void slotChangedDir(); | 268 | virtual void slotChangedDir(); |
269 | virtual void slotOpen(); | 269 | virtual void slotOpen(); |
270 | virtual void slotRescan(); | 270 | virtual void slotRescan(); |
271 | virtual void slotRename(); | 271 | virtual void slotRename(); |
272 | virtual void slotDelete(); | 272 | virtual void slotDelete(); |
273 | virtual void cdUP(); | 273 | virtual void cdUP(); |
274 | virtual void slotHome(); | 274 | virtual void slotHome(); |
275 | virtual void slotDoc(); | 275 | virtual void slotDoc(); |
276 | virtual void slotNavigate( ); | 276 | virtual void slotNavigate( ); |
277 | }; | 277 | }; |
278 | 278 | ||
279 | 279 | ||
280 | #endif | 280 | #endif |
281 | 281 | ||