summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector/MANIFEST29
-rwxr-xr-xlibopie/ofileselector/configure301
-rw-r--r--libopie/ofileselector/libopie.pro97
-rw-r--r--libopie/ofileselector/ofilelistview.cpp32
-rw-r--r--libopie/ofileselector/ofilelistview.h6
-rw-r--r--libopie/ofileselector/ofileselector.cpp2
-rw-r--r--libopie/ofileselector/ofileselectoritem.cpp4
-rw-r--r--libopie/ofileselector/ofileview.cpp2
-rw-r--r--libopie/ofileselector/ofileview.h4
-rw-r--r--libopie/ofileselector/olister.cpp13
-rw-r--r--libopie/ofileselector/olister.h7
-rw-r--r--libopie/ofileselector/olocallister.cpp14
-rw-r--r--libopie/ofileselector/olocallister.h2
13 files changed, 482 insertions, 31 deletions
diff --git a/libopie/ofileselector/MANIFEST b/libopie/ofileselector/MANIFEST
new file mode 100644
index 0000000..2730a1c
--- a/dev/null
+++ b/libopie/ofileselector/MANIFEST
@@ -0,0 +1,29 @@
1Hija,
2dunno if that is to call a manifest but here is
3an quick overview how the OFileSelector is implemented
4and whats the whole purpose is.
5
6OFileSelector is meant to be extendable by design. It's divided
7into a shell the class OFileSelector which is a dispatcher
8between worlds and gives a common interface to the programmer.
9Then there is the OLister class which is a lister of files.
10It's responsible for taking care of a filesystem... but it's not limited
11to local filesystem. You can have a FTP lister, Bluetooth Device Lister,
12IrdaDevice Lister, Local Documents Lister, a PIM Lister an X-Ref lister...
13they will operate on the level of filesystems....
14
15A OFileView is the other part of the FileSelector it's responsible
16for the things represented to the USER.
17There is a ListView and a IconView and possible more views to come.
18
19Then there is a PixmapProvider which is responsible for providing pixmaps
20for a mimetype. This can be used for something like a Pixmap preview....
21
22
23The lister is told to reparse() then it adds it things to the mainview
24on selection the URL get's generated in more than one step.
251. The UI notifies the lister about activation
262. The Lister assembles the URL
273. the Lister notifies the OFileSelector
284. the OFileSelector emits a signal
29
diff --git a/libopie/ofileselector/configure b/libopie/ofileselector/configure
new file mode 100755
index 0000000..c66fd82
--- a/dev/null
+++ b/libopie/ofileselector/configure
@@ -0,0 +1,301 @@
1#!/bin/sh
2#
3# Configures to build the Qtopia Environment
4#
5# Copyright 1999-2000 Trolltech AS. All rights reserved.
6#
7
8PLATFORM=generic
9SHARING=shared
10DEBUG=
11QCONFIGARG=
12
13touch .test.qpe.
14if [ '!' -f ${OPIEDIR}/.test.qpe. ];
15then
16 rm .test.qpe.
17 echo
18 echo
19 echo ' The environment variable $OPIEDIR is not set correctly. It is currently'
20 echo ' set to "'$OPIEDIR'", but it should be set to this directory,'
21 echo ' which is "'`pwd`'".'
22 echo
23 echo ' Please read the INSTALL file for instructions on how to set $OPIEDIR'
24 echo ' correctly. If you have set $OPIEDIR in your .profile or .login, you '
25 echo ' will need to log out and log in again to make the setting effective.'
26 echo
27 echo
28 exit 1
29fi
30rm .test.qpe.
31
32if [ '!' -f $TMAKEPATH/tmake.conf ]
33then
34 # You have tmake. We'll regenerate the file for you...
35 echo ' The environment variable $TMAKEPATH is not set correclty. '
36 echo ' It should be set to the tmake path'
37 echo
38 echo ' Please read the INSTALL file for instructions on how to set $TMAKEPATH'
39 echo ' to the environment variable correctly.'
40 exit 1
41fi
42
43VERSION_MAJ=$(sed -n -e 's/.*QPE_VERSION "\([0-9]*\)\.[0-9]*\.[0-9]*.*".*/\1/p' <library/version.h)
44VERSION_MIN=$(sed -n -e 's/.*QPE_VERSION "[0-9]*\.\([0-9]\)\.[0-9]*.*".*/\1/p' <library/version.h)
45VERSION_PAT=$(sed -n -e 's/.*QPE_VERSION "[0-9]*\.[0-9]*\.\([0-9]*\).*".*/\1/p' <library/version.h)
46
47TOMAKE=
48
49if grep -q 'VERSION_STR.*"3' $QTDIR/include/qglobal.h
50then
51 QT3=yes
52else
53 QT3=no
54fi
55
56# Parse the arguments, setting things to "yes" or "no".
57
58while [ -n "$1" ]; do
59 case $1 in
60 -platform|-xplatform) # No difference since we don't need to build moc, etc.
61 shift; PLATFORM=$1
62 ;;
63 -release)
64 DEBUG=
65 ;;
66 -debug)
67 DEBUG=-debug
68 ;;
69 -shared)
70 SHARING=shared
71 ;;
72 -static)
73 SHARING=static
74 ;;
75 -qconfig)
76 # optional way to specify the qconfig-qpe.h is to pass -qconfig qpe
77 shift; QCONFIGARG=DEFINES+=QCONFIG='\"'$1'\"' # Don't quote me on that.
78 ;;
79 -make)
80 shift; TOMAKE="$TOMAKE $1"
81 ;;
82 -qt3)
83 QT3=yes
84 ;;
85 *)
86 HELP=yes;;
87 esac
88 shift
89done
90
91TARGET=configs/$PLATFORM-$SHARING$DEBUG
92
93if [ '!' -f $TARGET ]
94then
95 if [ -f configs/linux-$PLATFORM-g++-$SHARING$DEBUG ]
96 then
97 TARGET=configs/linux-$PLATFORM-g++-$SHARING$DEBUG
98 PLATFORM=linux-$PLATFORM-g++
99 else
100 echo
101 echo ' The specified platform/compiler not supported: ' $TARGET
102 echo
103 exit 2
104 fi
105fi
106
107# Next, emit a usage message if something failed.
108
109if [ "$HELP" = "yes" ]; then
110 cat <<EOF
111Usage: $0 [-debug] [-release] [-shared] [-static] [-qt3] [-platform ...]
112
113The defaults (*) are usually acceptable. Here is a short explanation of
114each option:
115
116 * -release ........... Compile and link Qt with debugging turned off.
117 -debug ............. Compile and link Qt with debugging turned on.
118
119 * -shared ............ Create and use a shared Qt library (libqt.so)
120 -static ............ Create and use a static Qt library (libqt.a)
121
122 -qt3 ............... Configure for use with Qt 3.x
123
124 -platform target ... The platform you are building on ($PLATFORM)
125EOF
126 exit 0;
127fi
128
129CUSTOM=`echo $PLATFORM | sed -n -e "s/.*-\(.*\)-.*/\1/p"`
130
131if [ -f library/custom-$CUSTOM.h ]
132then
133 rm -f library/custom.h
134 ln -s custom-$CUSTOM.h library/custom.h
135fi
136
137mkdir -p include/qpe
138( cd include/qpe && rm -f *.h; ln -s ../../library/*.h .; ln -s ../../library/backend/*.h .; rm -f *_p.h; )
139mkdir -p include/qtopia
140( cd include/qtopia && rm -f *.h; ln -s ../../library/*.h .; )
141mkdir -p include/qtopia/private
142( cd include/qtopia/private && rm -f *.h; ln -s ../../../library/backend/*.h .; )
143mkdir -p include/opie
144( cd include/opie && rm -f *.h; ln -s ../../libopie/*.h .; rm -f *_p.h; )
145( cd include/opie && ln -s ../../libsql/*.h .; )
146( cd include/opie && ln -s ../../libopie/pim/*.h .; )
147( cd include/opie && ln -fs ../../libopie/ofileselector/*.h .; )
148
149echo Creating makefiles...
150
151# Set version for library directly
152# Version 1.5.0 right now for compat.
153sed -e 's/^\(VERSION.*= \).*/\1'1.5.0.$VERSION_PAT/ <library/library.pro >library/library.pro-v
154mv library/library.pro-v library/library.pro
155
156if [ "$QT3" = yes ]
157then
158 VCONFIG="CONFIG+=qt3"
159else
160 VCONFIG="CONFIG+=qt2"
161fi
162
163if [ -f $TMAKEPATH/tmake.conf ]
164then
165 # You have tmake. We'll regenerate the file for you...
166 echo "Makefiles will be regenerated."
167fi
168
169H=`pwd`
170if [ -z "$TOMAKE" ]
171then
172 TOMAKE=`make showcomponents`
173fi
174
175for a in $TOMAKE ; do
176 N=$a/Makefile
177 M=$a/Makefile.in
178 O=$a/Makefile.add
179 f=`basename $a`
180
181 if [ -f "$TMAKEPATH/tmake.conf" -a -f "$a/$f.pro" ]
182 then
183 ( cd $a;
184 TMAKEPATH=$QTDIR/tmake:$TMAKEPATH \
185 tmake $QCONFIGARG CONFIG+=embedded $VCONFIG \
186 -t $H/qt/tmake/propagate.t $f.pro |
187 sed -e "s|$QTDIR|\$(QTDIR)|g" -e "s|$OPIEDIR|\$(OPIEDIR)|g" >Makefile.in;
188 )
189 echo -n "."
190 #echo Building $N..
191 appname=`grep '^TARGET' $a/$f.pro | sed 's/^TARGET.*=//' | tr -d " \t"`
192 translation=`grep '^TRANSLATION.*[^+]=.*' $a/$f.pro | sed 's,^TRANSL.*=.*i18n\/.*\/,,' | sed 's/ //g' | sed 's,\.ts.*,,' | sed 's,^lib,,' `
193 if [ -n "$translation" -a -n "$appname" ]
194 then
195 if [ "$appname" != "$translation" ]
196 then
197 echo
198 echo "Warning: translation and appname disagree in $a/$f.pro"
199 fi
200 fi
201
202 fi
203
204 cat > $N <<EOF
205#############################################################################
206# Automatically generated from $M
207# Build options from $1
208#############################################################################
209
210EOF
211
212 SED=
213 PLATFORM_CFLAGS=
214
215 if [ "$f" = "embeddedkonsole" ]
216 then
217 case $PLATFORM in
218 *x86*|*generic*|*ipaq*|*sharp*)
219 SED="$SED /^LIBS.*=/s/\$/ -lutil/;"
220 PLATFORM_CFLAGS="-DHAVE_OPENPTY"
221 ;; *)
222 SED=
223 esac
224 elif [ "$f" = "libmpeg3" ]
225 then
226 # Patch our Makefile.in file with the platform specifics for the libmpeg3 library
227 # Use the C++ compiler to compile the .c files (because the fixed-point classes are C++ code)
228 SED='s/\$(CC)/\$(CXX)/;'
229 case $PLATFORM
230 in
231 # For x86 turn on using floating point, compile mmx and css code
232 *x86*)
233 # "-funroll-loops -fomit-frame-pointer -malign-loops=2 -malign-jumps=2 -malign-functions=2 -march=i486"
234 PLATFORM_CFLAGS="-DHAVE_MMX -DHAVE_CSS"
235 SED="$SED /SOURCES.*=/s/=/= video\\/mmxidct.S video\\/reconmmx.s\ /;"
236 # For generic turn on using floating point
237 ;; *generic*)
238 PLATFORM_CFLAGS=""
239 # For the ipaq use fixed point maths, don't compile the mmx or css code
240 ;; *ipaq*|*sharp*)
241 PLATFORM_CFLAGS="-DUSE_FIXED_POINT"
242 ;; *)
243 # For 'other platforms', turn off optimizations and use fixed point
244 PLATFORM_CFLAGS="-O -DUSE_FIXED_POINT"
245 esac
246 elif [ "$f" = "libmad" ]
247 then
248 # Patch our Makefile.in file with the platform specifics for the libmad library
249 case $PLATFORM
250 in
251 # For x86 use intel optimizations
252 *x86*)
253 PLATFORM_CFLAGS="-DFPM_INTEL"
254 # For the ipaq use ARM asm optimizations
255 ;; *ipaq*|*sharp*)
256 PLATFORM_CFLAGS="-DFPM_ARM"
257 SED="$SED /SOURCES.*=/s/=/= idmt_arm.S /;"
258 # For generic platforms use the C 64-bit implementation
259 ;; *generic*)
260 PLATFORM_CFLAGS="-DFPM_64BIT"
261 # For 'other platforms' use the ARM code
262 ;; *)
263 PLATFORM_CFLAGS="-DFPM_ARM"
264 SED="$SED /SOURCES.*=/s/=/= idmt_arm.S /;"
265 esac
266 fi
267 if [ -n "$PLATFORM_CFLAGS" ]
268 then
269 # Append the addition c-flags we have defined
270 SED="$SED /CFLAGS.*=.*/s/\$/ $PLATFORM_CFLAGS/;"
271 SED="$SED /CXXFLAGS.*=.*/s/\$/ $PLATFORM_CFLAGS/;"
272 fi
273 cat $TARGET >> $N
274 if [ -n "$SED" ]
275 then
276 sed -e "$SED" $M >> $N
277 else
278 cat $M >> $N
279 fi
280
281 cat >> $N <<EOF
282
283lupdate:
284 lupdate $f.pro
285
286lrelease:
287 lrelease $f.pro
288
289EOF
290 if [ -f "$O" ]
291 then
292 cat >> $N $O
293 fi
294
295done
296
297MAKE=make
298echo
299echo "Opie is now configured for building. Just run $MAKE (or $MAKE single)."
300echo "To reconfigure, run $MAKE clean and configure."
301echo
diff --git a/libopie/ofileselector/libopie.pro b/libopie/ofileselector/libopie.pro
new file mode 100644
index 0000000..0fa43fc
--- a/dev/null
+++ b/libopie/ofileselector/libopie.pro
@@ -0,0 +1,97 @@
1TEMPLATE = lib
2CONFIG += qte warn_on release
3HEADERS = ofontmenu.h \
4 ocolorbutton.h \
5 ofileselector/odefaultfactories.h \
6 ofileselector/ofiledialog.h \
7 ofileselector/ofilelistview.h \
8 ofileselector/ofileselector.h \
9 ofileselector/ofileselectoritem.h \
10 ofileselector/ofileseleczormain.h \
11 ofileselector/ofileview.h \
12 ofileselector/olister.h \
13 ofileselector/olocallister.h \
14 ofileselector/opixmapprovider.h \
15 tododb.h \
16 ocheckitem.h todoevent.h todoresource.h \
17 todovcalresource.h xmltree.h \
18 colordialog.h colorpopupmenu.h \
19 oclickablelabel.h oprocctrl.h \
20 oprocess.h odevice.h \
21 otimepicker.h otabwidget.h \
22 otabbar.h otabinfo.h \
23 ofontselector.h \
24 pim/opimrecord.h \
25 pim/otodo.h \
26 pim/orecordlist.h \
27 pim/opimaccesstemplate.h \
28 pim/opimaccessbackend.h \
29 pim/otodoaccess.h \
30 pim/otodacessbackend.h \
31 pim/ocontact.h \
32 pim/ocontactaccess.h \
33 pim/ocontactaccessbackend.h \
34 pim/ocontactaccessbackend_xml.h \
35 pim/obackendfactory.h \
36 pim/opimcache.h \
37 pim/otodoaccessvcal.h \
38 pim/orecur.h \
39 orecurrancewidget.h
40# pim/otodoaccesssql.h \
41
42SOURCES = ofontmenu.cc \
43 ocolorbutton.cpp \
44 ofileselector/odefaultfactories.cpp \
45 ofileselector/ofiledialog.cpp \
46 ofileselector/ofilefactory.cpp \
47 ofileselector/ofilelistview.cpp \
48 ofileselector/ofileselector.cpp \
49 ofileselector/ofileselectoritem.cpp \
50 ofileselector/ofileselectormain.cpp \
51 ofileselector/ofileview.cpp \
52 ofileselector/olister.cpp \
53 ofileselector/olocallister.cpp \
54 ofileselector/opixmapprovider.cpp \
55 xmltree.cc \
56 ocheckitem.cpp tododb.cpp todoevent.cpp \
57 todovcalresource.cpp colordialog.cpp \
58 colorpopupmenu.cpp oclickablelabel.cpp \
59 oprocctrl.cpp oprocess.cpp \
60 odevice.cpp otimepicker.cpp \
61 otabwidget.cpp otabbar.cpp \
62 ofontselector.cpp \
63 pim/otodo.cpp \
64 pim/opimrecord.cpp \
65 pim/otodoaccess.cpp \
66 pim/otodoaccessbackend.cpp \
67 pim/otodoaccessxml.cpp \
68 pim/ocontact.cpp \
69 pim/ocontactaccess.cpp \
70 pim/otodoaccessvcal.cpp \
71 pim/orecur.cpp \
72 orecurrancewidget.cpp
73# pim/otodoaccesssql.cpp \
74
75TARGET = opie
76INCLUDEPATH += $(OPIEDIR)/include
77DESTDIR = $(QTDIR)/lib$(PROJMAK)
78#VERSION = 1.0.0
79
80# LIBS += -lopiesql
81
82INTERFACES = otimepickerbase.ui orecurrancebase.ui
83
84TRANSLATIONS = ../i18n/de/libopie.ts \
85 ../i18n/en/libopie.ts \
86 ../i18n/es/libopie.ts \
87 ../i18n/fr/libopie.ts \
88 ../i18n/hu/libopie.ts \
89 ../i18n/ja/libopie.ts \
90 ../i18n/ko/libopie.ts \
91 ../i18n/no/libopie.ts \
92 ../i18n/pl/libopie.ts \
93 ../i18n/pt/libopie.ts \
94 ../i18n/pt_BR/libopie.ts \
95 ../i18n/sl/libopie.ts \
96 ../i18n/zh_CN/libopie.ts \
97 ../i18n/zh_TW/libopie.ts
diff --git a/libopie/ofileselector/ofilelistview.cpp b/libopie/ofileselector/ofilelistview.cpp
index 9cfdc48..fe8acf0 100644
--- a/libopie/ofileselector/ofilelistview.cpp
+++ b/libopie/ofileselector/ofilelistview.cpp
@@ -1,203 +1,201 @@
1 1
2#include <qheader.h> 2#include <qheader.h>
3 3
4#include <qpe/mimetype.h> 4#include <qpe/mimetype.h>
5#include <qpe/resource.h> 5#include <qpe/resource.h>
6#include <qpe/qpeapplication.h> 6#include <qpe/qpeapplication.h>
7 7
8#include "ofileselector.h" 8#include "ofileselector.h"
9#include "ofileselectoritem.h" 9#include "ofileselectoritem.h"
10#include "ofilelistview.h" 10#include "ofilelistview.h"
11 11
12 12
13OFileListView::OFileListView( QWidget* parent, OFileSelector* sel) 13OFileListView::OFileListView( QWidget* parent, OFileSelector* sel)
14 : QListView( parent ), OFileView( sel ) 14 : QListView( parent ), OFileView( sel )
15{ 15{
16 QPEApplication::setStylusOperation( viewport(), 16 QPEApplication::setStylusOperation( viewport(),
17 QPEApplication::RightOnHold); 17 QPEApplication::RightOnHold);
18 addColumn(" " ); 18 addColumn(" " );
19 addColumn(tr("Name"), 135 ); 19 addColumn(tr("Name"), 135 );
20 addColumn(tr("Size"), -1 ); 20 addColumn(tr("Size"), -1 );
21 addColumn(tr("Date"), 60 ); 21 addColumn(tr("Date"), 60 );
22 addColumn(tr("Mime Type"), -1 ); 22 addColumn(tr("Mime Type"), -1 );
23 QHeader *head = header(); 23 QHeader *head = header();
24 head->hide(); 24 head->hide();
25 setSorting( 1 ); 25 setSorting( 1 );
26 setAllColumnsShowFocus( TRUE ); 26 setAllColumnsShowFocus( TRUE );
27 27
28 connect(this, SIGNAL(selectionChanged() ), 28 connect(this, SIGNAL(selectionChanged() ),
29 this, SLOT(slotSelectionChanged() ) ); 29 this, SLOT(slotSelectionChanged() ) );
30 30
31 connect(this, SIGNAL(currentChanged(QListViewItem *) ), 31 connect(this, SIGNAL(currentChanged(QListViewItem *) ),
32 this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); 32 this, SLOT(slotCurrentChanged(QListViewItem * ) ) );
33 33
34 connect(this, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), 34 connect(this, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ),
35 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); 35 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) );
36 36
37 connect(this, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), 37 connect(this, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )),
38 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); 38 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) );
39} 39}
40OFileListView::~OFileListView() { 40OFileListView::~OFileListView() {
41 41
42} 42}
43void OFileListView::clear() { 43void OFileListView::clear() {
44 QListView::clear(); 44 QListView::clear();
45} 45}
46void OFileListView::addFile( const QPixmap& pix, 46void OFileListView::addFile( const QPixmap& pix,
47 const QString&, 47 const QString&,
48 QFileInfo* info, 48 QFileInfo* info,
49 const QString& /*extra*/, 49 const QString& extra,
50 bool isSymlink ) { 50 bool isSymlink ) {
51 QString dir; 51 QString dir;
52 QString name; 52 QString name;
53 bool locked = false; 53 bool locked = false;
54 54
55 dir = info->dirPath( true ); 55 dir = info->dirPath( true );
56 56
57 if( isSymlink ) 57 if( isSymlink )
58 name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); 58 name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink();
59 else { 59 else {
60 name = info->fileName(); 60 name = info->fileName();
61 if( ( selector()->mode() == OFileSelector::Open && !info->isReadable() ) || 61 if( ( selector()->mode() == OFileSelector::Open && !info->isReadable() ) ||
62 ( selector()->mode() == OFileSelector::Save && !info->isWritable() ) ){ 62 ( selector()->mode() == OFileSelector::Save && !info->isWritable() ) ){
63 63
64 locked = true; 64 locked = true;
65 } 65 }
66 } 66 }
67 new OFileSelectorItem( this, pix, name, 67 new OFileSelectorItem( this, pix, name,
68 info->lastModified().toString(), 68 info->lastModified().toString(),
69 QString::number( info->size() ), 69 QString::number( info->size() ),
70 dir, locked ); 70 dir, locked, extra );
71} 71}
72void OFileListView::addFile( const QPixmap&, 72void OFileListView::addFile( const QPixmap&,
73 const QString& /*mime*/, const QString& /*dir*/, 73 const QString& /*mime*/, const QString& /*dir*/,
74 const QString& /*file*/, 74 const QString& /*file*/,
75 const QString& /*extra*/, 75 const QString& /*extra*/,
76 bool /*isSyml*/ ) { 76 bool /*isSyml*/ ) {
77 77
78} 78}
79void OFileListView::addDir( const QPixmap& pix, const QString&, 79void OFileListView::addDir( const QPixmap& pix, const QString&,
80 QFileInfo* info, 80 QFileInfo* info,
81 const QString& /*extra */, 81 const QString& extra ,
82 bool symlink ) { 82 bool symlink ) {
83 83
84 bool locked = false; 84 bool locked = false;
85 QString name; 85 QString name;
86 86
87 name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; 87 name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ;
88 88
89 new OFileSelectorItem( this, pix, name, 89 new OFileSelectorItem( this, pix, name,
90 info->lastModified().toString(), 90 info->lastModified().toString(),
91 QString::number( info->size() ), 91 QString::number( info->size() ),
92 info->dirPath( true ), locked, 92 info->dirPath( true ), locked, extra,
93 true ); 93 true );
94 94
95} 95}
96void OFileListView::addDir( const QPixmap&, 96void OFileListView::addDir( const QPixmap&,
97 const QString& /*mime*/, const QString& /*dir*/, 97 const QString& /*mime*/, const QString& /*dir*/,
98 const QString& /*file*/, 98 const QString& /*file*/,
99 const QString& /*extra*/, 99 const QString& /*extra*/,
100 bool ) { 100 bool ) {
101 101
102} 102}
103void OFileListView::addSymlink( const QPixmap&, 103void OFileListView::addSymlink( const QPixmap&,
104 const QString& /*mime*/, 104 const QString& /*mime*/,
105 QFileInfo* /*info*/, 105 QFileInfo* /*info*/,
106 const QString& /*extra*/, 106 const QString& /*extra*/,
107 bool /*isSym*/ ) { 107 bool /*isSym*/ ) {
108 108
109} 109}
110void OFileListView::addSymlink(const QPixmap&, 110void OFileListView::addSymlink(const QPixmap&,
111 const QString& /*m*/, const QString& /*path*/, 111 const QString& /*m*/, const QString& /*path*/,
112 const QString& /*file*/, 112 const QString& /*file*/,
113 const QString& /*extra*/, 113 const QString& /*extra*/,
114 bool /*isSym*/ ) { 114 bool /*isSym*/ ) {
115 115
116} 116}
117void OFileListView::cd( const QString& ) { 117void OFileListView::cd( const QString& ) {
118 118
119} 119}
120QWidget* OFileListView::widget() { 120QWidget* OFileListView::widget() {
121 return this; 121 return this;
122} 122}
123QString OFileListView::selectedName()const{ 123QString OFileListView::selectedName()const{
124 QListViewItem *item = currentItem(); 124 QListViewItem *item = currentItem();
125 if (!item ) 125 if (!item )
126 return QString::null; 126 return QString::null;
127 127
128 return item->text( 1 ); 128 return item->text( 1 );
129} 129}
130QString OFileListView::selectedExtra()const{
131 QListViewItem* item = currentItem();
132 if (!item) return QString::null;
133 OFileSelectorItem* fit = (OFileSelectorItem*)fit;
134
135 return fit->extra();
136}
130QStringList OFileListView::selectedNames()const { 137QStringList OFileListView::selectedNames()const {
131 QStringList list; 138 QStringList list;
132 list << selectedName(); 139 list << selectedName();
133 return list; 140 return list;
134} 141}
135QString OFileListView::selectedPath()const { 142QString OFileListView::selectedPath()const {
136 return QString::null; 143 return QString::null;
137} 144}
138QStringList OFileListView::selectedPaths()const { 145QStringList OFileListView::selectedPaths()const {
139 QStringList list; 146 QStringList list;
140b list << selectedPath(); 147 list << selectedPath();
141 return list; 148 return list;
142} 149}
143int OFileListView::fileCount() { 150int OFileListView::fileCount() {
144 return childCount(); 151 return childCount();
145} 152}
146void OFileListView::sort() { 153void OFileListView::sort() {
147 QListView::sort(); 154 QListView::sort();
148} 155}
149void OFileListView::slotSelectionChanged() { 156void OFileListView::slotSelectionChanged() {
150 157
151} 158}
152void OFileListView::slotCurrentChanged( QListViewItem* item) { 159void OFileListView::slotCurrentChanged( QListViewItem* item) {
153 if (!item ) 160 if (!item )
154 return; 161 return;
155 162
156 OFileSelectorItem* sel = (OFileSelectorItem*) item; 163 OFileSelectorItem* sel = (OFileSelectorItem*) item;
157 164
158 qWarning("current changed"); 165 qWarning("current changed");
159 if(!sel->isDir() ){ 166 if(!sel->isDir() ){
160 updateLine( sel->text(1) ); 167 updateLine( sel->text(1) );
161 168
162 if (selector()->mode() == OFileSelector::Fileselector ) { 169 if (selector()->mode() == OFileSelector::Fileselector ) {
163 QStringList str = QStringList::split("->", sel->text(1) ); 170 QStringList str = QStringList::split("->", sel->text(1) );
164 QString path =sel->directory() + "/" + str[0].stripWhiteSpace(); 171 fileSelected(sel->directory(), str[0].stripWhiteSpace(),sel->extra() );
165 DocLnk lnk( path );
166 fileSelected(lnk );
167 fileSelected( path );
168 } 172 }
169 } 173 }
170} 174}
171void OFileListView::slotClicked( int button, QListViewItem* item, 175void OFileListView::slotClicked( int button, QListViewItem* item,
172 const QPoint&, int ) { 176 const QPoint&, int ) {
173 if ( !item ) 177 if ( !item )
174 return; 178 return;
175 179
176 if( button != Qt::LeftButton ) 180 if( button != Qt::LeftButton )
177 return; 181 return;
178 182
179 OFileSelectorItem *sel = (OFileSelectorItem*)item; 183 OFileSelectorItem *sel = (OFileSelectorItem*)item;
180 184
181 if(!sel->isLocked() ){ 185 if(!sel->isLocked() ){
182 QStringList str = QStringList::split("->", sel->text(1) ); 186 QStringList str = QStringList::split("->", sel->text(1) );
183 if( sel->isDir() ){ 187 if( sel->isDir() ){
184 changedDir( sel->directory() + "/" + str[0].stripWhiteSpace() ); 188 changedDir( sel->directory(), str[0].stripWhiteSpace(),sel->extra() );
185 }else{ 189 }else{
186 updateLine( str[0].stripWhiteSpace() ); 190 updateLine( str[0].stripWhiteSpace() );
187 QString path = sel->directory(); 191 fileSelected( sel->directory(),str[0].stripWhiteSpace(), sel->extra() );
188 path += "/";
189 path += str[0].stripWhiteSpace();
190
191 DocLnk lnk( path );
192 fileSelected( path );
193 fileSelected( lnk );
194 } 192 }
195 } 193 }
196} 194}
197void OFileListView::slotRightButton( int button, QListViewItem* item, 195void OFileListView::slotRightButton( int button, QListViewItem* item,
198 const QPoint&, int ) { 196 const QPoint&, int ) {
199 if (!item || (button != Qt::RightButton )) 197 if (!item || (button != Qt::RightButton ))
200 return; 198 return;
201 199
202 /* raise contextmenu */ 200 /* raise contextmenu */
203} 201}
diff --git a/libopie/ofileselector/ofilelistview.h b/libopie/ofileselector/ofilelistview.h
index 0f625ec..f2eac57 100644
--- a/libopie/ofileselector/ofilelistview.h
+++ b/libopie/ofileselector/ofilelistview.h
@@ -1,67 +1,69 @@
1#ifndef OPIE_FILE_LIST_VIEW_H 1#ifndef OPIE_FILE_LIST_VIEW_H
2#define OPIE_FILE_LIST_VIEW_H 2#define OPIE_FILE_LIST_VIEW_H
3 3
4#include <qlistview.h> 4#include <qlistview.h>
5#include <qpixmap.h> 5#include <qpixmap.h>
6 6
7#include "ofileview.h" 7#include "ofileview.h"
8 8
9class OFileListView : public QListView, public OFileView { 9class OFileListView : public QListView, public OFileView {
10 Q_OBJECT 10 Q_OBJECT
11public: 11public:
12 OFileListView( QWidget* parent, OFileSelector* ); 12 OFileListView( QWidget* parent, OFileSelector* );
13 ~OFileListView(); 13 ~OFileListView();
14 14
15 void clear(); 15 void clear();
16 void addFile( const QPixmap&, 16 void addFile( const QPixmap&,
17 const QString& mine, 17 const QString& mine,
18 QFileInfo* info, 18 QFileInfo* info,
19 const QString& extra = QString::null, 19 const QString& extra = QString::null,
20 bool isSymlink = FALSE ); 20 bool isSymlink = FALSE );
21 21
22 void addFile( const QPixmap&, 22 void addFile( const QPixmap&,
23 const QString& mime, 23 const QString& mime,
24 const QString& dir, 24 const QString& dir,
25 const QString& file, 25 const QString& file,
26 const QString& extra = QString::null, 26 const QString& extra = QString::null,
27 bool = false ); 27 bool = false );
28 28
29 void addDir( const QPixmap&, 29 void addDir( const QPixmap&,
30 const QString& mime, 30 const QString& mime,
31 QFileInfo* info,
31 const QString& extra = QString::null, 32 const QString& extra = QString::null,
32 QFileInfo* info, bool = FALSE ); 33 bool = FALSE );
33 34
34 void addDir( const QPixmap&, 35 void addDir( const QPixmap&,
35 const QString& mime, const QString& dir, 36 const QString& mime, const QString& dir,
36 const QString& file, 37 const QString& file,
37 const QString& extra = QString::null, 38 const QString& extra = QString::null,
38 bool = FALSE ); 39 bool = FALSE );
39 40
40 void addSymlink( const QPixmap&, 41 void addSymlink( const QPixmap&,
41 const QString& mime, 42 const QString& mime,
42 QFileInfo* info, 43 QFileInfo* info,
43 const QString& extra = QString::null, 44 const QString& extra = QString::null,
44 bool = FALSE ); 45 bool = FALSE );
45 void addSymlink( const QPixmap&, 46 void addSymlink( const QPixmap&,
46 const QString& mine, const QString& path, 47 const QString& mine, const QString& path,
47 const QString& file, 48 const QString& file,
48 const QString& extra, 49 const QString& extra = QString::null,
49 bool isSymlink = FALSE ); 50 bool isSymlink = FALSE );
50 void cd( const QString& path ); 51 void cd( const QString& path );
51 QWidget* widget(); 52 QWidget* widget();
52 void sort(); 53 void sort();
53 54
54 QString selectedName()const ; 55 QString selectedName()const ;
55 QStringList selectedNames()const; 56 QStringList selectedNames()const;
56 57
57 QString selectedPath()const; 58 QString selectedPath()const;
58 QStringList selectedPaths()const; 59 QStringList selectedPaths()const;
60 QString selectedExtra()const;
59 int fileCount(); 61 int fileCount();
60private slots: 62private slots:
61 void slotSelectionChanged(); 63 void slotSelectionChanged();
62 void slotCurrentChanged(QListViewItem* ); 64 void slotCurrentChanged(QListViewItem* );
63 void slotClicked( int, QListViewItem*, const QPoint&, int ); 65 void slotClicked( int, QListViewItem*, const QPoint&, int );
64 void slotRightButton(int, QListViewItem*, const QPoint&, int ); 66 void slotRightButton(int, QListViewItem*, const QPoint&, int );
65}; 67};
66 68
67#endif 69#endif
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp
index 0ccb3cb..255e79e 100644
--- a/libopie/ofileselector/ofileselector.cpp
+++ b/libopie/ofileselector/ofileselector.cpp
@@ -271,829 +271,831 @@ QString OFileSelector::selectedName() const
271 DocLnk lnk = m_select->selectedDocument(); 271 DocLnk lnk = m_select->selectedDocument();
272 name = lnk.file(); 272 name = lnk.file();
273 }else { 273 }else {
274 if ( m_shLne ) { 274 if ( m_shLne ) {
275 name = m_currentDir + "/" +m_edit->text(); 275 name = m_currentDir + "/" +m_edit->text();
276 }else{ 276 }else{
277 name = m_currentDir + "/" + currentView()->selectedName(); 277 name = m_currentDir + "/" + currentView()->selectedName();
278 } 278 }
279 } 279 }
280 return name; 280 return name;
281} 281}
282QStringList OFileSelector::selectedNames()const 282QStringList OFileSelector::selectedNames()const
283{ 283{
284 QStringList list; 284 QStringList list;
285 if( m_selector == Normal ){ 285 if( m_selector == Normal ){
286 list << selectedName(); 286 list << selectedName();
287 }else { 287 }else {
288 list << selectedName(); // FIXME implement multiple Selections 288 list << selectedName(); // FIXME implement multiple Selections
289 } 289 }
290 return list; 290 return list;
291} 291}
292/** If mode is set to the Dir selection this will return the selected path. 292/** If mode is set to the Dir selection this will return the selected path.
293 * 293 *
294 * 294 *
295 */ 295 */
296QString OFileSelector::selectedPath()const 296QString OFileSelector::selectedPath()const
297{ 297{
298 QString path; 298 QString path;
299 if( m_selector == Normal ){ 299 if( m_selector == Normal ){
300 path = QPEApplication::documentDir(); 300 path = QPEApplication::documentDir();
301 } /* normal case to do */ 301 } /* normal case to do */
302 return path; 302 return path;
303} 303}
304QStringList OFileSelector::selectedPaths() const 304QStringList OFileSelector::selectedPaths() const
305{ 305{
306 QStringList list; 306 QStringList list;
307 list << selectedPath(); 307 list << selectedPath();
308 return list; 308 return list;
309} 309}
310QString OFileSelector::directory()const 310QString OFileSelector::directory()const
311{ 311{
312 if( m_selector == Normal ) 312 if( m_selector == Normal )
313 return QPEApplication::documentDir(); 313 return QPEApplication::documentDir();
314 314
315 return QDir(m_currentDir).absPath(); 315 return QDir(m_currentDir).absPath();
316} 316}
317 317
318int OFileSelector::fileCount() 318int OFileSelector::fileCount()
319{ 319{
320 int count; 320 int count;
321 switch( m_selector ){ 321 switch( m_selector ){
322 case Normal: 322 case Normal:
323 count = m_select->fileCount(); 323 count = m_select->fileCount();
324 break; 324 break;
325 case Extended: 325 case Extended:
326 case ExtendedAll: 326 case ExtendedAll:
327 default: 327 default:
328 count = currentView()->fileCount(); 328 count = currentView()->fileCount();
329 break; 329 break;
330 } 330 }
331 return count; 331 return count;
332} 332}
333DocLnk OFileSelector::selectedDocument() const 333DocLnk OFileSelector::selectedDocument() const
334{ 334{
335 DocLnk lnk; 335 DocLnk lnk;
336 switch( m_selector ){ 336 switch( m_selector ){
337 case Normal:{ 337 case Normal:{
338 lnk = m_select->selectedDocument(); 338 lnk = m_select->selectedDocument();
339 break; 339 break;
340 } 340 }
341 case Extended: 341 case Extended:
342 case ExtendedAll: 342 case ExtendedAll:
343 default: 343 default:
344 lnk = DocLnk( selectedName() ); 344 lnk = DocLnk( selectedName() );
345 break; 345 break;
346 } 346 }
347 return lnk; 347 return lnk;
348} 348}
349QValueList<DocLnk> OFileSelector::selectedDocuments() const 349QValueList<DocLnk> OFileSelector::selectedDocuments() const
350{ 350{
351 QValueList<DocLnk> docs; 351 QValueList<DocLnk> docs;
352 docs.append( selectedDocument() ); 352 docs.append( selectedDocument() );
353 return docs; 353 return docs;
354} 354}
355 355
356 356
357// slots internal 357// slots internal
358 358
359void OFileSelector::slotOk() 359void OFileSelector::slotOk()
360{ 360{
361 emit ok(); 361 emit ok();
362} 362}
363void OFileSelector::slotCancel() 363void OFileSelector::slotCancel()
364{ 364{
365 emit cancel(); 365 emit cancel();
366} 366}
367/* switch the views */ 367/* switch the views */
368void OFileSelector::slotViewCheck(const QString &sel) 368void OFileSelector::slotViewCheck(const QString &sel)
369{ 369{
370 setView( sel ); 370 setView( sel );
371} 371}
372 372
373QString OFileSelector::currentMimeType() const{ 373QString OFileSelector::currentMimeType() const{
374 QString mime; 374 QString mime;
375 QString currentText; 375 QString currentText;
376 if (m_shChooser && m_mimeCheck ) 376 if (m_shChooser && m_mimeCheck )
377 currentText = m_mimeCheck->currentText(); 377 currentText = m_mimeCheck->currentText();
378 378
379 qWarning("CurrentText" + currentText ); 379 qWarning("CurrentText" + currentText );
380 if (tr("All") == currentText ) return QString::null; 380 if (tr("All") == currentText ) return QString::null;
381 else if (currentText.isEmpty() ) { 381 else if (currentText.isEmpty() ) {
382 ; 382 ;
383 }else { 383 }else {
384 QMap<QString, QStringList>::ConstIterator it; 384 QMap<QString, QStringList>::ConstIterator it;
385 it = m_mimetypes.find( currentText ); 385 it = m_mimetypes.find( currentText );
386 if ( it != m_mimetypes.end() ) { 386 if ( it != m_mimetypes.end() ) {
387 mime = it.data().join(";"); 387 mime = it.data().join(";");
388 }else{ 388 }else{
389 mime = currentText; 389 mime = currentText;
390 } 390 }
391 } 391 }
392 return mime; 392 return mime;
393} 393}
394void OFileSelector::slotMimeCheck(const QString &mime) 394void OFileSelector::slotMimeCheck(const QString &mime)
395{ 395{
396 if( m_selector == Normal ){ 396 if( m_selector == Normal ){
397 initializeOldSelector(); 397 initializeOldSelector();
398 398
399 updateMimes(); 399 updateMimes();
400 updateMimeCheck(); 400 updateMimeCheck();
401 m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); 401 m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
402 }else{ // others 402 }else{ // others
403 qWarning("Mime %s", mime.latin1() ); 403 qWarning("Mime %s", mime.latin1() );
404 if(m_shChooser ){ 404 if(m_shChooser ){
405 qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); 405 qWarning("Current Text %s", m_mimeCheck->currentText().latin1() );
406 //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); 406 //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
407 } 407 }
408 reparse(); 408 reparse();
409 } 409 }
410} 410}
411/* 411/*
412 * Ok if a non dir gets inserted into this combobox 412 * Ok if a non dir gets inserted into this combobox
413 * we need to change it 413 * we need to change it
414 * QFileInfo and dirPath will give us the right Dir 414 * QFileInfo and dirPath will give us the right Dir
415 */ 415 */
416void OFileSelector::slotLocationActivated(const QString &file) 416void OFileSelector::slotLocationActivated(const QString &file)
417{ 417{
418 qWarning("slotLocationActivated"); 418 qWarning("slotLocationActivated");
419 QString name = file.left( file.find("<-", 0, TRUE ) ); 419 QString name = file.left( file.find("<-", 0, TRUE ) );
420 QFileInfo info( name ); 420 QFileInfo info( name );
421 if ( info.isFile() ) 421 if ( info.isFile() )
422 cd(info.dirPath( TRUE ) ); //absolute 422 cd(info.dirPath( TRUE ) ); //absolute
423 else 423 else
424 cd(name ); 424 cd(name );
425 reparse(); 425 reparse();
426} 426}
427void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count) 427void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count)
428{ 428{
429 QStringList pathList; 429 QStringList pathList;
430 bool underDog = FALSE; 430 bool underDog = FALSE;
431 for(int i=0;i<count;i++) { 431 for(int i=0;i<count;i++) {
432 pathList << m_location->text(i); 432 pathList << m_location->text(i);
433 if( m_location->text(i) == currentPath) 433 if( m_location->text(i) == currentPath)
434 underDog = TRUE; 434 underDog = TRUE;
435 } 435 }
436 if( !underDog) { 436 if( !underDog) {
437 m_location->clear(); 437 m_location->clear();
438 if( currentPath.left(2)=="//") 438 if( currentPath.left(2)=="//")
439 pathList.append( currentPath.right(currentPath.length()-1) ); 439 pathList.append( currentPath.right(currentPath.length()-1) );
440 else 440 else
441 pathList.append( currentPath ); 441 pathList.append( currentPath );
442 m_location->insertStringList( pathList,-1); 442 m_location->insertStringList( pathList,-1);
443 } 443 }
444} 444}
445/* 445/*
446 * Do not crash anymore 446 * Do not crash anymore
447 * don't try to change dir to a file 447 * don't try to change dir to a file
448 */ 448 */
449void OFileSelector::locationComboChanged() 449void OFileSelector::locationComboChanged()
450{ 450{
451 QFileInfo info( m_location->lineEdit()->text() ); 451 QFileInfo info( m_location->lineEdit()->text() );
452 qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); 452 qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() );
453 if (info.isFile() ) 453 if (info.isFile() )
454 cd(info.dirPath(TRUE) ); //absolute path 454 cd(info.dirPath(TRUE) ); //absolute path
455 else 455 else
456 cd( m_location->lineEdit()->text() ); 456 cd( m_location->lineEdit()->text() );
457 457
458 reparse(); 458 reparse();
459} 459}
460void OFileSelector::init() 460void OFileSelector::init()
461{ 461{
462 initFactory(); 462 initFactory();
463 m_lay = new QVBoxLayout( this ); 463 m_lay = new QVBoxLayout( this );
464 m_lay->setSpacing(0 ); 464 m_lay->setSpacing(0 );
465 465
466 /* take care of the main view... */ 466 /* take care of the main view... */
467 initToolbar(); 467 initToolbar();
468 //if( m_shChooser ) // the Chooser for the view and Mimetypes 468 //if( m_shChooser ) // the Chooser for the view and Mimetypes
469 initializeChooser(); 469 initializeChooser();
470 470
471 /* initialize the file lister */ 471 /* initialize the file lister */
472 if( m_selector == Normal ){ 472 if( m_selector == Normal ){
473 QString mime; 473 QString mime;
474 if (!m_autoMime) { 474 if (!m_autoMime) {
475 if (!m_mimetypes.isEmpty() ) { 475 if (!m_mimetypes.isEmpty() ) {
476 QMap<QString, QStringList>::Iterator it; 476 QMap<QString, QStringList>::Iterator it;
477 it = m_mimetypes.begin(); // cause we're in the init 477 it = m_mimetypes.begin(); // cause we're in the init
478 mime = it.data().join(";"); 478 mime = it.data().join(";");
479 } 479 }
480 } 480 }
481 initializeOldSelector(); 481 initializeOldSelector();
482 }else{ 482 }else{
483 initializeView(); 483 initializeView();
484 } 484 }
485 485
486 if( m_shLne ) // the LineEdit with the current FileName 486 if( m_shLne ) // the LineEdit with the current FileName
487 initializeName(); 487 initializeName();
488 488
489 if( m_shPerm ) // the Permission QCheckBox 489 if( m_shPerm ) // the Permission QCheckBox
490 initializePerm(); 490 initializePerm();
491 491
492 if( m_shYesNo ) // the Yes No button row 492 if( m_shYesNo ) // the Yes No button row
493 initializeYes( ); 493 initializeYes( );
494 494
495 if (m_selector != Normal ) 495 if (m_selector != Normal )
496 reparse(); 496 reparse();
497} 497}
498void OFileSelector::updateMimes() 498void OFileSelector::updateMimes()
499{ 499{
500 if( m_autoMime ){ 500 if( m_autoMime ){
501 m_mimetypes.clear(); 501 m_mimetypes.clear();
502 m_mimetypes.insert( tr("All"), QString::null ); 502 m_mimetypes.insert( tr("All"), QString::null );
503 if( m_selector == Normal ){ 503 if( m_selector == Normal ){
504 DocLnkSet set; 504 DocLnkSet set;
505 Global::findDocuments(&set, QString::null ); 505 Global::findDocuments(&set, QString::null );
506 QListIterator<DocLnk> dit( set.children() ); 506 QListIterator<DocLnk> dit( set.children() );
507 for( ; dit.current(); ++dit ){ 507 for( ; dit.current(); ++dit ){
508 if( !m_mimetypes.contains( (*dit)->type() ) ) 508 if( !m_mimetypes.contains( (*dit)->type() ) )
509 m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); 509 m_mimetypes.insert( (*dit)->type(), (*dit)->type() );
510 } 510 }
511 }// else done in reparse 511 }// else done in reparse
512 } 512 }
513} 513}
514void OFileSelector::initVars() 514void OFileSelector::initVars()
515{ 515{
516 if( m_mimetypes.isEmpty() ) 516 if( m_mimetypes.isEmpty() )
517 m_autoMime = true; 517 m_autoMime = true;
518 else 518 else
519 m_autoMime = false; 519 m_autoMime = false;
520 520
521 m_shClose = false; 521 m_shClose = false;
522 m_shNew = false; 522 m_shNew = false;
523 m_shTool = true; 523 m_shTool = true;
524 m_shPerm = false; 524 m_shPerm = false;
525 m_shLne = true; 525 m_shLne = true;
526 m_shChooser = true; 526 m_shChooser = true;
527 m_shYesNo = true; 527 m_shYesNo = true;
528 m_case = false; 528 m_case = false;
529 m_dir = true; 529 m_dir = true;
530 m_files = true; 530 m_files = true;
531 m_showPopup = false; 531 m_showPopup = false;
532 m_mainView = 0l; 532 m_mainView = 0l;
533 m_fileView = 0l; 533 m_fileView = 0l;
534 m_lister = 0l; 534 m_lister = 0l;
535 535
536 if(m_pixmaps == 0 ) // init the pixmaps 536 if(m_pixmaps == 0 ) // init the pixmaps
537 initPics(); 537 initPics();
538 538
539 // pointers 539 // pointers
540 m_location = 0; 540 m_location = 0;
541 m_mimeCheck = 0; 541 m_mimeCheck = 0;
542 m_viewCheck = 0; 542 m_viewCheck = 0;
543 m_homeButton = 0; 543 m_homeButton = 0;
544 m_docButton = 0; 544 m_docButton = 0;
545 m_hideButton = 0; 545 m_hideButton = 0;
546 m_ok = 0; 546 m_ok = 0;
547 m_cancel = 0; 547 m_cancel = 0;
548 m_reread = 0; 548 m_reread = 0;
549 m_up = 0; 549 m_up = 0;
550 m_View = 0; 550 m_View = 0;
551 m_checkPerm = 0; 551 m_checkPerm = 0;
552 m_pseudo = 0; 552 m_pseudo = 0;
553 m_pseudoLayout = 0; 553 m_pseudoLayout = 0;
554 m_select = 0; 554 m_select = 0;
555 m_lay = 0; 555 m_lay = 0;
556 m_Oselector = 0; 556 m_Oselector = 0;
557 m_boxToolbar = 0; 557 m_boxToolbar = 0;
558 m_boxOk = 0; 558 m_boxOk = 0;
559 m_boxName = 0; 559 m_boxName = 0;
560 m_boxView = 0; 560 m_boxView = 0;
561 m_edit = 0; 561 m_edit = 0;
562 m_fnLabel = 0; 562 m_fnLabel = 0;
563 m_new = 0; 563 m_new = 0;
564 m_close = 0; 564 m_close = 0;
565} 565}
566void OFileSelector::initializeName() 566void OFileSelector::initializeName()
567{ 567{
568 /** Name Layout Line 568 /** Name Layout Line
569 * This is the Layout line arranged in 569 * This is the Layout line arranged in
570 * horizontal way each components 570 * horizontal way each components
571 * are next to each other 571 * are next to each other
572 * but we will only do this if 572 * but we will only do this if
573 * we didn't initialize a while ago. 573 * we didn't initialize a while ago.
574 */ 574 */
575 if( m_boxName == 0 ){ 575 if( m_boxName == 0 ){
576 m_boxName = new QHBox( this ); // remove this this? or use a QHBox 576 m_boxName = new QHBox( this ); // remove this this? or use a QHBox
577 m_fnLabel = new QLabel( m_boxName ); 577 m_fnLabel = new QLabel( m_boxName );
578 m_fnLabel->setText( tr("Name:") ); 578 m_fnLabel->setText( tr("Name:") );
579 m_edit = new QLineEdit( m_boxName ); 579 m_edit = new QLineEdit( m_boxName );
580 m_edit->setText( m_name ); 580 m_edit->setText( m_name );
581 //m_boxName->addWidget( m_fnLabel ); 581 //m_boxName->addWidget( m_fnLabel );
582 m_boxName->setMargin( 5 ); 582 m_boxName->setMargin( 5 );
583 m_boxName->setSpacing( 8 ); 583 m_boxName->setSpacing( 8 );
584 //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor 584 //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor
585 585
586 m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout 586 m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout
587 }// else we already initialized 587 }// else we already initialized
588 // maybe show the components? 588 // maybe show the components?
589 // 589 //
590} 590}
591void OFileSelector::initializeYes() 591void OFileSelector::initializeYes()
592{ 592{
593 /** The Save Cancel bar 593 /** The Save Cancel bar
594 * 594 *
595 */ 595 */
596 if( m_boxOk == 0 ){ 596 if( m_boxOk == 0 ){
597 m_boxOk = new QHBox( this ); 597 m_boxOk = new QHBox( this );
598 m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); 598 m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" );
599 m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); 599 m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" );
600 600
601 //m_boxOk->addWidget( m_ok ); 601 //m_boxOk->addWidget( m_ok );
602 //m_boxOk->addWidget( m_cancel ); 602 //m_boxOk->addWidget( m_cancel );
603 m_boxOk->setMargin( 5 ); 603 m_boxOk->setMargin( 5 );
604 m_boxOk->setSpacing( 10 ); 604 m_boxOk->setSpacing( 10 );
605 m_lay->addWidget( m_boxOk, 0 ); 605 m_lay->addWidget( m_boxOk, 0 );
606 606
607 connect( m_ok, SIGNAL( clicked() ), 607 connect( m_ok, SIGNAL( clicked() ),
608 this, SLOT(slotOk() ) ); 608 this, SLOT(slotOk() ) );
609 connect( m_cancel, SIGNAL( clicked() ), 609 connect( m_cancel, SIGNAL( clicked() ),
610 this, SLOT( slotCancel() ) ); 610 this, SLOT( slotCancel() ) );
611 } 611 }
612} 612}
613/* 613/*
614 * OK m_mimeCheck is a QComboBox we now want to fill 614 * OK m_mimeCheck is a QComboBox we now want to fill
615 * out that combobox 615 * out that combobox
616 * if automime we need to update the mimetypes 616 * if automime we need to update the mimetypes
617 */ 617 */
618void OFileSelector::updateMimeCheck() { 618void OFileSelector::updateMimeCheck() {
619 m_mimeCheck->clear(); 619 m_mimeCheck->clear();
620 if (m_autoMime ) { 620 if (m_autoMime ) {
621 //m_mimeCheck->insertItem( tr("All") ); 621 //m_mimeCheck->insertItem( tr("All") );
622 updateMimes(); 622 updateMimes();
623 } 623 }
624 624
625 QMap<QString, QStringList>::Iterator it; 625 QMap<QString, QStringList>::Iterator it;
626 for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { 626 for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) {
627 m_mimeCheck->insertItem( it.key() ); 627 m_mimeCheck->insertItem( it.key() );
628 } 628 }
629} 629}
630 630
631void OFileSelector::initializeChooser() 631void OFileSelector::initializeChooser()
632{ 632{
633 if( m_boxView == 0 ){ 633 if( m_boxView == 0 ){
634 m_boxView = new QHBox( this ); 634 m_boxView = new QHBox( this );
635 m_viewCheck = new QComboBox( m_boxView, "view check"); 635 m_viewCheck = new QComboBox( m_boxView, "view check");
636 m_mimeCheck = new QComboBox( m_boxView, "mime check"); 636 m_mimeCheck = new QComboBox( m_boxView, "mime check");
637 m_boxView->setSpacing( 8 ); 637 m_boxView->setSpacing( 8 );
638 m_lay->addWidget(m_boxView, 0 ); 638 m_lay->addWidget(m_boxView, 0 );
639 639
640 640
641 updateMimeCheck(); 641 updateMimeCheck();
642 fillList(); 642 fillList();
643 643
644 connect( m_viewCheck, SIGNAL( activated(const QString & ) ), 644 connect( m_viewCheck, SIGNAL( activated(const QString & ) ),
645 this, SLOT( slotViewCheck(const QString & ) ) ); 645 this, SLOT( slotViewCheck(const QString & ) ) );
646 connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), 646 connect( m_mimeCheck, SIGNAL( activated(const QString & ) ),
647 this, SLOT( slotMimeCheck( const QString & ) ) ); 647 this, SLOT( slotMimeCheck( const QString & ) ) );
648 } 648 }
649} 649}
650/* generate the buttons for the toolbar */ 650/* generate the buttons for the toolbar */
651void OFileSelector::initToolbar() { 651void OFileSelector::initToolbar() {
652 m_mainView = new OFileSelectorMain( this ); 652 m_mainView = new OFileSelectorMain( this );
653 653
654 /* now generate the tool bar */ 654 /* now generate the tool bar */
655 qWarning( "toolbar" ); 655 qWarning( "toolbar" );
656 m_pseudo = new QWidget( m_mainView, "Pseudo Widget" ); 656 m_pseudo = new QWidget( m_mainView, "Pseudo Widget" );
657 m_pseudoLayout = new QVBoxLayout( m_pseudo ); 657 m_pseudoLayout = new QVBoxLayout( m_pseudo );
658 658
659 m_boxToolbar = new QHBox( m_pseudo ); 659 m_boxToolbar = new QHBox( m_pseudo );
660 m_boxToolbar->setSpacing( 0 ); 660 m_boxToolbar->setSpacing( 0 );
661 661
662 // tool bar members now 662 // tool bar members now
663 m_location = new QComboBox( m_boxToolbar ); 663 m_location = new QComboBox( m_boxToolbar );
664 m_location->setEditable( TRUE ); 664 m_location->setEditable( TRUE );
665 m_location->setDuplicatesEnabled( FALSE ); 665 m_location->setDuplicatesEnabled( FALSE );
666 connect( m_location, SIGNAL(activated(const QString& ) ), 666 connect( m_location, SIGNAL(activated(const QString& ) ),
667 this, SLOT(slotLocationActivated(const QString& )) ); 667 this, SLOT(slotLocationActivated(const QString& )) );
668 connect( m_location->lineEdit(), SIGNAL(returnPressed() ) , 668 connect( m_location->lineEdit(), SIGNAL(returnPressed() ) ,
669 this, SLOT(locationComboChanged() ) ); 669 this, SLOT(locationComboChanged() ) );
670 670
671 // UP Button 671 // UP Button
672 m_up = new QPushButton( Resource::loadIconSet("up"), QString::null, 672 m_up = new QPushButton( Resource::loadIconSet("up"), QString::null,
673 m_boxToolbar, "cdUpButton" ); 673 m_boxToolbar, "cdUpButton" );
674 m_up->setFixedSize( QSize(20, 20 ) ); 674 m_up->setFixedSize( QSize(20, 20 ) );
675 connect( m_up, SIGNAL( clicked() ), this, SLOT(cdUP() ) ); 675 connect( m_up, SIGNAL( clicked() ), this, SLOT(cdUP() ) );
676 m_up->setFlat( TRUE ); 676 m_up->setFlat( TRUE );
677 677
678 // Home Button 678 // Home Button
679 m_homeButton = new QPushButton(Resource::loadIconSet("home"), 679 m_homeButton = new QPushButton(Resource::loadIconSet("home"),
680 QString::null, m_boxToolbar ); 680 QString::null, m_boxToolbar );
681 m_homeButton->setFixedSize( QSize(20, 20 ) ); 681 m_homeButton->setFixedSize( QSize(20, 20 ) );
682 connect(m_homeButton, SIGNAL(clicked() ), this, SLOT(slotHome() ) ); 682 connect(m_homeButton, SIGNAL(clicked() ), this, SLOT(slotHome() ) );
683 m_homeButton->setFlat( TRUE ); 683 m_homeButton->setFlat( TRUE );
684 684
685 // Documents Button 685 // Documents Button
686 m_docButton = new QPushButton( Resource::loadIconSet("DocsIcon"), 686 m_docButton = new QPushButton( Resource::loadIconSet("DocsIcon"),
687 QString::null, m_boxToolbar, 687 QString::null, m_boxToolbar,
688 "docsButton" ); 688 "docsButton" );
689 m_docButton->setFixedSize( QSize(20, 20 ) ); 689 m_docButton->setFixedSize( QSize(20, 20 ) );
690 m_docButton->setFlat( true ); 690 m_docButton->setFlat( true );
691 connect( m_docButton, SIGNAL(clicked() ), 691 connect( m_docButton, SIGNAL(clicked() ),
692 this, SLOT(slotDoc() ) ); 692 this, SLOT(slotDoc() ) );
693 693
694 // close button 694 // close button
695 m_close = new QPushButton( Resource::loadIconSet( "close"), "", 695 m_close = new QPushButton( Resource::loadIconSet( "close"), "",
696 m_boxToolbar ); 696 m_boxToolbar );
697 connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); 697 connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) );
698 m_close->setFixedSize( 20, 20 ); 698 m_close->setFixedSize( 20, 20 );
699 699
700 m_boxToolbar->setFixedHeight( 20 ); 700 m_boxToolbar->setFixedHeight( 20 );
701 m_pseudoLayout->addWidget(m_boxToolbar ); 701 m_pseudoLayout->addWidget(m_boxToolbar );
702 702
703 /* init the locations */ 703 /* init the locations */
704 initLocations(); 704 initLocations();
705 705
706 if( !m_shTool ){ 706 if( !m_shTool ){
707 m_location->hide( ); 707 m_location->hide( );
708 m_up->hide( ); 708 m_up->hide( );
709 m_homeButton->hide( ); 709 m_homeButton->hide( );
710 m_docButton->hide( ); 710 m_docButton->hide( );
711 } 711 }
712 if(!m_shClose ) 712 if(!m_shClose )
713 m_close->hide(); 713 m_close->hide();
714 714
715 m_mainView->setToolbar( m_pseudo ); 715 m_mainView->setToolbar( m_pseudo );
716 m_lay->addWidget( m_mainView, 100 ); 716 m_lay->addWidget( m_mainView, 100 );
717} 717}
718/* put default locations into the bar */ 718/* put default locations into the bar */
719void OFileSelector::initLocations () { 719void OFileSelector::initLocations () {
720 720
721 // let;s fill the Location ComboBox 721 // let;s fill the Location ComboBox
722 StorageInfo storage; 722 StorageInfo storage;
723 const QList<FileSystem> &fs = storage.fileSystems(); 723 const QList<FileSystem> &fs = storage.fileSystems();
724 QListIterator<FileSystem> it ( fs ); 724 QListIterator<FileSystem> it ( fs );
725 for( ; it.current(); ++it ){ 725 for( ; it.current(); ++it ){
726 const QString disk = (*it)->name(); 726 const QString disk = (*it)->name();
727 const QString path = (*it)->path(); 727 const QString path = (*it)->path();
728 m_location->insertItem(path+ "<-"+disk ); 728 m_location->insertItem(path+ "<-"+disk );
729 } 729 }
730 int count = m_location->count(); 730 int count = m_location->count();
731 m_location->insertItem( m_currentDir ); 731 m_location->insertItem( m_currentDir );
732 m_location->setCurrentItem( count ); 732 m_location->setCurrentItem( count );
733 733
734} 734}
735void OFileSelector::initializePerm() 735void OFileSelector::initializePerm()
736{ 736{
737 if( m_checkPerm == 0 ){ 737 if( m_checkPerm == 0 ){
738 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm"); 738 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm");
739 m_checkPerm->setChecked( false ); 739 m_checkPerm->setChecked( false );
740 m_lay->addWidget( m_checkPerm ); 740 m_lay->addWidget( m_checkPerm );
741 } 741 }
742} 742}
743void OFileSelector::initPics() 743void OFileSelector::initPics()
744{ 744{
745 m_pixmaps = new QMap<QString,QPixmap>; 745 m_pixmaps = new QMap<QString,QPixmap>;
746 QPixmap pm = Resource::loadPixmap( "folder" ); 746 QPixmap pm = Resource::loadPixmap( "folder" );
747 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 747 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
748 748
749 QPainter painter( &pm ); 749 QPainter painter( &pm );
750 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 750 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
751 pm.setMask( pm.createHeuristicMask( FALSE ) ); 751 pm.setMask( pm.createHeuristicMask( FALSE ) );
752 m_pixmaps->insert("dirsymlink", pm ); 752 m_pixmaps->insert("dirsymlink", pm );
753 753
754 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); 754 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" );
755 QPainter pen(&pm2 ); 755 QPainter pen(&pm2 );
756 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); 756 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk );
757 pm2.setMask( pm2.createHeuristicMask( FALSE ) ); 757 pm2.setMask( pm2.createHeuristicMask( FALSE ) );
758 m_pixmaps->insert("symlinkedlocked", pm2 ); 758 m_pixmaps->insert("symlinkedlocked", pm2 );
759} 759}
760// if a mime complies with the m_mimeCheck->currentItem 760// if a mime complies with the m_mimeCheck->currentItem
761bool OFileSelector::compliesMime( const QString &path, const QString &mime ) 761bool OFileSelector::compliesMime( const QString &path, const QString &mime )
762{ 762{
763 if( mime == "All" ) 763 if( mime == "All" )
764 return true; 764 return true;
765 MimeType type( path ); 765 MimeType type( path );
766 if( type.id() == mime ) 766 if( type.id() == mime )
767 return true; 767 return true;
768 return false; 768 return false;
769} 769}
770/* check if the mimetype in mime 770/* check if the mimetype in mime
771 * complies with the one which is current 771 * complies with the one which is current
772 */ 772 */
773/* 773/*
774 * We've the mimetype of the file 774 * We've the mimetype of the file
775 * We need to get the stringlist of the current mimetype 775 * We need to get the stringlist of the current mimetype
776 * 776 *
777 * mime = image/jpeg 777 * mime = image/jpeg
778 * QStringList = 'image/*' 778 * QStringList = 'image/*'
779 * or QStringList = image/jpeg;image/png;application/x-ogg 779 * or QStringList = image/jpeg;image/png;application/x-ogg
780 * or QStringList = application/x-ogg;image/*; 780 * or QStringList = application/x-ogg;image/*;
781 * with all these mime filters it should get acceptes 781 * with all these mime filters it should get acceptes
782 * to do so we need to look if mime is contained inside 782 * to do so we need to look if mime is contained inside
783 * the stringlist 783 * the stringlist
784 * if it's contained return true 784 * if it's contained return true
785 * if not ( I'm no RegExp expert at all ) we'll look if a '/*' 785 * if not ( I'm no RegExp expert at all ) we'll look if a '/*'
786 * is contained in the mimefilter and then we will 786 * is contained in the mimefilter and then we will
787 * look if both are equal until the '/' 787 * look if both are equal until the '/'
788 */ 788 */
789bool OFileSelector::compliesMime( const QString& mime ) { 789bool OFileSelector::compliesMime( const QString& mime ) {
790 qWarning("mimetype is %s", mime.latin1() ); 790 qWarning("mimetype is %s", mime.latin1() );
791 QString currentText; 791 QString currentText;
792 if (m_shChooser ) 792 if (m_shChooser )
793 currentText = m_mimeCheck->currentText(); 793 currentText = m_mimeCheck->currentText();
794 794
795 qWarning("current text is %s", currentText.latin1() ); 795 qWarning("current text is %s", currentText.latin1() );
796 QMap<QString, QStringList>::Iterator it; 796 QMap<QString, QStringList>::Iterator it;
797 QStringList list; 797 QStringList list;
798 if ( currentText == tr("All") ) return true; 798 if ( currentText == tr("All") ) return true;
799 else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { 799 else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) {
800 it = m_mimetypes.begin(); 800 it = m_mimetypes.begin();
801 list = it.data(); 801 list = it.data();
802 }else if ( currentText.isEmpty() ) return true; 802 }else if ( currentText.isEmpty() ) return true;
803 else{ 803 else{
804 it = m_mimetypes.find(currentText ); 804 it = m_mimetypes.find(currentText );
805 if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; 805 if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText;
806 else qWarning("found"), list = it.data(); 806 else qWarning("found"), list = it.data();
807 } 807 }
808 808
809 809
810 if ( list.contains(mime) ) return true; 810 if ( list.contains(mime) ) return true;
811 qWarning("list doesn't contain it "); 811 qWarning("list doesn't contain it ");
812 QStringList::Iterator it2; 812 QStringList::Iterator it2;
813 int pos; 813 int pos;
814 for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { 814 for ( it2 = list.begin(); it2 != list.end(); ++it2 ) {
815 pos = (*it2).findRev("/*"); 815 pos = (*it2).findRev("/*");
816 if ( pos >= 0 ) { 816 if ( pos >= 0 ) {
817 if ( mime.contains( (*it2).left(pos) ) ) return true; 817 if ( mime.contains( (*it2).left(pos) ) ) return true;
818 } 818 }
819 } 819 }
820 return false; 820 return false;
821} 821}
822void OFileSelector::slotFileSelected( const QString &string ) 822void OFileSelector::slotFileSelected( const QString &string )
823{ 823{
824 if( m_shLne ) 824 if( m_shLne )
825 m_edit->setText( string ); 825 m_edit->setText( string );
826 emit fileSelected( string ); 826 emit fileSelected( string );
827} 827}
828void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) 828void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
829{ 829{
830 slotFileSelected( lnk.name() ); 830 slotFileSelected( lnk.name() );
831 // emit fileSelected( lnk ); 831 // emit fileSelected( lnk );
832} 832}
833 833
834 834
835void OFileSelector::slotDelete() 835void OFileSelector::slotDelete()
836{ 836{
837 /* 837 /*
838 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 838 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
839 QStringList list = QStringList::split("->", sel->text(1) ); 839 QStringList list = QStringList::split("->", sel->text(1) );
840 if( sel->isDir() ){ 840 if( sel->isDir() ){
841 QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry 841 QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry
842 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], 842 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0],
843 tr("Yes"),tr("No"),0,1,1) ) { 843 tr("Yes"),tr("No"),0,1,1) ) {
844 case 0: 844 case 0:
845 ::system(str.utf8().data() ); 845 ::system(str.utf8().data() );
846 break; 846 break;
847 } 847 }
848 } else { 848 } else {
849 QFile::remove( list[0] ); 849 QFile::remove( list[0] );
850 } 850 }
851 m_View->takeItem( sel ); 851 m_View->takeItem( sel );
852 delete sel; 852 delete sel;
853 */ 853 */
854} 854}
855void OFileSelector::cdUP() 855void OFileSelector::cdUP()
856{ 856{
857 QDir dir( m_currentDir ); 857 QDir dir( m_currentDir );
858 dir.cdUp(); 858 dir.cdUp();
859 if(dir.exists() ){ 859 if(dir.exists() ){
860 m_currentDir = dir.absPath(); 860 m_currentDir = dir.absPath();
861 reparse(); 861 reparse();
862 int count = m_location->count(); 862 int count = m_location->count();
863 slotInsertLocationPath( m_currentDir, count); 863 slotInsertLocationPath( m_currentDir, count);
864 m_location->setCurrentItem( indexByString( m_location, m_currentDir)); 864 m_location->setCurrentItem( indexByString( m_location, m_currentDir));
865 //this wont work in all instances 865 //this wont work in all instances
866 // FIXME 866 // FIXME
867 } 867 }
868} 868}
869void OFileSelector::slotHome() 869void OFileSelector::slotHome()
870{ 870{
871 cd(QDir::homeDirPath() ); 871 cd(QDir::homeDirPath() );
872} 872}
873void OFileSelector::slotDoc() 873void OFileSelector::slotDoc()
874{ 874{
875 cd(QPEApplication::documentDir() ); 875 cd(QPEApplication::documentDir() );
876} 876}
877void OFileSelector::slotNavigate( ) 877void OFileSelector::slotNavigate( )
878{ 878{
879 879
880} 880}
881// fill the View with life 881// fill the View with life
882void OFileSelector::reparse() 882void OFileSelector::reparse()
883{ 883{
884 if( m_selector == Normal ) 884 if( m_selector == Normal )
885 return; 885 return;
886 886
887 currentView()->clear(); 887 currentView()->clear();
888 888
889 if( m_shChooser) 889 if( m_shChooser)
890 qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); 890 qWarning("reparse %s", m_mimeCheck->currentText().latin1() );
891 891
892 QString currentMimeType; 892 QString currentMimeType;
893 893
894 // let's update the mimetype 894 // let's update the mimetype
895 if( m_autoMime ){ 895 if( m_autoMime ){
896 m_mimetypes.clear(); 896 m_mimetypes.clear();
897 // ok we can change mimetype so we need to be able to give a selection 897 // ok we can change mimetype so we need to be able to give a selection
898 if( m_shChooser ) { 898 if( m_shChooser ) {
899 currentMimeType = m_mimeCheck->currentText(); 899 currentMimeType = m_mimeCheck->currentText();
900 m_mimeCheck->clear(); 900 m_mimeCheck->clear();
901 901
902 // let's find possible mimetypes 902 // let's find possible mimetypes
903 m_mimetypes = currentLister()->mimeTypes( m_currentDir ); 903 m_mimetypes = currentLister()->mimeTypes( m_currentDir );
904 904
905 // add them to the chooser 905 // add them to the chooser
906 updateMimeCheck(); 906 updateMimeCheck();
907 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); 907 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) );
908 currentMimeType = m_mimeCheck->currentText(); 908 currentMimeType = m_mimeCheck->currentText();
909 } 909 }
910 }else { // no autoMime 910 }else { // no autoMime
911 // let the mimetype be set from out side the m_mimeCheck FEATURE 911 // let the mimetype be set from out side the m_mimeCheck FEATURE
912 912
913 if( m_shChooser ) 913 if( m_shChooser )
914 currentMimeType = m_mimeCheck->currentText(); 914 currentMimeType = m_mimeCheck->currentText();
915 915
916 } 916 }
917 // now we got our mimetypes we can add the files 917 // now we got our mimetypes we can add the files
918 918
919 currentLister()->reparse( m_currentDir ); 919 currentLister()->reparse( m_currentDir );
920 /* we're done with adding let's sort */ 920 /* we're done with adding let's sort */
921 currentView()->sort(); 921 currentView()->sort();
922 922
923 923
924 if( m_shTool ){ 924 if( m_shTool ){
925 m_location->insertItem( m_currentDir ); 925 m_location->insertItem( m_currentDir );
926 926
927 } 927 }
928 // reenable painting and updates 928 // reenable painting and updates
929} 929}
930/* switch lister to @param lister */ 930/* switch lister to @param lister */
931void OFileSelector::setLister(const QString& lister) { 931void OFileSelector::setLister(const QString& lister) {
932 QStringList listerList = factory()->lister(); 932 QStringList listerList = factory()->lister();
933 933
934 if (listerList.contains(lister) ) { 934 if (listerList.contains(lister) ) {
935 delete (OLister*) m_lister; 935 delete (OLister*) m_lister;
936 m_lister = factory()->lister( lister, this ); 936 m_lister = factory()->lister( lister, this );
937 }else if (!m_lister ) { 937 }else if (!m_lister ) {
938 /* 938 /*
939 * if we do not have a lister 939 * if we do not have a lister
940 * we need to take the default one 940 * we need to take the default one
941 */ 941 */
942 m_lister = new OLocalLister(this); 942 m_lister = new OLocalLister(this);
943 } 943 }
944 m_listerName = lister; 944 m_listerName = lister;
945} 945}
946void OFileSelector::setView( const QString& lis ) { 946void OFileSelector::setView( const QString& lis ) {
947 qWarning("setView "); 947 qWarning("setView ");
948 fillList(); 948 fillList();
949 if ( lis == tr("Documents") ) { 949 if ( lis == tr("Documents") ) {
950 m_selector = Normal; 950 m_selector = Normal;
951 delete m_lister; 951 delete m_lister;
952 delete m_fileView; 952 delete m_fileView;
953 m_lister = 0l; 953 m_lister = 0l;
954 m_fileView = 0l; 954 m_fileView = 0l;
955 initializeOldSelector(); 955 initializeOldSelector();
956 }else { 956 }else {
957 qWarning("lis %s", lis.latin1() ); 957 qWarning("lis %s", lis.latin1() );
958 QString list; 958 QString list;
959 959
960 delete m_lister; 960 delete m_lister;
961 delete m_fileView; 961 delete m_fileView;
962 delete m_select; 962 delete m_select;
963 m_lister =0l; 963 m_lister =0l;
964 m_fileView = 0l; 964 m_fileView = 0l;
965 m_select = 0l; 965 m_select = 0l;
966 if ( lis.startsWith("All") ) { 966 if ( lis.startsWith("All") ) {
967 m_selector = ExtendedAll; 967 m_selector = ExtendedAll;
968 list = lis.mid(4 ).stripWhiteSpace(); 968 list = lis.mid(4 ).stripWhiteSpace();
969 } else{ 969 } else{
970 list = lis; 970 list = lis;
971 m_selector = Extended; 971 m_selector = Extended;
972 } 972 }
973 setLister(m_listerName); 973 setLister(m_listerName);
974 m_fileView = factory()->view( list, this, m_mainView ); 974 m_fileView = factory()->view( list, this, m_mainView );
975 m_mainView->setWidget( m_fileView->widget() ); 975 m_mainView->setWidget( m_fileView->widget() );
976 reparse(); 976 reparse();
977 } 977 }
978} 978}
979/* 979/*
980 * the factory 980 * the factory
981 */ 981 */
982void OFileSelector::initFactory() { 982void OFileSelector::initFactory() {
983 m_fileFactory = new OFileFactory(); 983 m_fileFactory = new OFileFactory();
984 m_fileFactory->addLister(tr("Files"), newLocalLister ); 984 m_fileFactory->addLister(tr("Files"), newLocalLister );
985 m_fileFactory->addView(tr("List View"), newFileListView ); 985 m_fileFactory->addView(tr("List View"), newFileListView );
986 /* the factory is just a dummy */ 986 /* the factory is just a dummy */
987 m_fileFactory->addView(tr("Documents"), newFileListView ); 987 m_fileFactory->addView(tr("Documents"), newFileListView );
988} 988}
989void OFileSelector::fillList() { 989void OFileSelector::fillList() {
990 qWarning("fill list"); 990 qWarning("fill list");
991 if (!m_viewCheck ) 991 if (!m_viewCheck )
992 return; 992 return;
993 993
994 m_viewCheck->clear(); 994 m_viewCheck->clear();
995 QStringList list = factory()->views(); 995 QStringList list = factory()->views();
996 qWarning("views: " + list.join(";") ); 996 qWarning("views: " + list.join(";") );
997 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 997 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
998 qWarning( (*it) ); 998 qWarning( (*it) );
999 if ( (*it) == tr("Documents") ) { 999 if ( (*it) == tr("Documents") ) {
1000 m_viewCheck->insertItem( (*it) ); 1000 m_viewCheck->insertItem( (*it) );
1001 }else{ 1001 }else{
1002 m_viewCheck->insertItem( (*it) ); 1002 m_viewCheck->insertItem( (*it) );
1003 m_viewCheck->insertItem( tr("All ") + (*it) ); 1003 m_viewCheck->insertItem( tr("All ") + (*it) );
1004 } 1004 }
1005 } 1005 }
1006} 1006}
1007OFileFactory* OFileSelector::factory() { 1007OFileFactory* OFileSelector::factory() {
1008 return m_fileFactory; 1008 return m_fileFactory;
1009} 1009}
1010 1010
1011 1011
1012OFileView* OFileSelector::currentView() { 1012OFileView* OFileSelector::currentView() {
1013 return m_fileView; 1013 return m_fileView;
1014} 1014}
1015OFileView* OFileSelector::currentView() const{ 1015OFileView* OFileSelector::currentView() const{
1016 return m_fileView; 1016 return m_fileView;
1017} 1017}
1018int OFileSelector::filter() { 1018int OFileSelector::filter() {
1019 int filter; 1019 int filter;
1020 if ( m_selector == ExtendedAll ) 1020 if ( m_selector == ExtendedAll )
1021 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; 1021 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
1022 else 1022 else
1023 filter = QDir::Files | QDir::Dirs | QDir::All ; 1023 filter = QDir::Files | QDir::Dirs | QDir::All ;
1024 1024
1025 return filter; 1025 return filter;
1026} 1026}
1027int OFileSelector::sorting() { 1027int OFileSelector::sorting() {
1028 int sort; 1028 int sort;
1029 1029
1030 if (m_case ) 1030 if (m_case )
1031 sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed ); 1031 sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed );
1032 else 1032 else
1033 sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed ); 1033 sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed );
1034 1034
1035 return sort; 1035 return sort;
1036} 1036}
1037void OFileSelector::internFileSelected( const QString& s) { 1037void OFileSelector::internFileSelected( const QString& s) {
1038 emit fileSelected( s ); 1038 emit fileSelected( s );
1039 DocLnk lnk( s );
1040 internFileSelected( lnk );
1039} 1041}
1040void OFileSelector::internFileSelected( const DocLnk& d ) { 1042void OFileSelector::internFileSelected( const DocLnk& d ) {
1041 emit fileSelected( d ); 1043 emit fileSelected( d );
1042} 1044}
1043void OFileSelector::internContextMenu() { 1045void OFileSelector::internContextMenu() {
1044 emit contextMenu(); 1046 emit contextMenu();
1045} 1047}
1046void OFileSelector::internChangedDir( const QString& s) { 1048void OFileSelector::internChangedDir( const QString& s) {
1047 emit dirSelected( s ); 1049 emit dirSelected( s );
1048 cd(s ); 1050 cd(s );
1049} 1051}
1050void OFileSelector::internChangedDir( const QDir& s) { 1052void OFileSelector::internChangedDir( const QDir& s) {
1051 emit dirSelected( s ); 1053 emit dirSelected( s );
1052} 1054}
1053QPixmap OFileSelector::pixmap( const QString& s ) { 1055QPixmap OFileSelector::pixmap( const QString& s ) {
1054 1056
1055 return (*m_pixmaps)[s]; 1057 return (*m_pixmaps)[s];
1056} 1058}
1057OLister* OFileSelector::currentLister()const { 1059OLister* OFileSelector::currentLister()const {
1058 return m_lister; 1060 return m_lister;
1059} 1061}
1060void OFileSelector::initializeOldSelector() { 1062void OFileSelector::initializeOldSelector() {
1061 qWarning("initializeOldSelector"); 1063 qWarning("initializeOldSelector");
1062 1064
1063 delete m_select; 1065 delete m_select;
1064 1066
1065 // we need to initialize but keep the selected mimetype 1067 // we need to initialize but keep the selected mimetype
1066 /* we default not to show close and new buttons */ 1068 /* we default not to show close and new buttons */
1067 QString mime = currentMimeType(); 1069 QString mime = currentMimeType();
1068 qWarning("MimeType " + mime ); 1070 qWarning("MimeType " + mime );
1069 m_select = new FileSelector( mime , 1071 m_select = new FileSelector( mime ,
1070 m_mainView, "fileselector", 1072 m_mainView, "fileselector",
1071 FALSE, FALSE); 1073 FALSE, FALSE);
1072 m_select->setCategorySelectVisible( FALSE ); 1074 m_select->setCategorySelectVisible( FALSE );
1073 m_select->setTypeComboVisible( FALSE ); 1075 m_select->setTypeComboVisible( FALSE );
1074 1076
1075 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), 1077 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
1076 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); 1078 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
1077 connect(m_select, SIGNAL(closeMe() ), 1079 connect(m_select, SIGNAL(closeMe() ),
1078 this, SIGNAL(closeMe() ) ); 1080 this, SIGNAL(closeMe() ) );
1079 //connect to close me and other signals as well 1081 //connect to close me and other signals as well
1080 m_mainView->setWidget( m_select ); 1082 m_mainView->setWidget( m_select );
1081} 1083}
1082/* 1084/*
1083 * initialize the listview 1085 * initialize the listview
1084 * we will call fillList 1086 * we will call fillList
1085 * setLister 1087 * setLister
1086 * with QString::null to get the default 1088 * with QString::null to get the default
1087 * setView with either Files or All Files 1089 * setView with either Files or All Files
1088 * depending on Extended 1090 * depending on Extended
1089 */ 1091 */
1090void OFileSelector::initializeView() { 1092void OFileSelector::initializeView() {
1091 setLister(QString::null); 1093 setLister(QString::null);
1092 fillList(); 1094 fillList();
1093 if (m_selector == Extended ) { 1095 if (m_selector == Extended ) {
1094 setView( tr("List View") ); 1096 setView( tr("List View") );
1095 }else{ 1097 }else{
1096 setView( tr("All List View") ); 1098 setView( tr("All List View") );
1097 } 1099 }
1098} 1100}
1099 1101
diff --git a/libopie/ofileselector/ofileselectoritem.cpp b/libopie/ofileselector/ofileselectoritem.cpp
index d31046b..4ef8fe3 100644
--- a/libopie/ofileselector/ofileselectoritem.cpp
+++ b/libopie/ofileselector/ofileselectoritem.cpp
@@ -1,58 +1,58 @@
1#include "ofileselectoritem.h" 1#include "ofileselectoritem.h"
2 2
3OFileSelectorItem::OFileSelectorItem( QListView*view, 3OFileSelectorItem::OFileSelectorItem( QListView*view,
4 const QPixmap& pix, 4 const QPixmap& pix,
5 const QString& path, 5 const QString& path,
6 const QString& date, 6 const QString& date,
7 const QString& size, 7 const QString& size,
8 const QString& dir, 8 const QString& dir,
9 const QString& extra,
10 bool isLocked, 9 bool isLocked,
10 const QString& extra,
11 bool isDir ) 11 bool isDir )
12 : QListViewItem( view ) 12 : QListViewItem( view )
13{ 13{
14 setPixmap( 0, pix ); 14 setPixmap( 0, pix );
15 setText( 1, path ); 15 setText( 1, path );
16 setText( 2, size ); 16 setText( 2, size );
17 setText( 3, date ); 17 setText( 3, date );
18 m_dir = isDir; 18 m_dir = isDir;
19 m_locked = isLocked; 19 m_locked = isLocked;
20 m_dirStr = dir; 20 m_dirStr = dir;
21 m_extra = extra; 21 m_extra = extra;
22} 22}
23OFileSelectorItem::~OFileSelectorItem() { 23OFileSelectorItem::~OFileSelectorItem() {
24} 24}
25bool OFileSelectorItem::isLocked()const { 25bool OFileSelectorItem::isLocked()const {
26 return m_locked; 26 return m_locked;
27} 27}
28QString OFileSelectorItem::directory()const { 28QString OFileSelectorItem::directory()const {
29 return m_dirStr; 29 return m_dirStr;
30} 30}
31bool OFileSelectorItem::isDir()const { 31bool OFileSelectorItem::isDir()const {
32 return m_dir; 32 return m_dir;
33} 33}
34QString OFileSelectorItem::path() const { 34QString OFileSelectorItem::path() const {
35 return text(1); 35 return text(1);
36} 36}
37QString OFileSelectorItem::key( int id, bool ) { 37QString OFileSelectorItem::key( int id, bool ) {
38 QString ke; 38 QString ke;
39 39
40 if( id == 0 || id == 1 ){ // name 40 if( id == 0 || id == 1 ){ // name
41 if( m_dir ){ 41 if( m_dir ){
42 ke.append("0" ); 42 ke.append("0" );
43 ke.append( text(1) ); 43 ke.append( text(1) );
44 }else{ 44 }else{
45 ke.append("1" ); 45 ke.append("1" );
46 ke.append( text(1) ); 46 ke.append( text(1) );
47 } 47 }
48 }else if( id == 2 ){ // size 48 }else if( id == 2 ){ // size
49 return text(2); 49 return text(2);
50 }else if( id == 3 ){ // date 50 }else if( id == 3 ){ // date
51 return text(3); 51 return text(3);
52 } 52 }
53 53
54 return ke; 54 return ke;
55} 55}
56QString OFileSelector::extra()const { 56QString OFileSelectorItem::extra()const {
57 return m_extra; 57 return m_extra;
58} 58}
diff --git a/libopie/ofileselector/ofileview.cpp b/libopie/ofileselector/ofileview.cpp
index 72d2f60..4203ca3 100644
--- a/libopie/ofileselector/ofileview.cpp
+++ b/libopie/ofileselector/ofileview.cpp
@@ -1,30 +1,32 @@
1#include <qlineedit.h> 1#include <qlineedit.h>
2 2
3#include <qpe/applnk.h> 3#include <qpe/applnk.h>
4 4
5#include "ofileselector.h" 5#include "ofileselector.h"
6#include "olister.h"
6#include "ofileview.h" 7#include "ofileview.h"
7 8
8 9
10
9OFileView::OFileView( OFileSelector* sel) 11OFileView::OFileView( OFileSelector* sel)
10 : m_sel( sel ) 12 : m_sel( sel )
11{ 13{
12} 14}
13OFileView::~OFileView() { 15OFileView::~OFileView() {
14} 16}
15void OFileView::fileSelected( const QString& dir,const QString& file,const QString& extra ) { 17void OFileView::fileSelected( const QString& dir,const QString& file,const QString& extra ) {
16 m_sel->currentLister()->fileSelected( dir,file,extra ); 18 m_sel->currentLister()->fileSelected( dir,file,extra );
17} 19}
18void OFileView::contextMenu() { 20void OFileView::contextMenu() {
19 m_sel->internContextMenu(); 21 m_sel->internContextMenu();
20} 22}
21void OFileView::changedDir( const QString& s, const QString& file, const QString& extra) { 23void OFileView::changedDir( const QString& s, const QString& file, const QString& extra) {
22 m_sel->currentLister()->changedDir( s, file,extra ); 24 m_sel->currentLister()->changedDir( s, file,extra );
23} 25}
24OFileSelector* OFileView::selector() const { 26OFileSelector* OFileView::selector() const {
25 return m_sel; 27 return m_sel;
26} 28}
27void OFileView::updateLine( const QString& str ) { 29void OFileView::updateLine( const QString& str ) {
28 if (m_sel->m_shLne ) 30 if (m_sel->m_shLne )
29 m_sel->m_edit->setText( str ); 31 m_sel->m_edit->setText( str );
30} 32}
diff --git a/libopie/ofileselector/ofileview.h b/libopie/ofileselector/ofileview.h
index 808587f..e84a3e1 100644
--- a/libopie/ofileselector/ofileview.h
+++ b/libopie/ofileselector/ofileview.h
@@ -1,140 +1,140 @@
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 zecke <zecke@handhelds.org> 3             .=l. Copyright (c) 2002 zecke <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#ifndef ofileview_h 29#ifndef ofileview_h
30#define ofileview_h 30#define ofileview_h
31 31
32#include <qobject.h> 32#include <qobject.h>
33#include <qwidget.h> 33#include <qwidget.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35 35
36class QFileInfo; 36class QFileInfo;
37class QDir; 37class QDir;
38class DocLnk; 38class DocLnk;
39 39
40/** 40/**
41 * A OFileView is a specialised View for the 41 * A OFileView is a specialised View for the
42 * OFileSelector 42 * OFileSelector
43 * With a View you can chage the user visible 43 * With a View you can chage the user visible
44 * representation of a OFileLister 44 * representation of a OFileLister
45 * OFileView is just a basic interface which helps you to 45 * OFileView is just a basic interface which helps you to
46 * write new views 46 * write new views
47 */ 47 */
48class OFileSelector; 48class OFileSelector;
49class OFileView { 49class OFileView {
50public: 50public:
51 OFileView( OFileSelector* ); 51 OFileView( OFileSelector* );
52 OFileView(); 52 OFileView();
53 virtual ~OFileView(); 53 virtual ~OFileView();
54 54
55 virtual void clear() = 0; 55 virtual void clear() = 0;
56 virtual void addFile(const QPixmap&, 56 virtual void addFile(const QPixmap&,
57 const QString &mine, 57 const QString &mine,
58 QFileInfo *info, 58 QFileInfo *info,
59 const QString& extra = QString::null, 59 const QString& extra = QString::null,
60 bool isSymlink = FALSE ) = 0; 60 bool isSymlink = FALSE ) = 0;
61 61
62 virtual void addFile(const QPixmap&, 62 virtual void addFile(const QPixmap&,
63 const QString& mine, const QString& dir, 63 const QString& mine, const QString& dir,
64 const QString& file, 64 const QString& file,
65 const QString& extra = QString::null, 65 const QString& extra = QString::null,
66 bool = FALSE ) = 0; 66 bool = FALSE ) = 0;
67 67
68 virtual void addDir (const QPixmap&, 68 virtual void addDir (const QPixmap&,
69 const QString &mine, 69 const QString &mine,
70 QFileInfo *info, 70 QFileInfo *info,
71 const QString& extra = QString::null, 71 const QString& extra = QString::null,
72 bool isSymlink = FALSE ) = 0; 72 bool isSymlink = FALSE ) = 0;
73 virtual void addDir (const QPixmap&, 73 virtual void addDir (const QPixmap&,
74 const QString& mine, const QString& dir, 74 const QString& mine, const QString& dir,
75 const QString& file, 75 const QString& file,
76 const QString& extra = QString::null, 76 const QString& extra = QString::null,
77 bool = FALSE) = 0; 77 bool = FALSE) = 0;
78 78
79 virtual void addSymlink(const QPixmap&, 79 virtual void addSymlink(const QPixmap&,
80 const QString &mime, 80 const QString &mime,
81 QFileInfo *info, 81 QFileInfo *info,
82 const QString& extra = QString::null, 82 const QString& extra = QString::null,
83 bool isSymlink = FALSE ) = 0; 83 bool isSymlink = FALSE ) = 0;
84 84
85 virtual void addSymlink(const QPixmap&, 85 virtual void addSymlink(const QPixmap&,
86 const QString& mine, 86 const QString& mine,
87 const QString& path, 87 const QString& path,
88 const QString& file, 88 const QString& file,
89 const QString& extra = QString::null, 89 const QString& extra = QString::null,
90 bool isSymlink = FALSE ) = 0; 90 bool isSymlink = FALSE ) = 0;
91 91
92 virtual void cd(const QString &path ) = 0; 92 virtual void cd(const QString &path ) = 0;
93 virtual QWidget* widget() = 0; 93 virtual QWidget* widget() = 0;
94 94
95 virtual QString selectedName()const = 0; 95 virtual QString selectedName()const = 0;
96 virtual QStringList selectedNames()const = 0; 96 virtual QStringList selectedNames()const = 0;
97 virtual QString selectedPath()const = 0; 97 virtual QString selectedPath()const = 0;
98 virtual QStringList selectedPaths()const = 0; 98 virtual QStringList selectedPaths()const = 0;
99 virtual QString selectedExtra()const = 0;
99 virtual int fileCount() = 0; 100 virtual int fileCount() = 0;
100 virtual void sort() =0; 101 virtual void sort() =0;
101 102
102/*signals:*/ 103/*signals:*/
103protected: 104protected:
104 105
105 /** 106 /**
106 * @param dir The dir name 107 * @param dir The dir name
107 * @param file The file name 108 * @param file The file name
108 * @param extra The extra information 109 * @param extra The extra information
109 */ 110 */
110 void fileSelected(const QString &dir, const QString& file, const QString& extra = QString::nulll); 111 void fileSelected(const QString &dir, const QString& file, const QString& extra = QString::null);
111 void contextMenu(); 112 void contextMenu();
112 113
113 /** 114 /**
114 * 115 *
115 * @param dir The dir name 116 * @param dir The dir name
116 * @param file The file name 117 * @param file The file name
117 * @param extra The extra informations 118 * @param extra The extra informations
118 */ 119 */
119 void changedDir(const QString &dir, const QString& file, const QString& extra = QString::null); 120 void changedDir(const QString &dir, const QString& file, const QString& extra = QString::null);
120 void changedDir(const QDir & );
121 121
122 /* updates the file name line of the FileSelector */ 122 /* updates the file name line of the FileSelector */
123 void updateLine( const QString& ); 123 void updateLine( const QString& );
124 OFileSelector* selector()const; 124 OFileSelector* selector()const;
125 125
126private: 126private:
127 OFileSelector* m_sel; 127 OFileSelector* m_sel;
128}; 128};
129 129
130class OFileViewFactory { 130class OFileViewFactory {
131 public: 131 public:
132 OFileViewFactory() {} ; 132 OFileViewFactory() {} ;
133 virtual ~OFileViewFactory() = 0; 133 virtual ~OFileViewFactory() = 0;
134 134
135 OFileView* newView(QWidget *parent, const char *name ); 135 OFileView* newView(QWidget *parent, const char *name );
136 QString name()const; 136 QString name()const;
137}; 137};
138 138
139 139
140#endif 140#endif
diff --git a/libopie/ofileselector/olister.cpp b/libopie/ofileselector/olister.cpp
index 378c69d..ea09940 100644
--- a/libopie/ofileselector/olister.cpp
+++ b/libopie/ofileselector/olister.cpp
@@ -1,162 +1,171 @@
1#include <qcombobox.h> 1#include <qcombobox.h>
2 2
3#include "olister.h" 3#include "olister.h"
4#include "ofileview.h" 4#include "ofileview.h"
5#include "opixmapprovider.h" 5#include "opixmapprovider.h"
6#include "ofileselector.h" 6#include "ofileselector.h"
7 7
8 8
9OLister::OLister( OFileSelector* view) 9OLister::OLister( OFileSelector* view)
10 : m_view( view ), m_acc( 0l ) 10 : m_view( view ), m_acc( 0l )
11{ 11{
12 m_prov = new OPixmapProvider( view ); 12 m_prov = new OPixmapProvider( view );
13} 13}
14OLister::~OLister() { 14OLister::~OLister() {
15 delete m_prov; 15 delete m_prov;
16} 16}
17void OLister::setPixmapProvider( OPixmapProvider* prov ) { 17void OLister::setPixmapProvider( OPixmapProvider* prov ) {
18 delete m_prov; 18 delete m_prov;
19 m_prov = prov; 19 m_prov = prov;
20} 20}
21bool OLister::showFiles()const { 21bool OLister::showFiles()const {
22 return m_view->showFiles(); 22 return m_view->showFiles();
23} 23}
24bool OLister::showDirs()const { 24bool OLister::showDirs()const {
25 return m_view->showDirs(); 25 return m_view->showDirs();
26} 26}
27void OLister::addFile( const QString& mine, 27void OLister::addFile( const QString& mine,
28 QFileInfo* info, 28 QFileInfo* info,
29 const QString& extra, 29 const QString& extra,
30 bool isSymlink ) { 30 bool isSymlink ) {
31 int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink : 31 int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink :
32 OPixmapProvider::File; 32 OPixmapProvider::File;
33 QPixmap pix = provider()->pixmap(t, mine, 33 QPixmap pix = provider()->pixmap(t, mine,
34 info); 34 info);
35 view()->currentView()->addFile( pix, 35 view()->currentView()->addFile( pix,
36 mine, 36 mine,
37 info, 37 info,
38 extra, 38 extra,
39 isSymlink ); 39 isSymlink );
40} 40}
41void OLister::addFile( const QString& mine, 41void OLister::addFile( const QString& mine,
42 const QString& path, 42 const QString& path,
43 const QString& file, 43 const QString& file,
44 const QString& extra, 44 const QString& extra,
45 bool isSymlink ) { 45 bool isSymlink ) {
46 int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink : 46 int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink :
47 OPixmapProvider::File; 47 OPixmapProvider::File;
48 48
49 QPixmap pix = provider()->pixmap(t, mine, path, file ); 49 QPixmap pix = provider()->pixmap(t, mine, path, file );
50 view()->currentView()->addFile( pix, 50 view()->currentView()->addFile( pix,
51 mine, 51 mine,
52 path, 52 path,
53 file, 53 file,
54 extra, 54 extra,
55 isSymlink ); 55 isSymlink );
56} 56}
57void OLister::addDir( const QString& mine, 57void OLister::addDir( const QString& mine,
58 QFileInfo* info, 58 QFileInfo* info,
59 const QString& extra, 59 const QString& extra,
60 bool isSymlink ) { 60 bool isSymlink ) {
61 int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink : 61 int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink :
62 OPixmapProvider::Dir; 62 OPixmapProvider::Dir;
63 QPixmap pix = provider()->pixmap(t, mine, info ); 63 QPixmap pix = provider()->pixmap(t, mine, info );
64 view()->currentView()->addDir( pix, 64 view()->currentView()->addDir( pix,
65 mine, 65 mine,
66 info, 66 info,
67 extra, 67 extra,
68 isSymlink ); 68 isSymlink );
69} 69}
70void OLister::addDir( const QString& mine, 70void OLister::addDir( const QString& mine,
71 const QString& path, 71 const QString& path,
72 const QString& dir, 72 const QString& dir,
73 const QString& extra, 73 const QString& extra,
74 bool isSymlink ) { 74 bool isSymlink ) {
75 75
76 int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink : 76 int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink :
77 OPixmapProvider::Dir; 77 OPixmapProvider::Dir;
78 QPixmap pix = provider()->pixmap(t, mine, path, dir ); 78 QPixmap pix = provider()->pixmap(t, mine, path, dir );
79 79
80 view()->currentView()->addDir( pix, 80 view()->currentView()->addDir( pix,
81 mine, 81 mine,
82 path, 82 path,
83 dir, 83 dir,
84 extra, 84 extra,
85 isSymlink ); 85 isSymlink );
86} 86}
87void OLister::addSymlink( const QString& mine, 87void OLister::addSymlink( const QString& mine,
88 QFileInfo* info, 88 QFileInfo* info,
89 const QString& extra, 89 const QString& extra,
90 bool isSymlink ) { 90 bool isSymlink ) {
91 QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, info ); 91 QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, info );
92 view()->currentView()->addSymlink( pix, 92 view()->currentView()->addSymlink( pix,
93 mine, 93 mine,
94 info, 94 info,
95 extra, 95 extra,
96 isSymlink ); 96 isSymlink );
97} 97}
98void OLister::addSymlink( const QString& mine, 98void OLister::addSymlink( const QString& mine,
99 const QString& path, 99 const QString& path,
100 const QString& name, 100 const QString& name,
101 const QString& extra, 101 const QString& extra,
102 bool isSymlink ) { 102 bool isSymlink ) {
103 QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, 103 QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine,
104 path, name ); 104 path, name );
105 view()->currentView()->addSymlink( pix, 105 view()->currentView()->addSymlink( pix,
106 mine, 106 mine,
107 path, 107 path,
108 name, 108 name,
109 extra, 109 extra,
110 isSymlink ); 110 isSymlink );
111} 111}
112OFileSelector* OLister::view() { 112OFileSelector* OLister::view() {
113 return m_view; 113 return m_view;
114} 114}
115OPixmapProvider* OLister::provider() { 115OPixmapProvider* OLister::provider() {
116 return m_prov; 116 return m_prov;
117} 117}
118bool OLister::compliesMime( const QString& mime ) { 118bool OLister::compliesMime( const QString& mime ) {
119 return view()->compliesMime( mime ); 119 return view()->compliesMime( mime );
120} 120}
121void OLister::internFileSelected( const QString& dir ) {
122 view()->internFileSelected( dir );
123}
124void OLister::internChangedDir( const QString& dir ) {
125 view()->internChangedDir( dir );
126}
121OListerCmbAccess* OLister::comboBox() { 127OListerCmbAccess* OLister::comboBox() {
122 if (!m_acc ) 128 if (!m_acc )
123 m_acc = new OListerCmbAccess( view()->m_location ); 129 m_acc = new OListerCmbAccess( view()->m_location );
124 130
125 return m_acc; 131 return m_acc;
126} 132}
127 133
128 134
129OListerCmbAccess::OListerCmbAccess(QComboBox* box ) 135OListerCmbAccess::OListerCmbAccess(QComboBox* cmb )
130 : m_cmb( cmb ) 136 : m_cmb( cmb )
131{} 137{}
132OListerCmbAccess::~OListerCmbAccess() { 138OListerCmbAccess::~OListerCmbAccess() {
133} 139}
134void OListerCmbAccess::clear() { 140void OListerCmbAccess::clear() {
135 if ( m_cmb ) 141 if ( m_cmb )
136 m_cmb->clear(); 142 m_cmb->clear();
137} 143}
138void OListerCmbAccess::setCurrentItem( const QString& add, bool FORCE_ADD) { 144void OListerCmbAccess::setCurrentItem( const QString& add, bool FORCE_ADD) {
139 if ( !m_cmb ) return; 145 if ( !m_cmb ) return;
140 146
141 147
142 int c = m_cmb->count(); 148 int c = m_cmb->count();
143 for ( int i = 0; i < m_cmb->count(); i++ ) { 149 for ( int i = 0; i < m_cmb->count(); i++ ) {
144 if ( m_cmb->text(i) == add ) { 150 if ( m_cmb->text(i) == add ) {
145 bo->setCurrentItem( i ); 151 m_cmb->setCurrentItem( i );
146 return; 152 return;
147 } 153 }
148 } 154 }
155 if (!FORCE_ADD ) return;
156
157
149 m_cmb->insertItem(add ); 158 m_cmb->insertItem(add );
150 m_cmb->setCurrentItem( c ); 159 m_cmb->setCurrentItem( c );
151} 160}
152void OListerCmbAccess::insert( const QString& str ) { 161void OListerCmbAccess::insert( const QString& str ) {
153 if ( m_cmb ) 162 if ( m_cmb )
154 m_cmb->insertItem( str ); 163 m_cmb->insertItem( str );
155} 164}
156QString OListerCmbAccess::currentText()const { 165QString OListerCmbAccess::currentText()const {
157 QString str; 166 QString str;
158 if (m_cmb ) 167 if (m_cmb )
159 str = m_cmb->currentText(); 168 str = m_cmb->currentText();
160 169
161 return str; 170 return str;
162} 171}
diff --git a/libopie/ofileselector/olister.h b/libopie/ofileselector/olister.h
index 79d5409..cd84316 100644
--- a/libopie/ofileselector/olister.h
+++ b/libopie/ofileselector/olister.h
@@ -1,125 +1,128 @@
1#ifndef OPIE_FILE_LISTER_H 1#ifndef OPIE_FILE_LISTER_H
2#define OPIE_FILE_LISTER_H 2#define OPIE_FILE_LISTER_H
3 3
4#include <qfileinfo.h> 4#include <qfileinfo.h>
5#include <qmap.h> 5#include <qmap.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <qstringlist.h> 7#include <qstringlist.h>
8 8
9class QComboBox; 9class QComboBox;
10class OPixmapProvider; 10class OPixmapProvider;
11class OFileSelector; 11class OFileSelector;
12 12
13class OListerCmbAccess; 13class OListerCmbAccess;
14/** 14/**
15 * lister is something like KIO but very 15 * lister is something like KIO but very
16 * very basic and currently only for 16 * very basic and currently only for
17 * populating our views. 17 * populating our views.
18 * This is a base class which needs to be implemented. 18 * This is a base class which needs to be implemented.
19 * @see OLocalLister for a filesystem based implementation 19 * @see OLocalLister for a filesystem based implementation
20 */ 20 */
21 21
22class OLister { 22class OLister {
23public: 23public:
24 OLister( OFileSelector* ); 24 OLister( OFileSelector* );
25 virtual ~OLister(); 25 virtual ~OLister();
26 virtual void reparse(const QString& path) = 0; 26 virtual void reparse(const QString& path) = 0;
27 27
28 /** 28 /**
29 * return a list of available mimetypes 29 * return a list of available mimetypes
30 */ 30 */
31 virtual QMap<QString, QStringList> mimeTypes( const QString& dir ) = 0; 31 virtual QMap<QString, QStringList> mimeTypes( const QString& dir ) = 0;
32 void setPixmapProvider( OPixmapProvider* ); 32 void setPixmapProvider( OPixmapProvider* );
33 33
34 34
35 /* some way a slot */ 35 /* some way a slot */
36 void fileSelected( const QString& dir, const QString& file, const QString& extra ) = 0; 36 virtual void fileSelected( const QString& dir, const QString& file, const QString& extra ) = 0;
37 void changeDir( const QString& dir, const QString& file, const QString& extra ) = 0; 37 virtual void changedDir( const QString& dir, const QString& file, const QString& extra ) = 0;
38protected: 38protected:
39 /** 39 /**
40 * I hate too big classes 40 * I hate too big classes
41 * this is a way to group 41 * this is a way to group
42 * access to a ComboBox 42 * access to a ComboBox
43 * which might exist or 43 * which might exist or
44 * not in a secure way 44 * not in a secure way
45 */ 45 */
46 OListerCmbAccess* comboBox(); 46 OListerCmbAccess* comboBox();
47 47
48 bool showFiles()const; 48 bool showFiles()const;
49 bool showDirs()const; 49 bool showDirs()const;
50 bool compliesMime( const QString& mime ); 50 bool compliesMime( const QString& mime );
51 void addFile( const QString& mine, 51 void addFile( const QString& mine,
52 QFileInfo*, 52 QFileInfo*,
53 const QString& extra = QString::null, 53 const QString& extra = QString::null,
54 bool isSymlink = FALSE ); 54 bool isSymlink = FALSE );
55 55
56 void addFile( const QString& mine, 56 void addFile( const QString& mine,
57 const QString& path, 57 const QString& path,
58 const QString& file, 58 const QString& file,
59 const QString& extra = QString::null, 59 const QString& extra = QString::null,
60 bool isSymlink = FALSE ); 60 bool isSymlink = FALSE );
61 void addDir( const QString& mine, 61 void addDir( const QString& mine,
62 QFileInfo*, 62 QFileInfo*,
63 const QString& extra = QString::null,
63 bool isSymlink = FALSE ); 64 bool isSymlink = FALSE );
64 void addDir( const QString& mine, 65 void addDir( const QString& mine,
65 const QString& path, 66 const QString& path,
66 const QString& dir, 67 const QString& dir,
67 const QString& extra = QString::null, 68 const QString& extra = QString::null,
68 bool isSymlink = FALSE ); 69 bool isSymlink = FALSE );
69 void addSymlink( const QString& mine, 70 void addSymlink( const QString& mine,
70 QFileInfo* info, 71 QFileInfo* info,
71 const QString& extra = QString::null, 72 const QString& extra = QString::null,
72 bool isSymlink = FALSE); 73 bool isSymlink = FALSE);
73 void addSymlink( const QString& mine, 74 void addSymlink( const QString& mine,
74 const QString& path, 75 const QString& path,
75 const QString& name, 76 const QString& name,
76 const QString& extra = QString::null, 77 const QString& extra = QString::null,
77 bool isSymlink = FALSE ); 78 bool isSymlink = FALSE );
78 OFileSelector* view(); 79 OFileSelector* view();
79 OPixmapProvider* provider(); 80 OPixmapProvider* provider();
81 void internFileSelected( const QString& file );
82 void internChangedDir( const QString& dir );
80private: 83private:
81 OFileSelector* m_view; 84 OFileSelector* m_view;
82 OPixmapProvider* m_prov; 85 OPixmapProvider* m_prov;
83 OListerCmbAccess* m_acc; 86 OListerCmbAccess* m_acc;
84 87
85 class Private; 88 class Private;
86 Private *d; 89 Private *d;
87}; 90};
88 91
89class OListerCmbAccess { 92class OListerCmbAccess {
90 friend class OLister; 93 friend class OLister;
91public: 94public:
92 OListerCmbAccess( QComboBox* = 0l); 95 OListerCmbAccess( QComboBox* = 0l);
93 ~OListerCmbAccess(); 96 ~OListerCmbAccess();
94 97
95 /** 98 /**
96 * clears the combobox 99 * clears the combobox
97 */ 100 */
98 void clear(); 101 void clear();
99 102
100 /** 103 /**
101 * set's @param add to be the current Item 104 * set's @param add to be the current Item
102 * if the item is not present it'll be removed 105 * if the item is not present it'll be removed
103 */ 106 */
104 void setCurrentItem( const QString& add, bool FORECE_ADD = TRUE ); 107 void setCurrentItem( const QString& add, bool FORECE_ADD = TRUE );
105 108
106 /** 109 /**
107 * inserts the the String at 110 * inserts the the String at
108 * a non predictable position... The position is determined 111 * a non predictable position... The position is determined
109 * by the QComboBox code 112 * by the QComboBox code
110 */ 113 */
111 void insert( const QString& ); 114 void insert( const QString& );
112 115
113 /** 116 /**
114 * 117 *
115 */ 118 */
116 QString currentText()const; 119 QString currentText()const;
117 120
118private: 121private:
119 class Private; 122 class Private;
120 Private* d; 123 Private* d;
121 QComboBox* m_cmb; 124 QComboBox* m_cmb;
122 125
123}; 126};
124 127
125#endif 128#endif
diff --git a/libopie/ofileselector/olocallister.cpp b/libopie/ofileselector/olocallister.cpp
index 2306b14..5d7884d 100644
--- a/libopie/ofileselector/olocallister.cpp
+++ b/libopie/ofileselector/olocallister.cpp
@@ -1,119 +1,125 @@
1#include <qdir.h> 1#include <qdir.h>
2#include <qfileinfo.h> 2#include <qfileinfo.h>
3#include <qmap.h> 3#include <qmap.h>
4 4
5#include <qpe/mimetype.h> 5#include <qpe/mimetype.h>
6 6
7#include "ofileselector.h" 7#include "ofileselector.h"
8#include "olocallister.h" 8#include "olocallister.h"
9 9
10OLocalLister::OLocalLister( OFileSelector* file ) 10OLocalLister::OLocalLister( OFileSelector* file )
11 : OLister( file ) 11 : OLister( file )
12{ 12{
13} 13}
14OLocalLister::~OLocalLister() { 14OLocalLister::~OLocalLister() {
15} 15}
16 16
17QMap<QString, QStringList> OLocalLister::mimeTypes( const QString& curDir ) { 17QMap<QString, QStringList> OLocalLister::mimeTypes( const QString& curDir ) {
18 QMap<QString, QStringList> mimes; 18 QMap<QString, QStringList> mimes;
19 19
20 // let's find possible mimetypes 20 // let's find possible mimetypes
21 QDir dir( curDir ); 21 QDir dir( curDir );
22 dir.setFilter( QDir::Files | QDir::Readable ); 22 dir.setFilter( QDir::Files | QDir::Readable );
23 dir.setSorting( QDir::Size ); 23 dir.setSorting( QDir::Size );
24 24
25 const QFileInfoList *list = dir.entryInfoList(); 25 const QFileInfoList *list = dir.entryInfoList();
26 QFileInfoListIterator it( *list ); 26 QFileInfoListIterator it( *list );
27 QFileInfo *fi; 27 QFileInfo *fi;
28 28
29 while( (fi=it.current() ) ) { 29 while( (fi=it.current() ) ) {
30 /* skip .desktop */ 30 /* skip .desktop */
31 if( fi->extension() == QString::fromLatin1("desktop") ){ 31 if( fi->extension() == QString::fromLatin1("desktop") ){
32 ++it; 32 ++it;
33 continue; 33 continue;
34 } 34 }
35 MimeType type( fi->absFilePath() ); 35 MimeType type( fi->absFilePath() );
36 36
37 if( !mimes.contains( type.id() ) ){ 37 if( !mimes.contains( type.id() ) ){
38 mimes.insert( type.id(), type.id() ); 38 mimes.insert( type.id(), type.id() );
39 } 39 }
40 40
41 ++it; 41 ++it;
42 } 42 }
43 43
44 return mimes; 44 return mimes;
45} 45}
46/** 46/**
47 * FIXME mimecheck 47 * FIXME mimecheck
48 * use mime check for that 48 * use mime check for that
49 * filter dirs 49 * filter dirs
50 * filter filters 50 * filter filters
51 * filter files 51 * filter files
52 * filter mimetypes 52 * filter mimetypes
53 */ 53 */
54void OLocalLister::reparse( const QString& path ) { 54void OLocalLister::reparse( const QString& path ) {
55 QString currentMimeType; 55 QString currentMimeType;
56 QDir dir( path ); 56 QDir dir( path );
57 57
58 dir.setSorting( view()->sorting() ); 58 dir.setSorting( view()->sorting() );
59 dir.setFilter( view()->filter() ); 59 dir.setFilter( view()->filter() );
60 60
61 61
62 const QFileInfoList *list = dir.entryInfoList(); 62 const QFileInfoList *list = dir.entryInfoList();
63 QFileInfoListIterator it( *list ); 63 QFileInfoListIterator it( *list );
64 QFileInfo *fi; 64 QFileInfo *fi;
65 65
66 while( (fi=it.current() ) ){ 66 while( (fi=it.current() ) ){
67 67
68 if( fi->fileName() == QString::fromLatin1("..") || 68 if( fi->fileName() == QString::fromLatin1("..") ||
69 fi->fileName() == QString::fromLatin1(".") ){ 69 fi->fileName() == QString::fromLatin1(".") ){
70 ++it; 70 ++it;
71 continue; 71 continue;
72 } 72 }
73 if( fi->isSymLink() ){ 73 if( fi->isSymLink() ){
74 QString file = fi->dirPath( true ) + "/" + fi->readLink(); 74 QString file = fi->dirPath( true ) + "/" + fi->readLink();
75 /* 75 /*
76 * 5 tries to prevent dos attack 76 * 5 tries to prevent dos attack
77 */ 77 */
78 for( int i = 0; i<=4; i++) { 78 for( int i = 0; i<=4; i++) {
79 QFileInfo info( file ); 79 QFileInfo info( file );
80 if( !info.exists() ){ 80 if( !info.exists() ){
81 addSymlink( currentMimeType, fi, TRUE ); 81 addSymlink( currentMimeType, fi, QString::null, TRUE );
82 break; 82 break;
83 }else if( info.isDir() ){ 83 }else if( info.isDir() ){
84 if (!showDirs() ) 84 if (!showDirs() )
85 break; 85 break;
86 86
87 addDir( currentMimeType, fi, 87 addDir( currentMimeType, fi, QString::null,
88 TRUE ); 88 TRUE );
89 break; 89 break;
90 }else if( info.isFile() ){ 90 }else if( info.isFile() ){
91 /* if not show files skip it */ 91 /* if not show files skip it */
92 if (!showFiles() ) 92 if (!showFiles() )
93 break; 93 break;
94 94
95 /* check if we comply to the mimetype */ 95 /* check if we comply to the mimetype */
96 MimeType type( info.absFilePath() ); 96 MimeType type( info.absFilePath() );
97 if (compliesMime( type.id() ) ) 97 if (compliesMime( type.id() ) )
98 addFile( currentMimeType, fi, TRUE ); 98 addFile( currentMimeType, fi, QString::null, TRUE );
99 99
100 break; 100 break;
101 }else if( info.isSymLink() ){ 101 }else if( info.isSymLink() ){
102 file = info.dirPath(true ) + "/" + info.readLink() ; 102 file = info.dirPath(true ) + "/" + info.readLink() ;
103 break; 103 break;
104 }else if( i == 4){ 104 }else if( i == 4){
105 addSymlink( currentMimeType, fi ); 105 addSymlink( currentMimeType, fi );
106 } 106 }
107 } 107 }
108 108
109 }else if( fi->isDir() ){ 109 }else if( fi->isDir() ){
110 if (showDirs() ) 110 if (showDirs() )
111 addDir( currentMimeType, fi ); 111 addDir( currentMimeType, fi );
112 }else if( fi->isFile() ){ 112 }else if( fi->isFile() ){
113 if ( showFiles() ) 113 if ( showFiles() )
114 addFile( currentMimeType, fi ); 114 addFile( currentMimeType, fi );
115 } 115 }
116 ++it; 116 ++it;
117 } // of while loop 117 } // of while loop
118} 118}
119 119/* more accepting it code */
120void OLocalLister::fileSelected( const QString& dir, const QString& file, const QString& ) {
121 internFileSelected( dir + "/" + file );
122}
123void OLocalLister::changedDir( const QString& dir, const QString& file, const QString& ) {
124 internChangedDir( dir + "/" + file );
125}
diff --git a/libopie/ofileselector/olocallister.h b/libopie/ofileselector/olocallister.h
index 0a06102..01e6f3c 100644
--- a/libopie/ofileselector/olocallister.h
+++ b/libopie/ofileselector/olocallister.h
@@ -1,14 +1,16 @@
1#ifndef OPIE_LOCAL_LISTER 1#ifndef OPIE_LOCAL_LISTER
2#define OPIE_LOCAL_LISTER 2#define OPIE_LOCAL_LISTER
3 3
4#include "olister.h" 4#include "olister.h"
5 5
6class OLocalLister : public OLister { 6class OLocalLister : public OLister {
7public: 7public:
8 OLocalLister( OFileSelector* ); 8 OLocalLister( OFileSelector* );
9 ~OLocalLister(); 9 ~OLocalLister();
10 void reparse( const QString& path ); 10 void reparse( const QString& path );
11 QMap<QString, QStringList> mimeTypes(const QString& dir ); 11 QMap<QString, QStringList> mimeTypes(const QString& dir );
12 void fileSelected( const QString& dir, const QString& file, const QString& );
13 void changedDir( const QString& dir, const QString& file,const QString& );
12}; 14};
13 15
14#endif 16#endif