summaryrefslogtreecommitdiff
authorzecke <zecke>2002-04-01 01:24:44 (UTC)
committer zecke <zecke>2002-04-01 01:24:44 (UTC)
commit84850cd8811fc29aa39ecd2452884bf48ea27e92 (patch) (unidiff)
tree339584aec050e0084560e05d2460477354619d8f
parent66357a57409435e5967887af026bc1cf1d725f56 (diff)
downloadopie-84850cd8811fc29aa39ecd2452884bf48ea27e92.zip
opie-84850cd8811fc29aa39ecd2452884bf48ea27e92.tar.gz
opie-84850cd8811fc29aa39ecd2452884bf48ea27e92.tar.bz2
Almost done
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/TODO4
-rw-r--r--libopie/ofileselector.cc187
-rw-r--r--libopie/ofileselector.h9
3 files changed, 183 insertions, 17 deletions
diff --git a/libopie/TODO b/libopie/TODO
index c1bf6d1..a4e1ada 100644
--- a/libopie/TODO
+++ b/libopie/TODO
@@ -1,17 +1,19 @@
1- xmltree done 1- xmltree done
2 2
3- tododb 3- tododb
4 - set Alarms 4 - set Alarms
5 - multiple categories 5 - multiple categories
6 - Attendees 6 - Attendees
7 7
8- OFileSelector 8- OFileSelector
9 - DocLnk when not in Document Mode 9 - DocLnk when not in Document Mode ( and vice versa )
10 - MultipleDocuments
10 - TreeView have a own OFileSelectorItem for this 11 - TreeView have a own OFileSelectorItem for this
11 - IconView add a QIconView to the widgetstack 12 - IconView add a QIconView to the widgetstack
12 - Move OFileSelectorItem to it's own files 13 - Move OFileSelectorItem to it's own files
13 - add functions to access the member variables 14 - add functions to access the member variables
14 - debug 15 - debug
16 - new Dirs created inside the listview
15 17
16- Clickable labels? 18- Clickable labels?
17 Harlekin you wanted them in the libs? \ No newline at end of file 19 Harlekin you wanted them in the libs? \ No newline at end of file
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index b583125..14f035e 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -1,900 +1,1059 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 3             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include <qnamespace.h> 29#include <qnamespace.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qcombobox.h> 31#include <qcombobox.h>
32#include <qhbox.h> 32#include <qhbox.h>
33#include <qvbox.h> 33#include <qvbox.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qwidgetstack.h> 35#include <qwidgetstack.h>
36#include <qlineedit.h> 36#include <qlineedit.h>
37#include <qcheckbox.h> 37#include <qcheckbox.h>
38#include <qlabel.h> 38#include <qlabel.h>
39#include <qheader.h> 39#include <qheader.h>
40#include <qdir.h> 40#include <qdir.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qaction.h> 42#include <qaction.h>
43#include <qpopupmenu.h> 43#include <qpopupmenu.h>
44#include <qcursor.h> 44#include <qcursor.h>
45 45
46#include <qpe/qpeapplication.h> 46#include <qpe/qpeapplication.h>
47#include <qpe/fileselector.h> 47#include <qpe/fileselector.h>
48#include <qpe/applnk.h> 48#include <qpe/applnk.h>
49#include <qpe/global.h> 49#include <qpe/global.h>
50#include <qpe/mimetype.h> 50#include <qpe/mimetype.h>
51#include <qpe/resource.h> 51#include <qpe/resource.h>
52#include <qpe/storage.h>
52 53
53#include <unistd.h> 54#include <unistd.h>
54#include <stdlib.h> 55#include <stdlib.h>
55#include <sys/stat.h> 56#include <sys/stat.h>
56 57
57#include "ofileselector.h" 58#include "ofileselector.h"
58 59
59QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; 60QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0;
60 61
61namespace { 62namespace {
62 63
63 int indexByString( const QComboBox *box, const QString &str ){ 64 int indexByString( const QComboBox *box, const QString &str ){
64 int index= -1; 65 int index= -1;
65 for(int i= 0; i < box->count(); i++ ){ 66 for(int i= 0; i < box->count(); i++ ){
66 qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() ); 67 qWarning("str T%sT boxT%sT", str.latin1(), box->text(i).latin1() );
67 if( str == box->text(i ) ){ 68 if( str == box->text(i ) ){
68 index= i; 69 index= i;
69 break; 70 break;
70 } 71 }
71 } 72 }
72 return index; 73 return index;
73 } 74 }
74 75
75}; 76};
76 77
77 78
78OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, 79OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName,
79 const QString &fileName, const QStringList mimetypes ) : QWidget( wid ) 80 const QString &fileName, const QStringList mimetypes ) : QWidget( wid )
80{ 81{
81 m_selector = selector; 82 m_selector = selector;
82 m_currentDir = dirName; 83 m_currentDir = dirName;
83 m_name = fileName; 84 m_name = fileName;
84 m_mimetypes = mimetypes; 85 m_mimetypes = mimetypes;
85 if( mimetypes.isEmpty() ) 86 if( mimetypes.isEmpty() )
86 m_autoMime = true; 87 m_autoMime = true;
87 88
88 m_mode = mode; 89 m_mode = mode;
89 m_shTool = true; 90 m_shTool = true;
90 m_shPerm = true; 91 m_shPerm = true;
91 m_shLne = true; 92 m_shLne = true;
92 m_shChooser = true; 93 m_shChooser = true;
93 m_shYesNo = true; 94 m_shYesNo = true;
94 // for FILESELECTOR only view is interesting 95 // for FILESELECTOR only view is interesting
95 m_location = 0; 96 m_location = 0;
96 m_homeButton = 0; 97 m_homeButton = 0;
97 m_docButton = 0; 98 m_docButton = 0;
98 m_hideButton = 0; 99 m_hideButton = 0;
99 m_ok = 0; 100 m_ok = 0;
100 m_cancel = 0; 101 m_cancel = 0;
101 m_reread = 0; 102 m_reread = 0;
102 m_up = 0; 103 m_up = 0;
103 m_View = 0; 104 m_View = 0;
104 m_select = 0; 105 m_select = 0;
105 m_stack = 0; 106 m_stack = 0;
106 107
107 m_select = 0; 108 m_select = 0;
108 m_stack = 0; 109 m_stack = 0;
109 m_lay = 0; 110 m_lay = 0;
110 m_boxToolbar = 0; 111 m_boxToolbar = 0;
111 m_boxOk = 0; 112 m_boxOk = 0;
112 m_edit = 0; 113 m_edit = 0;
113 114
114 m_fnLabel = 0; 115 m_fnLabel = 0;
115 m_checkPerm = 0; 116 m_checkPerm = 0;
116 m_mimeCheck = 0; 117 m_mimeCheck = 0;
117 m_viewCheck = 0; 118 m_viewCheck = 0;
118 119
120 m_pseudo = 0;
121 m_pseudoLayout = 0;
122
119 m_dir = true; 123 m_dir = true;
120 m_files = true; 124 m_files = true;
121 m_custom = 0; 125 m_custom = 0;
126 m_showPopup = true;
122 127
123 if(m_pixmaps == 0 ) // init the pixmaps 128 if(m_pixmaps == 0 ) // init the pixmaps
124 initPics(); 129 initPics();
125 130
126 m_lay = new QVBoxLayout(this); 131 m_lay = new QVBoxLayout(this);
127 init(); 132 init();
128 m_edit->setText( fileName ); 133 m_edit->setText( fileName );
129} 134}
130void OFileSelector::initPics() 135void OFileSelector::initPics()
131{ 136{
132 qWarning("init pics" ); 137 qWarning("init pics" );
133 m_pixmaps = new QMap<QString,QPixmap>; 138 m_pixmaps = new QMap<QString,QPixmap>;
134 QPixmap pm = Resource::loadPixmap( "folder" ); 139 QPixmap pm = Resource::loadPixmap( "folder" );
135 QPixmap lnk = Resource::loadPixmap( "symlink" ); 140 QPixmap lnk = Resource::loadPixmap( "symlink" );
136 QPainter painter( &pm ); 141 QPainter painter( &pm );
137 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 142 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
138 pm.setMask( pm.createHeuristicMask( FALSE ) ); 143 pm.setMask( pm.createHeuristicMask( FALSE ) );
139 m_pixmaps->insert("dirsymlink", pm ); 144 m_pixmaps->insert("dirsymlink", pm );
140 145
141 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); 146 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" );
142 QPainter pen(&pm2 ); 147 QPainter pen(&pm2 );
143 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); 148 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk );
144 pm2.setMask( pm2.createHeuristicMask( FALSE ) ); 149 pm2.setMask( pm2.createHeuristicMask( FALSE ) );
145 m_pixmaps->insert("symlinkedlocked", pm2 ); 150 m_pixmaps->insert("symlinkedlocked", pm2 );
146 151
147}; 152};
148// let's initialize the gui 153// let's initialize the gui
149/** 154/**
150 -------------------- 155 --------------------
151 | cmbBox Button | 156 | cmbBox Button |
152 -------------------- 157 --------------------
153 | FileSlector | 158 | FileSlector |
154 | or | 159 | or |
155 | OSelector | 160 | OSelector |
156 | | 161 | |
157 | | 162 | |
158 ____________________ 163 ____________________
159 | LineEdit | 164 | LineEdit |
160 ____________________ 165 ____________________
161 | Permission Bar | 166 | Permission Bar |
162 ____________________ 167 ____________________
163 | ViewChoose | 168 | ViewChoose |
164 ____________________ 169 ____________________
165 | Save Cancel| 170 | Save Cancel|
166 ____________________ 171 ____________________
167 */ 172 */
168void OFileSelector::delItems() 173void OFileSelector::delItems()
169{ 174{
170 QLayoutIterator it = m_lay->iterator(); 175 QLayoutIterator it = m_lay->iterator();
171 while ( it.current() != 0 ){ 176 while ( it.current() != 0 ){
172 it.deleteCurrent(); 177 it.deleteCurrent();
173 } 178 }
174} 179}
175void OFileSelector::init() 180void OFileSelector::init()
176{ 181{
177 182
178 m_stack = new QWidgetStack(this, "wstack" ); 183 m_stack = new QWidgetStack(this, "wstack" );
179 if( m_selector == NORMAL ){ 184 if( m_selector == NORMAL ){
180 QString currMime; 185 QString currMime;
181 if( m_mimeCheck != 0 ) 186 if( m_mimeCheck != 0 )
182 currMime = m_mimeCheck->currentText(); 187 currMime = m_mimeCheck->currentText();
183 188
184 updateMimes(); 189 updateMimes();
185 m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); 190 m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE );
186 m_stack->addWidget(m_select, NORMAL ); 191 m_stack->addWidget(m_select, NORMAL );
187 m_lay->addWidget(m_stack ); 192 m_lay->addWidget(m_stack );
188 m_stack->raiseWidget(NORMAL ); 193 m_stack->raiseWidget(NORMAL );
189 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); 194 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) );
190 }else { 195 }else {
191 initializeListView(); 196 initializeListView();
192 } 197 }
193 198
194 if(m_shLne ){ 199 if(m_shLne ){
195 initializeName(); 200 initializeName();
196 } 201 }
197 202
198 if(m_shPerm ){ 203 if(m_shPerm ){
199 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); 204 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" );
200 m_checkPerm->setChecked( false ); 205 m_checkPerm->setChecked( false );
201 m_lay->addWidget(m_checkPerm ); 206 m_lay->addWidget(m_checkPerm );
202 } 207 }
203 208
204 if( m_shChooser ) 209 if( m_shChooser )
205 initializeChooser(); 210 initializeChooser();
206 211
207 if(m_shYesNo ) 212 if(m_shYesNo )
208 initializeYes(); 213 initializeYes();
209 214
210 215
211}; 216};
212 217
213void OFileSelector::setYesCancelVisible( bool show ) 218void OFileSelector::setYesCancelVisible( bool show )
214{ 219{
215 if ( show == m_shYesNo ) 220 if ( show == m_shYesNo )
216 return; 221 return;
217 m_shYesNo = show; 222 m_shYesNo = show;
218 if( !show ){ 223 if( !show ){
219 delete m_ok; 224 delete m_ok;
220 delete m_cancel; 225 delete m_cancel;
221 m_ok = 0; 226 m_ok = 0;
222 m_cancel = 0; 227 m_cancel = 0;
223 // delete m_boxOk; all ready deleted in delItems 228 // delete m_boxOk; all ready deleted in delItems
224 } 229 }
225 updateLay(); // recreate it and save the other states 230 updateLay(); // recreate it and save the other states
226} 231}
227 232
228void OFileSelector::setToolbarVisible( bool show ) 233void OFileSelector::setToolbarVisible( bool show )
229{ 234{
230 if ( m_shTool == show ) 235 if ( m_shTool == show )
231 return; 236 return;
232 /* if( show ){ 237 if(!m_shTool ){
233 238 delete m_boxToolbar;
234 }else { 239 delete m_homeButton;
235 240 delete m_docButton;
236 }*/ 241 delete m_location;
242 delete m_up;
243 m_boxToolbar = 0;
244 m_homeButton = 0;
245 m_docButton = 0;
246 m_location = 0;
247 m_up = 0;
248 };
249 updateLay();// overkill fix it
237} 250}
238 251
239void OFileSelector::setPermissionBarVisible( bool show ) 252void OFileSelector::setPermissionBarVisible( bool show )
240{ 253{
241 if( show == m_shPerm ) 254 if( show == m_shPerm )
242 return; 255 return;
243 256
244 m_shPerm = show; 257 m_shPerm = show;
245 258
246 updateLay(); 259 updateLay();
247} 260}
248void OFileSelector::setLineEditVisible( bool show ) 261void OFileSelector::setLineEditVisible( bool show )
249{ 262{
250 if( show == m_shLne ) 263 if( show == m_shLne )
251 return; 264 return;
252 265
253 m_shLne = show; 266 m_shLne = show;
254 if( !show ){ 267 if( !show ){
255 delete m_edit; 268 delete m_edit;
256 delete m_fnLabel; 269 delete m_fnLabel;
257 m_edit = 0; 270 m_edit = 0;
258 m_fnLabel = 0; 271 m_fnLabel = 0;
259 //delete m_boxName; will be deleted 272 //delete m_boxName; will be deleted
260 } 273 }
261 updateLay(); 274 updateLay();
262} 275}
263void OFileSelector::setChooserVisible( bool show ) 276void OFileSelector::setChooserVisible( bool show )
264{ 277{
265 if( show = m_shChooser ) 278 if( show = m_shChooser )
266 return; 279 return;
267 m_shChooser = show; 280 m_shChooser = show;
268 if( !show ){ 281 if( !show ){
269 delete m_mimeCheck; 282 delete m_mimeCheck;
270 delete m_viewCheck; 283 delete m_viewCheck;
271 m_mimeCheck = 0; 284 m_mimeCheck = 0;
272 m_viewCheck = 0; 285 m_viewCheck = 0;
273 } 286 }
274 updateLay(); 287 updateLay();
275} 288}
276QCheckBox* OFileSelector::permissionCheckbox( ) 289QCheckBox* OFileSelector::permissionCheckbox( )
277{ 290{
278 return m_checkPerm; 291 return m_checkPerm;
279} 292}
280void OFileSelector::setCaseSensetive( bool caSe ) 293void OFileSelector::setCaseSensetive( bool caSe )
281{ 294{
282 m_case = caSe; 295 m_case = caSe;
283 reparse(); 296 reparse();
284} 297}
285void OFileSelector::setShowFiles(bool files ){ 298void OFileSelector::setShowFiles(bool files ){
286 m_files = files; 299 m_files = files;
287 reparse(); 300 reparse();
288} 301}
289void OFileSelector::setPopupMenu(QPopupMenu *pop ) 302void OFileSelector::setPopupMenu(QPopupMenu *pop )
290{ 303{
291 //delete oldpopup; 304 //delete oldpopup;
292 m_custom = pop; 305 m_custom = pop;
293} 306}
294bool OFileSelector::setPermission( ) const 307bool OFileSelector::setPermission( ) const
295{ 308{
296 if( m_checkPerm == 0 ) 309 if( m_checkPerm == 0 )
297 return false; 310 return false;
298 else 311 else
299 return m_checkPerm->isChecked(); 312 return m_checkPerm->isChecked();
300} 313}
301void OFileSelector::setPermissionChecked( bool check ) 314void OFileSelector::setPermissionChecked( bool check )
302{ 315{
303 if( m_checkPerm == 0 ) 316 if( m_checkPerm == 0 )
304 return; 317 return;
305 m_checkPerm->setChecked( check ); 318 m_checkPerm->setChecked( check );
306} 319}
307QString OFileSelector::selectedName( )const 320QString OFileSelector::selectedName( )const
308{ 321{
309 QString string; 322 QString string;
310 if( m_selector == NORMAL ){ 323 if( m_selector == NORMAL ){
311 const DocLnk *lnk = m_select->selected(); 324 const DocLnk *lnk = m_select->selected();
312 string = lnk->file(); 325 string = lnk->file();
313 }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { 326 }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) {
314 QListViewItem *item = m_View->currentItem(); 327 QListViewItem *item = m_View->currentItem();
315 if(item != 0 ){ 328 if(item != 0 ){
316 string = item->text( 1 ); 329 string = item->text( 1 );
317 } 330 }
318 } 331 }
319 return string; 332 return string;
320} 333}
321QStringList OFileSelector::selectedNames()const 334QStringList OFileSelector::selectedNames()const
322{ 335{
323 QStringList list; 336 QStringList list;
324 return list; 337 return list;
325} 338}
326DocLnk OFileSelector::selectedDocument( )const 339DocLnk OFileSelector::selectedDocument( )const
327{ 340{
328 DocLnk lnk; 341 DocLnk lnk;
329 return lnk; 342 return lnk;
330} 343}
331void OFileSelector::updateLay() 344void OFileSelector::updateLay()
332{ 345{
333 /* if( m_shTool ) 346 /* if( m_shTool )
334 // 347 //
335 else 348 else
336 // hide 349 // hide
337 */ 350 */
338 // save the state 351 // save the state
339 bool check = false; 352 bool check = false;
340 if( m_checkPerm != 0 ) 353 if( m_checkPerm != 0 )
341 check = m_checkPerm->isChecked(); 354 check = m_checkPerm->isChecked();
342 QString text; 355 QString text;
343 356
344 if( m_edit != 0 ) 357 if( m_edit != 0 )
345 text = m_edit->text(); 358 text = m_edit->text();
346 // save current mimetype 359 // save current mimetype
347 360
348 delItems(); 361 delItems();
349 delete m_checkPerm; 362 delete m_checkPerm;
350 m_checkPerm = 0; 363 m_checkPerm = 0;
351 delete m_edit; 364 delete m_edit;
352 m_edit = 0; 365 m_edit = 0;
353 delete m_fnLabel; 366 delete m_fnLabel;
354 m_fnLabel = 0; 367 m_fnLabel = 0;
355 delete m_ok; 368 delete m_ok;
356 m_ok = 0; 369 m_ok = 0;
357 delete m_cancel; 370 delete m_cancel;
358 m_cancel = 0; 371 m_cancel = 0;
359 delete m_mimeCheck; 372 delete m_mimeCheck;
360 m_mimeCheck = 0; 373 m_mimeCheck = 0;
361 delete m_viewCheck; 374 delete m_viewCheck;
362 m_viewCheck = 0; 375 m_viewCheck = 0;
363 delete m_select; // test 376 delete m_select; // test
364 delete m_stack; 377 delete m_stack;
365 //delete m_list; 378 //delete m_list;
366 init(); 379 init();
367 if( m_shLne ) 380 if( m_shLne )
368 m_edit->setText(text ); 381 m_edit->setText(text );
369 if( m_shPerm ) 382 if( m_shPerm )
370 m_checkPerm->setChecked(check ); 383 m_checkPerm->setChecked(check );
371} 384}
372// let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve 385// let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve
373// insert QListViewItems with the right options 386// insert QListViewItems with the right options
374bool OFileSelector::compliesMime(const QString &path, const QString &mime ) 387bool OFileSelector::compliesMime(const QString &path, const QString &mime )
375{ 388{
376 if( mime == "All" ) 389 if( mime == "All" )
377 return true; 390 return true;
378 MimeType type( path ); 391 MimeType type( path );
379 if( type.id() == mime ) 392 if( type.id() == mime )
380 return true; 393 return true;
381 return false; 394 return false;
382} 395}
383 396
384void OFileSelector::reparse() 397void OFileSelector::reparse()
385{ 398{
386 if(m_View== 0 || m_selector == NORMAL) 399 if(m_View== 0 || m_selector == NORMAL)
387 return; 400 return;
388 401
389 m_View->clear(); 402 m_View->clear();
390 403
391 404
392 QString currMime =m_mimeCheck->currentText(); 405 QString currMime =m_mimeCheck->currentText();
393 // update the mimetype now 406 // update the mimetype now
394 if( m_autoMime ) { 407 if( m_autoMime ) {
395 QDir dir( m_currentDir ); 408 QDir dir( m_currentDir );
396 m_mimetypes.clear(); 409 m_mimetypes.clear();
397 m_mimeCheck->clear(); 410 m_mimeCheck->clear();
398 dir.setFilter( QDir::Files | QDir::Readable ); 411 dir.setFilter( QDir::Files | QDir::Readable );
399 dir.setSorting(QDir::Size ); 412 dir.setSorting(QDir::Size );
400 const QFileInfoList *list = dir.entryInfoList(); 413 const QFileInfoList *list = dir.entryInfoList();
401 QFileInfoListIterator it( *list ); 414 QFileInfoListIterator it( *list );
402 QFileInfo *fi; 415 QFileInfo *fi;
403 while( (fi=it.current()) ){ 416 while( (fi=it.current()) ){
404 if(fi->extension() == QString::fromLatin1("desktop") ){ 417 if(fi->extension() == QString::fromLatin1("desktop") ){
405 ++it; 418 ++it;
406 continue; 419 continue;
407 } 420 }
408 MimeType type(fi->filePath() ); 421 MimeType type(fi->filePath() );
409 if( !m_mimetypes.contains( type.id() ) ) 422 if( !m_mimetypes.contains( type.id() ) )
410 m_mimetypes.append( type.id() ); 423 m_mimetypes.append( type.id() );
411 424
412 ++it; 425 ++it;
413 } 426 }
414 m_mimetypes.prepend("All" ); 427 m_mimetypes.prepend("All" );
415 m_mimeCheck->insertStringList(m_mimetypes ); 428 m_mimeCheck->insertStringList(m_mimetypes );
416 // set it to the current mimetype 429 // set it to the current mimetype
417 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); 430 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) );
418 }; 431 };
419 QDir dir( m_currentDir ); 432 QDir dir( m_currentDir );
420 //dir.setFilter(-1 ); 433 //dir.setFilter(-1 );
421 dir.setSorting(QDir::Name | QDir::DirsFirst | QDir::Reversed | QDir::IgnoreCase ); 434 int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed;
435 if( m_case )
436 sort = QDir::IgnoreCase;
437 dir.setSorting( sort );
438
439 int filter;
440 /* if( m_dir && !m_files)
441 filter |= QDir::Dirs;
442 else if( !m_dir && m_files )
443 filter |= QDir::Files;
444 else
445 filter |= QDir::All;
446 */
447 if( m_selector == EXTENDED_ALL )
448 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
449 else
450 filter = QDir::Files | QDir::Dirs | QDir::All;
451 dir.setFilter( filter );
452
422 const QFileInfoList *list = dir.entryInfoList(); 453 const QFileInfoList *list = dir.entryInfoList();
423 QFileInfoListIterator it( *list ); 454 QFileInfoListIterator it( *list );
424 QFileInfo *fi; 455 QFileInfo *fi;
425 while( (fi=it.current()) ){ 456 while( (fi=it.current()) ){
426 if(fi->fileName() == ".." || fi->fileName() == "." ){ 457 if(fi->fileName() == ".." || fi->fileName() == "." ){
427 ++it; 458 ++it;
428 continue; 459 continue;
429 } 460 }
430 qWarning("Test: %s", fi->fileName().latin1() ); 461 qWarning("Test: %s", fi->fileName().latin1() );
431 if(fi->isSymLink() ){ 462 if(fi->isSymLink() ){
432 qWarning("Symlink %s", fi->fileName().latin1() ); 463 qWarning("Symlink %s", fi->fileName().latin1() );
433 QString file = fi->dirPath(true)+"/"+ fi->readLink(); 464 QString file = fi->dirPath(true)+"/"+ fi->readLink();
434 qWarning("File ->%s", file.latin1() ); 465 qWarning("File ->%s", file.latin1() );
435 for(int i=0; i<=4; i++ ){ // prepend from dos 466 for(int i=0; i<=4; i++ ){ // prepend from dos
436 QFileInfo info( file ); 467 QFileInfo info( file );
437 if( !info.exists() ){ 468 if( !info.exists() ){
438 qWarning("does not exist" ); 469 qWarning("does not exist" );
439 addSymlink(currMime, fi, TRUE ); 470 addSymlink(currMime, fi, TRUE );
440 break; 471 break;
441 }else if( info.isDir() ){ 472 }else if( info.isDir() ){
442 qWarning("isDir" ); 473 qWarning("isDir" );
443 addDir(currMime, fi, TRUE ); 474 addDir(currMime, fi, TRUE );
444 break; 475 break;
445 }else if( info.isFile() ){ 476 }else if( info.isFile() ){
446 qWarning("isFile" ); 477 qWarning("isFile" );
447 addFile(currMime, fi, TRUE ); 478 addFile(currMime, fi, TRUE );
448 break; 479 break;
449 }else if( info.isSymLink() ){ 480 }else if( info.isSymLink() ){
450 file = info.dirPath(true)+ "/"+ info.readLink(); 481 file = info.dirPath(true)+ "/"+ info.readLink();
451 qWarning("isSymlink again %s", file.latin1() ); 482 qWarning("isSymlink again %s", file.latin1() );
452 }else if( i == 4 ){ // just insert it and have the symlink symbol 483 }else if( i == 4 ){ // just insert it and have the symlink symbol
453 addSymlink(currMime, fi ); 484 addSymlink(currMime, fi );
454 qWarning("level too deep" ); 485 qWarning("level too deep" );
455 } 486 }
456 } 487 }
457 }else if( fi->isDir() ){ 488 }else if( fi->isDir() ){
458 addDir(currMime, fi ); 489 addDir(currMime, fi );
459 }else if( fi->isFile() ) { // file ? 490 }else if( fi->isFile() ) { // file ?
460 addFile(currMime, fi ); 491 addFile(currMime, fi );
461 } 492 }
462 ++it; 493 ++it;
463 } 494 }
464 m_View->sort(); 495 m_View->sort();
465} 496}
466QString OFileSelector::directory()const 497QString OFileSelector::directory()const
467{ 498{
468 return m_currentDir; 499 return m_currentDir;
469} 500}
470int OFileSelector::fileCount() 501int OFileSelector::fileCount()
471{ 502{
472 return 0; 503 return 0;
473} 504}
474void OFileSelector::slotOk( ) 505void OFileSelector::slotOk( )
475{ 506{
476 emit ok(); 507 emit ok();
477} 508}
478void OFileSelector::slotCancel( ) 509void OFileSelector::slotCancel( )
479{ 510{
480 emit cancel(); 511 emit cancel();
481} 512}
482 513
483void OFileSelector::initializeName() 514void OFileSelector::initializeName()
484{ 515{
485 m_boxName = new QHBoxLayout(this ); 516 m_boxName = new QHBoxLayout(this );
486 m_edit = new QLineEdit(this ); 517 m_edit = new QLineEdit(this );
487 m_fnLabel = new QLabel(this ); 518 m_fnLabel = new QLabel(this );
488 m_fnLabel->setText(tr("Name:") ); 519 m_fnLabel->setText(tr("Name:") );
489 m_boxName->addWidget(m_fnLabel ); 520 m_boxName->addWidget(m_fnLabel );
490 m_boxName->insertSpacing(1, 8 ); 521 m_boxName->insertSpacing(1, 8 );
491 m_boxName->addWidget(m_edit, 100 ); 522 m_boxName->addWidget(m_edit, 100 );
492 523
493 m_lay->addLayout(m_boxName); 524 m_lay->addLayout(m_boxName);
494} 525}
495void OFileSelector::initializeYes() 526void OFileSelector::initializeYes()
496{ 527{
497 m_ok = new QPushButton("&Save", this, "save" ); 528 m_ok = new QPushButton("&Save", this, "save" );
498 m_cancel = new QPushButton("C&ancel", this, "cancel" ); 529 m_cancel = new QPushButton("C&ancel", this, "cancel" );
499 m_boxOk = new QHBoxLayout(this ); 530 m_boxOk = new QHBoxLayout(this );
500 m_boxOk->addWidget( m_ok, Qt::AlignHCenter ); 531 m_boxOk->addWidget( m_ok, Qt::AlignHCenter );
501 m_boxOk->insertSpacing(1, 8 ); 532 m_boxOk->insertSpacing(1, 8 );
502 m_boxOk->addWidget( m_cancel, Qt::AlignHCenter); 533 m_boxOk->addWidget( m_cancel, Qt::AlignHCenter);
503 m_lay->addLayout(m_boxOk ); 534 m_lay->addLayout(m_boxOk );
504 connect(m_ok, SIGNAL(clicked() ), 535 connect(m_ok, SIGNAL(clicked() ),
505 this, SLOT(slotOk() ) ); 536 this, SLOT(slotOk() ) );
506 connect(m_cancel, SIGNAL(clicked() ), 537 connect(m_cancel, SIGNAL(clicked() ),
507 this, SLOT(slotCancel() ) ); 538 this, SLOT(slotCancel() ) );
508 539
509} 540}
510void OFileSelector::initializeChooser() 541void OFileSelector::initializeChooser()
511{ 542{
512 m_boxView = new QHBoxLayout(this ); 543 m_boxView = new QHBoxLayout(this );
513 544
514 m_mimeCheck = new QComboBox(this, "mime check"); 545 m_mimeCheck = new QComboBox(this, "mime check");
515 m_viewCheck = new QComboBox(this, "view check"); 546 m_viewCheck = new QComboBox(this, "view check");
516 m_boxView->addWidget(m_viewCheck, 0 ); 547 m_boxView->addWidget(m_viewCheck, 0 );
517 m_boxView->insertSpacing(1, 8 ); 548 m_boxView->insertSpacing(1, 8 );
518 m_boxView->addWidget(m_mimeCheck, 0 ); 549 m_boxView->addWidget(m_mimeCheck, 0 );
519 m_lay->addLayout(m_boxView ); 550 m_lay->addLayout(m_boxView );
520 551
521 m_viewCheck->insertItem(tr("Documents") ); 552 m_viewCheck->insertItem(tr("Documents") );
522 m_viewCheck->insertItem(tr("Files") ); 553 m_viewCheck->insertItem(tr("Files") );
523 m_viewCheck->insertItem(tr("All Files") ); 554 m_viewCheck->insertItem(tr("All Files") );
524 555
525 if(!m_autoMime ) 556 if(!m_autoMime )
526 m_mimeCheck->insertItem(m_mimetypes.join("," ) ); 557 m_mimeCheck->insertItem(m_mimetypes.join("," ) );
527 else{ // check 558 else{ // check
528 updateMimes(); 559 updateMimes();
529 m_mimeCheck->insertStringList( m_mimetypes ); 560 m_mimeCheck->insertStringList( m_mimetypes );
530 } 561 }
531 562
532 connect( m_viewCheck, SIGNAL(activated(const QString &) ), 563 connect( m_viewCheck, SIGNAL(activated(const QString &) ),
533 this, SLOT(slotViewCheck(const QString & ) ) ); 564 this, SLOT(slotViewCheck(const QString & ) ) );
534 565
535 connect( m_mimeCheck, SIGNAL(activated(const QString &) ), 566 connect( m_mimeCheck, SIGNAL(activated(const QString &) ),
536 this, SLOT(slotMimeCheck(const QString & ) ) ); 567 this, SLOT(slotMimeCheck(const QString & ) ) );
537} 568}
538void OFileSelector::slotMimeCheck(const QString &view ){ 569void OFileSelector::slotMimeCheck(const QString &view ){
539 if(m_selector == NORMAL ){ 570 if(m_selector == NORMAL ){
540 delete m_select; 571 delete m_select;
541 m_select = new FileSelector(view == "All" ? QString::null : view 572 m_select = new FileSelector(view == "All" ? QString::null : view
542 , m_stack, "fileselector", FALSE, FALSE ); 573 , m_stack, "fileselector", FALSE, FALSE );
543 m_stack->addWidget( m_select, NORMAL ); 574 m_stack->addWidget( m_select, NORMAL );
544 m_stack->raiseWidget( NORMAL ); 575 m_stack->raiseWidget( NORMAL );
545 }else{ 576 }else{
546 reparse(); 577 reparse();
547 } 578 }
548} 579}
549 580
550void OFileSelector::slotViewCheck(const QString &view ){ 581void OFileSelector::slotViewCheck(const QString &view ){
551 qWarning("changed: show %s", view.latin1() ); 582 qWarning("changed: show %s", view.latin1() );
552 // if the current view is the one 583 // if the current view is the one
553 QString currMime = m_mimeCheck->currentText(); 584 QString currMime = m_mimeCheck->currentText();
554 if( view == QString::fromLatin1("Documents") ){ 585 if( view == QString::fromLatin1("Documents") ){
555 // get the mimetype now 586 // get the mimetype now
556 // check if we're the current widget and return 587 // check if we're the current widget and return
557 if( m_View != 0) // delete 0 shouldn't crash but it did :( 588 if( m_View != 0) { // delete 0 shouldn't crash but it did :(
558 delete m_View; 589 delete m_View;
590 delete m_boxToolbar;
591 delete m_homeButton;
592 delete m_docButton;
593 delete m_location;
594 delete m_up;
595 delete m_pseudo;
596 delete m_pseudoLayout;
597 }
559 m_View = 0; 598 m_View = 0;
599 m_boxToolbar = 0;
600 m_homeButton = 0;
601 m_docButton = 0;
602 m_location = 0;
603 m_up = 0;
604 m_pseudo = 0;
605 m_pseudoLayout = 0;
606
560 delete m_select; 607 delete m_select;
561 m_select = new FileSelector( currMime == "All" ? QString::null : currMime, 608 m_select = new FileSelector( currMime == "All" ? QString::null : currMime,
562 m_stack,"fileselector", FALSE, FALSE ); 609 m_stack,"fileselector", FALSE, FALSE );
563 m_stack->addWidget( m_select, NORMAL ); 610 m_stack->addWidget( m_select, NORMAL );
564 m_mimeCheck->clear(); 611 m_mimeCheck->clear();
565 m_selector = NORMAL; 612 m_selector = NORMAL;
566 updateMimes(); 613 updateMimes();
567 m_mimeCheck->insertStringList( m_mimetypes ); 614 m_mimeCheck->insertStringList( m_mimetypes );
568 m_stack->raiseWidget( NORMAL ); 615 m_stack->raiseWidget( NORMAL );
569 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); 616 connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) );
570 617
571 }else if(view == QString::fromLatin1("Files") ){ 618 }else if(view == QString::fromLatin1("Files") ){
572 // remove from the stack 619 // remove from the stack
573 delete m_select; 620 delete m_select;
574 m_select = 0; 621 m_select = 0;
575 delete m_View; 622 delete m_View;
576 m_View = 0; 623 m_View = 0;
624
625 delete m_boxToolbar;
626 delete m_homeButton;
627 delete m_docButton;
628 delete m_location;
629 delete m_up;
630 delete m_pseudo;
631 delete m_pseudoLayout;
632 m_boxToolbar = 0;
633 m_homeButton = 0;
634 m_docButton = 0;
635 m_location = 0;
636 m_up = 0;
637 m_pseudo = 0;
638 m_pseudoLayout = 0;
639
577 m_selector = EXTENDED; 640 m_selector = EXTENDED;
578 // create the ListView or IconView 641 // create the ListView or IconView
579 initializeListView(); 642 initializeListView();
580 643
581 reparse(); 644 reparse();
582 }else if(view == QString::fromLatin1("All Files") ) { 645 }else if(view == QString::fromLatin1("All Files") ) {
583 // remove from the stack 646 // remove from the stack
584 delete m_select; 647 delete m_select;
585 m_select = 0; 648 m_select = 0;
586 delete m_View; 649 delete m_View;
587 m_View = 0; 650 m_View = 0;
651 delete m_boxToolbar;
652 delete m_homeButton;
653 delete m_docButton;
654 delete m_location;
655 delete m_up;
656 delete m_pseudo;
657 delete m_pseudoLayout;
658 m_boxToolbar = 0;
659 m_homeButton = 0;
660 m_docButton = 0;
661 m_location = 0;
662 m_up = 0;
663 m_pseudo = 0;
664 m_pseudoLayout = 0;
665
588 m_selector = EXTENDED_ALL; 666 m_selector = EXTENDED_ALL;
589 initializeListView(); 667 initializeListView();
590 reparse(); 668 reparse();
591 }; 669 };
592}; 670};
593 671
594 672
595void OFileSelector::updateMimes() // lets check which mode is active 673void OFileSelector::updateMimes() // lets check which mode is active
596 // check the current dir for items then 674 // check the current dir for items then
597{ 675{
598 m_mimetypes.clear(); 676 m_mimetypes.clear();
599 m_mimetypes.append("All" ); 677 m_mimetypes.append("All" );
600 if( m_selector == NORMAL ){ 678 if( m_selector == NORMAL ){
601 DocLnkSet set; 679 DocLnkSet set;
602 Global::findDocuments(&set, QString::null ); 680 Global::findDocuments(&set, QString::null );
603 QListIterator<DocLnk> dit( set.children() ); 681 QListIterator<DocLnk> dit( set.children() );
604 for ( ; dit.current(); ++dit ) { 682 for ( ; dit.current(); ++dit ) {
605 if( !m_mimetypes.contains((*dit)->type() ) ) 683 if( !m_mimetypes.contains((*dit)->type() ) )
606 m_mimetypes.append( (*dit)->type() ); 684 m_mimetypes.append( (*dit)->type() );
607 } 685 }
608 }else{ 686 }else{
609 // should be allreday updatet 687 // should be allreday updatet
610 ; 688 ;
611 } 689 }
612}; 690};
613void OFileSelector::initializeListView() 691void OFileSelector::initializeListView()
614{ 692{
615 m_View = new QListView(m_stack, "Extended view" ); 693 // just to make sure but clean it up better FIXME
616 m_stack->addWidget( m_View, EXTENDED ); 694 delete m_View;
695 m_View = 0;
696 delete m_boxToolbar;
697 delete m_homeButton;
698 delete m_docButton;
699 delete m_location;
700 delete m_up;
701 delete m_pseudo;
702 delete m_pseudoLayout;
703 m_boxToolbar = 0;
704 m_homeButton = 0;
705 m_docButton = 0;
706 m_location = 0;
707 m_up = 0;
708 m_pseudo = 0;
709 m_pseudoLayout = 0;
710 // time for the toolbar
711 m_pseudo = new QWidget(m_stack, "Pseudo Widget");
712 m_pseudoLayout = new QVBoxLayout(m_pseudo );
713 if(m_shTool ){
714 m_boxToolbar = new QHBoxLayout( );
715 m_boxToolbar->setAutoAdd( true );
716 m_location = new QComboBox(m_pseudo );
717
718 m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton");
719 m_up->setMinimumSize( QSize( 20, 20 ) );
720 m_up->setMaximumSize( QSize( 20, 20 ) );
721 connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) );
722 m_up->setFlat(TRUE);
723
724 m_homeButton = new QPushButton(Resource::loadIconSet("home") , "", m_pseudo);
725 m_homeButton->setMinimumSize( QSize( 20, 20 ) );
726 m_homeButton->setMaximumSize( QSize( 20, 20 ) );
727 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) );
728 m_homeButton->setFlat(TRUE);
729
730 m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", m_pseudo,"docsButton");
731 m_docButton->setMinimumSize( QSize( 20, 20 ) );
732 m_docButton->setMaximumSize( QSize( 20, 20 ) );
733 connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) );
734 m_docButton->setFlat(TRUE);
735
736 m_boxToolbar->addWidget(m_location );
737 m_boxToolbar->addWidget(m_up );
738 m_boxToolbar->addWidget(m_homeButton );
739 m_boxToolbar->addWidget(m_docButton );
740 m_pseudoLayout->addLayout(m_boxToolbar );
741 // lets fill the combobox
742 StorageInfo storage;
743 const QList<FileSystem> &fs = storage.fileSystems();
744 QListIterator<FileSystem> it ( fs );
745 for( ; it.current(); ++it ){
746 const QString disk = (*it)->name();
747 const QString path = (*it)->path();
748 m_location->insertItem(path+ "<-"+disk );
749 }
750 };
751 m_View = new QListView(m_pseudo, "Extended view" );
752 m_stack->addWidget( m_pseudo, EXTENDED );
617 m_stack->raiseWidget( EXTENDED ); 753 m_stack->raiseWidget( EXTENDED );
754 m_pseudoLayout->addWidget(m_View );
618 QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold); 755 QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold);
619 // set up the stuff 756 // set up the stuff
620 // Pixmap Name Date Size mime 757 // Pixmap Name Date Size mime
621 //(m_View->header() )->hide(); 758 //(m_View->header() )->hide();
622 //m_View->setRootIsDecorated(false); 759 //m_View->setRootIsDecorated(false);
623 m_View->addColumn(" "); 760 m_View->addColumn(" ");
624 m_View->addColumn(tr("Name") ); 761 m_View->addColumn(tr("Name") );
625 m_View->addColumn(tr("Size") ); 762 m_View->addColumn(tr("Size") );
626 m_View->addColumn(tr("Date"), 60 ); 763 m_View->addColumn(tr("Date"), 60 );
627 m_View->addColumn(tr("Mime Type") ); 764 m_View->addColumn(tr("Mime Type") );
628 QHeader *header = m_View->header(); 765 QHeader *header = m_View->header();
629 header->hide(); 766 header->hide();
630 m_View->setSorting(1 ); 767 m_View->setSorting(1 );
631 // connect now 768 // connect now
632 connect(m_View, SIGNAL(selectionChanged() ), this, SLOT(slotSelectionChanged() ) ); 769 connect(m_View, SIGNAL(selectionChanged() ), this, SLOT(slotSelectionChanged() ) );
633 connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); 770 connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), this, SLOT(slotCurrentChanged(QListViewItem * ) ) );
634 connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), 771 connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ),
635 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); 772 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) );
636 connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), 773 connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )),
637 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); 774 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) );
775
776
638}; 777};
639/* If a item is locked depends on the mode 778/* If a item is locked depends on the mode
640 if we're in OPEN !isReadable is locked 779 if we're in OPEN !isReadable is locked
641 if we're in SAVE !isWriteable is locked 780 if we're in SAVE !isWriteable is locked
642 781
643 782
644 */ 783 */
645 784
646 785
647void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){ 786void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){
648 qWarning("Add Files" ); 787 qWarning("Add Files" );
649 if( !m_files ){ 788 if( !m_files ){
650 qWarning("not mfiles" ); 789 qWarning("not mfiles" );
651 return; 790 return;
652 } 791 }
653 792
654 MimeType type( info->filePath() ); 793 MimeType type( info->filePath() );
655 QString name; 794 QString name;
656 QString dir; 795 QString dir;
657 bool locked= false; 796 bool locked= false;
658 if(mime == "All" ){ 797 if(mime == "All" ){
659 ; 798 ;
660 }else if( type.id() != mime ) { 799 }else if( type.id() != mime ) {
661 return; 800 return;
662 } 801 }
663 QPixmap pix = type.pixmap(); 802 QPixmap pix = type.pixmap();
664 if(pix.isNull() ) 803 if(pix.isNull() )
665 pix = Resource::loadPixmap( "UnknownDocument-14" ); 804 pix = Resource::loadPixmap( "UnknownDocument-14" );
666 dir = info->dirPath( true ); 805 dir = info->dirPath( true );
667 if( symlink ) { // check if the readLink is readable 806 if( symlink ) { // check if the readLink is readable
668 // do it right later 807 // do it right later
669 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); 808 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink();
670 }else{ // keep track of the icons 809 }else{ // keep track of the icons
671 name = info->fileName(); 810 name = info->fileName();
672 if( m_mode == OPEN ){ 811 if( m_mode == OPEN ){
673 if( !info->isReadable() ){ 812 if( !info->isReadable() ){
674 locked = true; 813 locked = true;
675 pix = Resource::loadPixmap("locked" ); 814 pix = Resource::loadPixmap("locked" );
676 } 815 }
677 }else if( m_mode == SAVE ){ 816 }else if( m_mode == SAVE ){
678 if( !info->isWritable() ){ 817 if( !info->isWritable() ){
679 locked = true; 818 locked = true;
680 pix = Resource::loadPixmap("locked" ); 819 pix = Resource::loadPixmap("locked" );
681 } 820 }
682 } 821 }
683 } 822 }
684 new OFileSelectorItem( m_View, pix, name, 823 new OFileSelectorItem( m_View, pix, name,
685 info->lastModified().toString(), 824 info->lastModified().toString(),
686 QString::number( info->size() ), 825 QString::number( info->size() ),
687 dir, locked ); 826 dir, locked );
688} 827}
689void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) 828void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink )
690{ 829{
691 if(!m_dir ) 830 if(!m_dir )
692 return; 831 return;
693 //if( showDirs ) 832 //if( showDirs )
694 { 833 {
695 bool locked=false; 834 bool locked=false;
696 QString name; 835 QString name;
697 QPixmap pix; 836 QPixmap pix;
698 if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ 837 if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){
699 locked = true; 838 locked = true;
700 if( symlink ){ 839 if( symlink ){
701 pix = (*m_pixmaps)["symlinkedlocked"]; 840 pix = (*m_pixmaps)["symlinkedlocked"];
702 }else{ 841 }else{
703 pix = Resource::loadPixmap("lockedfolder" ); 842 pix = Resource::loadPixmap("lockedfolder" );
704 } 843 }
705 }else{ 844 }else{
706 if( symlink ){ 845 if( symlink ){
707 pix = (*m_pixmaps)["dirsymlink" ]; 846 pix = (*m_pixmaps)["dirsymlink" ];
708 }else{ 847 }else{
709 pix = Resource::loadPixmap("folder" ); 848 pix = Resource::loadPixmap("folder" );
710 } 849 }
711 } 850 }
712 if( symlink){ 851 if( symlink){
713 name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink(); 852 name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink();
714 853
715 }else{ 854 }else{
716 //if(info->isReadable() ) 855 //if(info->isReadable() )
717 name = info->fileName(); 856 name = info->fileName();
718 } 857 }
719 858
720 new OFileSelectorItem(m_View, pix, 859 new OFileSelectorItem(m_View, pix,
721 name, info->lastModified().toString(), 860 name, info->lastModified().toString(),
722 QString::number(info->size() ),info->dirPath(true), locked, true ); 861 QString::number(info->size() ),info->dirPath(true), locked, true );
723 862
724 } 863 }
725} 864}
726void OFileSelector::setShowDirs(bool dir ) 865void OFileSelector::setShowDirs(bool dir )
727{ 866{
728 m_dir = dir; 867 m_dir = dir;
729 reparse(); 868 reparse();
730} 869}
731 870
732void OFileSelector::slotFileSelected(const QString &string ) 871void OFileSelector::slotFileSelected(const QString &string )
733{ 872{
734 if(m_shLne ) 873 if(m_shLne )
735 m_edit->setText( string ); 874 m_edit->setText( string );
736 875
737 emit fileSelected( string ); 876 emit fileSelected( string );
738 // do AppLnk stuff 877 // do AppLnk stuff
739} 878}
740void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) 879void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
741{ 880{
742 slotFileSelected(lnk.name() ); 881 slotFileSelected(lnk.name() );
743 emit fileSelected( lnk ); 882 emit fileSelected( lnk );
744} 883}
745void OFileSelector::slotSelectionChanged() // get the current items 884void OFileSelector::slotSelectionChanged() // get the current items
746 // fixme 885 // fixme
747{ 886{
748 qWarning("selection changed" ); 887 qWarning("selection changed" );
749} 888}
750void OFileSelector::slotCurrentChanged(QListViewItem *item ) 889void OFileSelector::slotCurrentChanged(QListViewItem *item )
751{ 890{
752 qWarning("current changed" ); 891 qWarning("current changed" );
753 if( item == 0 ) 892 if( item == 0 )
754 return; 893 return;
755 894
756 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ 895 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
757 OFileSelectorItem *sel = (OFileSelectorItem*)item; 896 OFileSelectorItem *sel = (OFileSelectorItem*)item;
758 if(!sel->isDir() ){ 897 if(!sel->isDir() ){
759 qWarning("is not dir" ); 898 qWarning("is not dir" );
760 if(m_shLne ){ 899 if(m_shLne ){
761 m_edit->setText(sel->text(1) ); 900 m_edit->setText(sel->text(1) );
762 qWarning("setTexy" ); 901 qWarning("setTexy" );
763 } 902 }
764 } 903 }
765 }else { 904 }else {
766 qWarning("mode not extended" ); 905 qWarning("mode not extended" );
767 } 906 }
768} 907}
769// either select or change dir 908// either select or change dir
770void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int ) 909void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int )
771{ 910{
772 if( item == 0 ) 911 if( item == 0 )
773 return; 912 return;
774 913
775 if( button != Qt::LeftButton ) 914 if( button != Qt::LeftButton )
776 return; 915 return;
777 916
778 qWarning("clicked" ); 917 qWarning("clicked" );
779 if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ 918 if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ){
780 qWarning("inside" ); 919 qWarning("inside" );
781 OFileSelectorItem *sel = (OFileSelectorItem*)item; 920 OFileSelectorItem *sel = (OFileSelectorItem*)item;
782 if(!sel->isLocked() ){ // not locked either changedir or open 921 if(!sel->isLocked() ){ // not locked either changedir or open
783 QStringList str = QStringList::split("->", sel->text(1) ); 922 QStringList str = QStringList::split("->", sel->text(1) );
784 if(sel->isDir() ){ 923 if(sel->isDir() ){
785 cd( sel->directory() + "/" + str[0] ); 924 cd( sel->directory() + "/" + str[0] );
786 }else{ 925 }else{
787 qWarning("file" ); 926 qWarning("file" );
788 if(m_shLne ) 927 if(m_shLne )
789 m_edit->setText(str[0] ); 928 m_edit->setText(str[0] );
790 emit fileSelected(str[0] ); 929 emit fileSelected(str[0] );
791 // emit DocLnk need to do it 930 // emit DocLnk need to do it
792 } 931 }
793 }else{ 932 }else{
794 qWarning( "locked" ); 933 qWarning( "locked" );
795 } 934 }
796 }; 935 };
797} 936}
798void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) 937void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int )
799{ 938{
939 if (item == 0 )
940 return;
941
800 if( button != Qt::RightButton ) 942 if( button != Qt::RightButton )
801 return; 943 return;
802 qWarning("right button" ); 944 qWarning("right button" );
803 slotContextMenu(item); 945 slotContextMenu(item);
804} 946}
805void OFileSelector::slotContextMenu(QListViewItem *item) 947void OFileSelector::slotContextMenu(QListViewItem *item)
806{ 948{
807 qWarning("context menu" ); 949 qWarning("context menu" );
950 if( item ==0 || !m_showPopup )
951 return;
952
808 if( m_custom !=0){ 953 if( m_custom !=0){
809 m_custom->exec(); 954 m_custom->exec();
810 }else{ 955 }else{
811 QPopupMenu menu; 956 QPopupMenu menu;
957 QAction up;
958 up.setText("cd up");
959 up.addTo( &menu );
960 connect(&up, SIGNAL(activated() ),
961 this, SLOT(cdUP() ) );
962
812 QAction act; 963 QAction act;
813 OFileSelectorItem *sel = (OFileSelectorItem*)item; 964 OFileSelectorItem *sel = (OFileSelectorItem*)item;
814 if(sel->isDir() ){ 965 if(sel->isDir() ){
815 act.setText( tr("Change Directory") ); 966 act.setText( tr("Change Directory") );
816 act.addTo(&menu ); 967 act.addTo(&menu );
817 connect(&act, SIGNAL(activated() ), 968 connect(&act, SIGNAL(activated() ),
818 this, SLOT(slotChangedDir() ) ); 969 this, SLOT(slotChangedDir() ) );
819 }else{ 970 }else{
820 act.setText( tr("Open file" ) ); 971 act.setText( tr("Open file" ) );
821 act.addTo( &menu ); 972 act.addTo( &menu );
822 connect(&act, SIGNAL(activated() ), 973 connect(&act, SIGNAL(activated() ),
823 this, SLOT(slotOpen() ) ); 974 this, SLOT(slotOpen() ) );
824 } 975 }
825 QAction rescan; 976 QAction rescan;
826 rescan.setText( tr("Rescan") ); 977 rescan.setText( tr("Rescan") );
827 rescan.addTo( &menu ); 978 rescan.addTo( &menu );
828 connect(&act, SIGNAL(activated() ), 979 connect(&rescan, SIGNAL(activated() ),
829 this, SLOT(slotRescan() ) ); 980 this, SLOT(slotRescan() ) );
830 981
831 QAction rename; 982 QAction rename;
832 rename.setText( tr("Rename") ); 983 rename.setText( tr("Rename") );
833 rename.addTo( &menu ); 984 rename.addTo( &menu );
834 connect(&act, SIGNAL(activated() ), 985 connect(&rename, SIGNAL(activated() ),
835 this, SLOT(slotRename() ) ); 986 this, SLOT(slotRename() ) );
836 987
837 menu.insertSeparator(); 988 menu.insertSeparator();
838 QAction delItem; 989 QAction delItem;
839 delItem.setText( tr("Delete") ); 990 delItem.setText( tr("Delete") );
840 delItem.addTo(&menu ); 991 delItem.addTo(&menu );
841 connect(&act, SIGNAL(activated() ), 992 connect(&delItem, SIGNAL(activated() ),
842 this, SLOT(slotDelete() ) ); 993 this, SLOT(slotDelete() ) );
843 994
844 menu.exec(QCursor::pos() ); 995 menu.exec(QCursor::pos() );
845 } 996 }
846} 997}
847bool OFileSelector::cd(const QString &str ) 998bool OFileSelector::cd(const QString &str )
848{ 999{
849 qWarning(" dir %s", str.latin1() ); 1000 qWarning(" dir %s", str.latin1() );
850 QDir dir( str); 1001 QDir dir( str);
851 if(dir.exists() ){ 1002 if(dir.exists() ){
852 m_currentDir = str; 1003 m_currentDir = str;
853 reparse(); 1004 reparse();
854 return true; 1005 return true;
855 } 1006 }
856 return false; 1007 return false;
857} 1008}
858 1009
859void OFileSelector::slotChangedDir() 1010void OFileSelector::slotChangedDir()
860{ 1011{
861 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1012 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
862 if(sel->isDir() ){ 1013 if(sel->isDir() ){
863 QStringList str = QStringList::split("->", sel->text(1) ); 1014 QStringList str = QStringList::split("->", sel->text(1) );
864 cd( sel->directory() + "/" + str[0] ); 1015 cd( sel->directory() + "/" + str[0] );
865 } 1016 }
866} 1017}
867void OFileSelector::slotOpen() 1018void OFileSelector::slotOpen()
868{ 1019{
869 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1020 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
870 if(!sel->isDir() ){ 1021 if(!sel->isDir() ){
871 QStringList str = QStringList::split("->", sel->text(1) ); 1022 QStringList str = QStringList::split("->", sel->text(1) );
872 slotFileSelected( str[0] ); 1023 slotFileSelected( str[0] );
873 } 1024 }
874} 1025}
875void OFileSelector::slotRescan() 1026void OFileSelector::slotRescan()
876{ 1027{
877 reparse(); 1028 reparse();
878} 1029}
879void OFileSelector::slotRename() 1030void OFileSelector::slotRename()
880{ 1031{
881 // rename inline 1032 // rename inline
882} 1033}
883void OFileSelector::slotDelete() 1034void OFileSelector::slotDelete()
884{ 1035{
885 qWarning("delete slot" ); 1036 qWarning("delete slot" );
886 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1037 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
887 QStringList list = QStringList::split("->", sel->text(1) ); 1038 QStringList list = QStringList::split("->", sel->text(1) );
888 if( sel->isDir() ){ 1039 if( sel->isDir() ){
889 QString str = QString::fromLatin1("rm -rf ") + list[0]; 1040 QString str = QString::fromLatin1("rm -rf ") + list[0];
890 ::system(str.utf8().data() ); 1041 ::system(str.utf8().data() );
891 }else{ 1042 }else{
892 QFile::remove( list[0] ); 1043 QFile::remove( list[0] );
893 } 1044 }
894 m_View->takeItem( sel ); 1045 m_View->takeItem( sel );
895 delete sel; 1046 delete sel;
896} 1047}
897 1048
898 1049void OFileSelector::cdUP()
1050{
1051 QDir dir( m_currentDir );
1052 dir.cdUp();
1053 if(dir.exists() ){
1054 m_currentDir = dir.absPath();
1055 reparse();
1056 }
1057}
899 1058
900 1059
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h
index 458e552..b91c0ea 100644
--- a/libopie/ofileselector.h
+++ b/libopie/ofileselector.h
@@ -1,270 +1,275 @@
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 */
53class DocLnk; 53class DocLnk;
54class QCheckBox; 54class QCheckBox;
55class QComboBox; 55class QComboBox;
56class QPushButton; 56class QPushButton;
57class FileSelector; 57class FileSelector;
58class QGridLayout; 58class QGridLayout;
59class QLineEdit; 59class QLineEdit;
60class QLabel; 60class QLabel;
61class QWidgetStack; 61class QWidgetStack;
62class QHBoxLayout; 62class QHBoxLayout;
63class QVBoxLayout; 63class QVBoxLayout;
64class QPopupMenu; 64class QPopupMenu;
65class QFileInfo; 65class QFileInfo;
66// 66//
67class OFileSelectorItem : public QListViewItem { 67class 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
116class OFileSelector : public QWidget { 116class OFileSelector : public QWidget {
117 Q_OBJECT 117 Q_OBJECT
118 public: 118 public:
119 enum Mode {OPEN=1, SAVE, FILESELECTOR }; 119 enum Mode {OPEN=1, SAVE, FILESELECTOR };
120 enum Selector{NORMAL=1, EXTENDED = 2, EXTENDED_ALL =4 }; 120 enum Selector{NORMAL=1, EXTENDED = 2, EXTENDED_ALL =4 };
121 enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; 121 enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 };
122 OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const QStringList mimetypes = QStringList() ); 122 OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const QStringList mimetypes = QStringList() );
123 123
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 158 bool showPopup()const { return m_showPopup; };
159 void setShowPopup( bool pop ) { m_showPopup = pop; };
159 void setPopupMenu( QPopupMenu * ); 160 void setPopupMenu( QPopupMenu * );
160 161
161 void updateLay(); 162 void updateLay();
162 163
163 void reparse(); // re reads the dir 164 void reparse(); // re reads the dir
164 165
165 QString selectedName( )const; 166 QString selectedName( )const;
166 QStringList selectedNames()const; 167 QStringList selectedNames()const;
167 168
168 QString selectedPath() const; 169 QString selectedPath() const;
169 QStringList selectedPaths() const; 170 QStringList selectedPaths() const;
170 171
171 QString directory()const; 172 QString directory()const;
172 int fileCount(); 173 int fileCount();
173 174
174 /* the user needs to delete it */ 175 /* the user needs to delete it */
175 DocLnk selectedDocument()const; 176 DocLnk selectedDocument()const;
176 /* the user needs to delete it */ 177 /* the user needs to delete it */
177 QValueList<DocLnk> selectedDocuments()const; 178 QValueList<DocLnk> selectedDocuments()const;
178 179
179 signals: 180 signals:
180 void fileSelected( const DocLnk & ); 181 void fileSelected( const DocLnk & );
181 void fileSelected( const QString & ); 182 void fileSelected( const QString & );
182 void closeMe(); 183 void closeMe();
183 void ok(); 184 void ok();
184 void cancel(); 185 void cancel();
185 186
186 protected slots: 187 protected slots:
187 void slotOk(); 188 void slotOk();
188 void slotCancel(); 189 void slotCancel();
189 void slotViewCheck(const QString & ); 190 void slotViewCheck(const QString & );
190 void slotMimeCheck(const QString & ); 191 void slotMimeCheck(const QString & );
191 protected: 192 protected:
192 void init(); 193 void init();
193 void updateMimes(); 194 void updateMimes();
194 195
195 protected: 196 protected:
196 197
197 private: 198 private:
198int m_mode, m_selector; 199 int m_mode, m_selector;
199 QComboBox *m_location, *m_mimeCheck, *m_viewCheck; 200 QComboBox *m_location, *m_mimeCheck, *m_viewCheck;
200 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; 201 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel;
201 QPushButton *m_reread, *m_up; 202 QPushButton *m_reread, *m_up;
202 QListView *m_View; 203 QListView *m_View;
203 QCheckBox *m_checkPerm; 204 QCheckBox *m_checkPerm;
205 QWidget *m_pseudo;
206 QVBoxLayout *m_pseudoLayout;
204 207
205 QString m_currentDir; 208 QString m_currentDir;
206 QString m_name; 209 QString m_name;
207 QStringList m_mimetypes; 210 QStringList m_mimetypes;
208 211
209 FileSelector *m_select; 212 FileSelector *m_select;
210 QWidgetStack *m_stack; 213 QWidgetStack *m_stack;
211 QVBoxLayout *m_lay; 214 QVBoxLayout *m_lay;
212 QGridLayout *m_Oselector; 215 QGridLayout *m_Oselector;
213 216
214 QHBoxLayout *m_boxToolbar; 217 QHBoxLayout *m_boxToolbar;
215 QHBoxLayout *m_boxOk; 218 QHBoxLayout *m_boxOk;
216 QHBoxLayout *m_boxName; 219 QHBoxLayout *m_boxName;
217 QHBoxLayout *m_boxView; 220 QHBoxLayout *m_boxView;
218 221
219 QPopupMenu *m_custom; 222 QPopupMenu *m_custom;
220 223
221 QLineEdit *m_edit; 224 QLineEdit *m_edit;
222 QLabel *m_fnLabel; 225 QLabel *m_fnLabel;
223 bool m_shTool:1; 226 bool m_shTool:1;
224 bool m_shPerm:1; 227 bool m_shPerm:1;
225 bool m_shLne:1; 228 bool m_shLne:1;
226 bool m_shChooser:1; 229 bool m_shChooser:1;
227 bool m_shYesNo:1; 230 bool m_shYesNo:1;
228 bool m_boCheckPerm:1; 231 bool m_boCheckPerm:1;
229 bool m_autoMime:1; 232 bool m_autoMime:1;
230 bool m_case:1; 233 bool m_case:1;
231 bool m_dir:1; 234 bool m_dir:1;
232 bool m_files:1; 235 bool m_files:1;
236 bool m_showPopup:1;
233 237
234 // implementation todo 238 // implementation todo
235 virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); 239 virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE );
236 virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); 240 virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE );
237 virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){}; 241 virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){};
238 void delItems(); 242 void delItems();
239 void initializeName(); 243 void initializeName();
240 void initializeYes(); 244 void initializeYes();
241 void initializeChooser(); 245 void initializeChooser();
242 void initializeListView(); 246 void initializeListView();
243 void initPics(); 247 void initPics();
244 bool compliesMime(const QString &path, const QString &mime); 248 bool compliesMime(const QString &path, const QString &mime);
245 249
246 class OFileSelectorPrivate; 250 class OFileSelectorPrivate;
247 OFileSelectorPrivate *d; 251 OFileSelectorPrivate *d;
248 static QMap<QString,QPixmap> *m_pixmaps; 252 static QMap<QString,QPixmap> *m_pixmaps;
249 253
250private slots: 254private slots:
251 void slotFileSelected(const QString & ); // not really meant to be a slot 255 void slotFileSelected(const QString & ); // not really meant to be a slot
252 void slotFileBridgeSelected( const DocLnk & ); 256 void slotFileBridgeSelected( const DocLnk & );
253 virtual void slotSelectionChanged(); 257 virtual void slotSelectionChanged();
254 virtual void slotCurrentChanged(QListViewItem* ); 258 virtual void slotCurrentChanged(QListViewItem* );
255 virtual void slotClicked( int, QListViewItem *item, const QPoint &, int); 259 virtual void slotClicked( int, QListViewItem *item, const QPoint &, int);
256 virtual void slotRightButton(int, QListViewItem *, const QPoint &, int ); 260 virtual void slotRightButton(int, QListViewItem *, const QPoint &, int );
257 virtual void slotContextMenu( QListViewItem *item); 261 virtual void slotContextMenu( QListViewItem *item);
258 // listview crap see above 262 // listview crap see above
259 // PopupMenu crap 263 // PopupMenu crap
260 virtual void slotChangedDir(); 264 virtual void slotChangedDir();
261 virtual void slotOpen(); 265 virtual void slotOpen();
262 virtual void slotRescan(); 266 virtual void slotRescan();
263 virtual void slotRename(); 267 virtual void slotRename();
264 virtual void slotDelete(); 268 virtual void slotDelete();
269 virtual void cdUP();
265 270
266}; 271};
267 272
268 273
269#endif 274#endif
270 275