summaryrefslogtreecommitdiff
authorzecke <zecke>2003-05-25 17:51:52 (UTC)
committer zecke <zecke>2003-05-25 17:51:52 (UTC)
commit7e1dce1560e45ef7fad91a8da2d0d96c1b166df9 (patch) (unidiff)
treec896c8ab6129414fa80df712a3a5794fa933716f
parentf1773ad179cb68b8e7777f3d43667ed5ebf1968d (diff)
downloadopie-7e1dce1560e45ef7fad91a8da2d0d96c1b166df9.zip
opie-7e1dce1560e45ef7fad91a8da2d0d96c1b166df9.tar.gz
opie-7e1dce1560e45ef7fad91a8da2d0d96c1b166df9.tar.bz2
die here too
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector/.cvsignore1
-rw-r--r--libopie/ofileselector/MANIFEST29
-rwxr-xr-xlibopie/ofileselector/configure301
-rw-r--r--libopie/ofileselector/libopie.pro104
-rw-r--r--libopie/ofileselector/odefaultfactories.cpp19
-rw-r--r--libopie/ofileselector/odefaultfactories.h16
-rw-r--r--libopie/ofileselector/ofiledialog.cpp116
-rw-r--r--libopie/ofileselector/ofiledialog.h78
-rw-r--r--libopie/ofileselector/ofilefactory.cpp58
-rw-r--r--libopie/ofileselector/ofilefactory.h32
-rw-r--r--libopie/ofileselector/ofilelistview.cpp201
-rw-r--r--libopie/ofileselector/ofilelistview.h69
-rw-r--r--libopie/ofileselector/ofileselector.cpp1095
-rw-r--r--libopie/ofileselector/ofileselector.h492
-rw-r--r--libopie/ofileselector/ofileselectoritem.cpp58
-rw-r--r--libopie/ofileselector/ofileselectoritem.h35
-rw-r--r--libopie/ofileselector/ofileselectormain.cpp41
-rw-r--r--libopie/ofileselector/ofileselectormain.h23
-rw-r--r--libopie/ofileselector/ofileview.cpp32
-rw-r--r--libopie/ofileselector/ofileview.h140
-rw-r--r--libopie/ofileselector/olister.cpp181
-rw-r--r--libopie/ofileselector/olister.h144
-rw-r--r--libopie/ofileselector/olocallister.cpp150
-rw-r--r--libopie/ofileselector/olocallister.h21
-rw-r--r--libopie/ofileselector/opixmapprovider.cpp83
-rw-r--r--libopie/ofileselector/opixmapprovider.h41
26 files changed, 0 insertions, 3560 deletions
diff --git a/libopie/ofileselector/.cvsignore b/libopie/ofileselector/.cvsignore
deleted file mode 100644
index 6d678c6..0000000
--- a/libopie/ofileselector/.cvsignore
+++ b/dev/null
@@ -1 +0,0 @@
1config.in
diff --git a/libopie/ofileselector/MANIFEST b/libopie/ofileselector/MANIFEST
deleted file mode 100644
index 2730a1c..0000000
--- a/libopie/ofileselector/MANIFEST
+++ b/dev/null
@@ -1,29 +0,0 @@
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
deleted file mode 100755
index c66fd82..0000000
--- a/libopie/ofileselector/configure
+++ b/dev/null
@@ -1,301 +0,0 @@
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
deleted file mode 100644
index 5cc6368..0000000
--- a/libopie/ofileselector/libopie.pro
+++ b/dev/null
@@ -1,104 +0,0 @@
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/ofileselectormain.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 = $(OPIEDIR)/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/nl/libopie.ts \
86 ../i18n/xx/libopie.ts \
87 ../i18n/en/libopie.ts \
88 ../i18n/es/libopie.ts \
89 ../i18n/fr/libopie.ts \
90 ../i18n/hu/libopie.ts \
91 ../i18n/ja/libopie.ts \
92 ../i18n/ko/libopie.ts \
93 ../i18n/no/libopie.ts \
94 ../i18n/pl/libopie.ts \
95 ../i18n/pt/libopie.ts \
96 ../i18n/pt_BR/libopie.ts \
97 ../i18n/sl/libopie.ts \
98 ../i18n/zh_CN/libopie.ts \
99 ../i18n/zh_TW/libopie.ts \
100 ../i18n/da/libopie.ts
101
102
103
104include ( $(OPIEDIR)/include.pro )
diff --git a/libopie/ofileselector/odefaultfactories.cpp b/libopie/ofileselector/odefaultfactories.cpp
deleted file mode 100644
index 2f8ef9b..0000000
--- a/libopie/ofileselector/odefaultfactories.cpp
+++ b/dev/null
@@ -1,19 +0,0 @@
1#include "ofilelistview.h"
2#include "olocallister.h"
3
4
5#include "odefaultfactories.h"
6
7extern "C" {
8
9
10
11 OFileView* newFileListView( OFileSelector* sel, QWidget* par ) {
12 return new OFileListView(par, sel );
13 }
14
15 OLister* newLocalLister( OFileSelector* sel) {
16 return new OLocalLister( sel );
17 }
18
19};
diff --git a/libopie/ofileselector/odefaultfactories.h b/libopie/ofileselector/odefaultfactories.h
deleted file mode 100644
index 0cc90e5..0000000
--- a/libopie/ofileselector/odefaultfactories.h
+++ b/dev/null
@@ -1,16 +0,0 @@
1#ifndef OPIE_DEFAULT_FACTORIES_H
2#define OPIE_DEFAULT_FACTORIES_H
3
4#include "ofilefactory.h"
5
6extern "C" {
7
8 OFileView* newFileListView( OFileSelector*, QWidget* parent );
9
10 OLister* newLocalLister(OFileSelector* );
11
12
13};
14
15
16#endif
diff --git a/libopie/ofileselector/ofiledialog.cpp b/libopie/ofileselector/ofiledialog.cpp
deleted file mode 100644
index d137c66..0000000
--- a/libopie/ofileselector/ofiledialog.cpp
+++ b/dev/null
@@ -1,116 +0,0 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <>
4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include <qpe/applnk.h>
30#include <qstring.h>
31#include <qapplication.h>
32#include <qlayout.h>
33
34#include "ofiledialog.h"
35
36OFileDialog::OFileDialog(const QString &caption,
37 QWidget *wid, int mode, int selector,
38 const QString &dirName,
39 const QString &fileName,
40 const QMap<QString,QStringList>& mimetypes )
41 : QDialog( wid, "OFileDialog", true )
42{
43 // QVBoxLayout *lay = new QVBoxLayout(this);
44 //showMaximized();
45 QVBoxLayout *lay = new QVBoxLayout(this );
46 file = new OFileSelector(this , mode, selector,
47 dirName, fileName,
48 mimetypes );
49 lay->addWidget( file );
50
51 //lay->addWidget( file );
52 //showFullScreen();
53 setCaption( caption.isEmpty() ? tr("FileDialog") : caption );
54 connect(file, SIGNAL(fileSelected(const QString&) ),
55 this, SLOT(slotFileSelected(const QString&) ) );
56
57 connect(file, SIGNAL(dirSelected(const QString &) ),
58 this, SLOT(slotDirSelected(const QString &) ) );
59
60
61 file->setYesCancelVisible( false ); // relayout
62}
63QString OFileDialog::mimetype()const
64{
65 return QString::null;
66}
67QString OFileDialog::fileName()const
68{
69 return file->selectedName();
70}
71DocLnk OFileDialog::selectedDocument()const
72{
73 return file->selectedDocument();
74}
75QString OFileDialog::getOpenFileName(int selector,
76 const QString &startDir,
77 const QString &file,
78 const MimeTypes &mimes,
79 QWidget *wid,
80 const QString &caption )
81{
82 QString ret;
83 OFileDialog dlg( caption.isEmpty() ? tr("Open") : caption,
84 wid, OFileSelector::Open, selector, startDir, file, mimes);
85 dlg.showMaximized();
86 if( dlg.exec() )
87 ret = dlg.fileName();
88
89 return ret;
90}
91QString OFileDialog::getSaveFileName(int selector,
92 const QString &startDir,
93 const QString &file,
94 const MimeTypes &mimes,
95 QWidget *wid,
96 const QString &caption )
97{
98 QString ret;
99 OFileDialog dlg( caption.isEmpty() ? tr("Save") : caption,
100 wid, OFileSelector::Save, selector, startDir, file, mimes);
101 dlg.showMaximized();
102 if( dlg.exec() )
103 ret = dlg.fileName();
104
105 return ret;
106}
107
108void OFileDialog::slotFileSelected(const QString & )
109{
110 accept();
111}
112void OFileDialog::slotDirSelected(const QString & )
113{
114 // if mode
115 //accept();
116}
diff --git a/libopie/ofileselector/ofiledialog.h b/libopie/ofileselector/ofiledialog.h
deleted file mode 100644
index e368e96..0000000
--- a/libopie/ofileselector/ofiledialog.h
+++ b/dev/null
@@ -1,78 +0,0 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 zecke <zecke@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29
30#ifndef OpieFileDialog_h
31#define OpieFileDialog_h
32
33#include <qdialog.h>
34
35//#include <opie/ofileselector.h>
36#include "ofileselector.h"
37
38class OFileDialog : public QDialog {
39 Q_OBJECT
40 public:
41 OFileDialog(const QString &caption,
42 QWidget *, int mode, int selector,
43 const QString &dirName,
44 const QString &fileName = QString::null,
45 const MimeTypes &mimetypes = MimeTypes() );
46 QString mimetype() const;
47 QString fileName() const;
48 DocLnk selectedDocument()const;
49
50 // static methods
51 static QString getOpenFileName(int selector,
52 const QString& startDir = QString::null,
53 const QString &fileName = QString::null,
54 const MimeTypes& mime = MimeTypes(),
55 QWidget *wid = 0,
56 const QString &caption = QString::null );
57
58 static QString getSaveFileName(int selector,
59 const QString& startDir = QString::null,
60 const QString& fileName = QString::null,
61 const MimeTypes& mimefilter = MimeTypes(),
62 QWidget *wid = 0,
63 const QString &caption = QString::null );
64
65 //let's OFileSelector catch up first
66 //static QString getExistingDirectory(const QString& startDir = QString::null,
67 // QWidget *parent = 0,
68 // const QString& caption = QString::null );
69 private:
70 class OFileDialogPrivate;
71 OFileDialogPrivate *d;
72 OFileSelector *file;
73
74 private slots:
75 void slotFileSelected( const QString & );
76 void slotDirSelected(const QString & );
77};
78#endif
diff --git a/libopie/ofileselector/ofilefactory.cpp b/libopie/ofileselector/ofilefactory.cpp
deleted file mode 100644
index aa143b4..0000000
--- a/libopie/ofileselector/ofilefactory.cpp
+++ b/dev/null
@@ -1,58 +0,0 @@
1#include "ofilefactory.h"
2
3OFileFactory::OFileFactory() {
4}
5OFileFactory::~OFileFactory() {
6}
7QStringList OFileFactory::lister()const {
8 QStringList list;
9 QMap<QString, listerFact>::ConstIterator it;
10 for ( it = m_lister.begin(); it != m_lister.end(); ++it ) {
11 list << it.key();
12 }
13 return list;
14}
15QStringList OFileFactory::views()const {
16 QStringList list;
17 QMap<QString, viewFact>::ConstIterator it;
18 for (it = m_view.begin(); it != m_view.end(); ++it ) {
19 list << it.key();
20 }
21
22 return list;
23}
24OFileView* OFileFactory::view( const QString& name,
25 OFileSelector* sel, QWidget* par) {
26 OFileView* vie= 0l;
27
28 QMap<QString, viewFact>::Iterator it;
29 it = m_view.find( name );
30
31 if ( it != m_view.end() ) {
32 vie = (*(it.data() ) )(sel, par);
33 }
34 return vie;
35}
36OLister* OFileFactory::lister(const QString& name, OFileSelector* sel) {
37 OLister* lis = 0l;
38
39 QMap<QString, listerFact>::Iterator it;
40 it = m_lister.find( name );
41 if ( it != m_lister.end() ) {
42 lis = (*(it.data() ) )(sel);
43 }
44
45 return lis;
46}
47void OFileFactory::addLister( const QString& name, listerFact fact ) {
48 m_lister.insert( name, fact );
49}
50void OFileFactory::addView( const QString& name, viewFact fact ) {
51 m_view.insert( name, fact );
52}
53void OFileFactory::removeLister( const QString& name) {
54 m_lister.remove( name );
55}
56void OFileFactory::removeView( const QString& name) {
57 m_view.remove( name );
58}
diff --git a/libopie/ofileselector/ofilefactory.h b/libopie/ofileselector/ofilefactory.h
deleted file mode 100644
index 96fb00d..0000000
--- a/libopie/ofileselector/ofilefactory.h
+++ b/dev/null
@@ -1,32 +0,0 @@
1#ifndef OFILE_FACTORY_H
2#define OFILE_FACTORY_H
3
4#include "olister.h"
5#include "ofileview.h"
6class OFileFactory {
7public:
8 typedef OLister* (*listerFact)(OFileSelector*);
9 typedef OFileView* (*viewFact)(OFileSelector*, QWidget*);
10 OFileFactory();
11 ~OFileFactory();
12
13 QStringList lister()const;
14 QStringList views()const;
15
16 OFileView* view( const QString& name, OFileSelector*, QWidget* );
17 OLister* lister( const QString& name, OFileSelector* );
18
19 void addLister( const QString&, listerFact fact );
20 void addView( const QString&, viewFact );
21
22 void removeLister( const QString& );
23 void removeView( const QString& );
24
25private:
26 QMap<QString, listerFact> m_lister;
27 QMap<QString, viewFact> m_view;
28
29};
30
31
32#endif
diff --git a/libopie/ofileselector/ofilelistview.cpp b/libopie/ofileselector/ofilelistview.cpp
deleted file mode 100644
index fe8acf0..0000000
--- a/libopie/ofileselector/ofilelistview.cpp
+++ b/dev/null
@@ -1,201 +0,0 @@
1
2#include <qheader.h>
3
4#include <qpe/mimetype.h>
5#include <qpe/resource.h>
6#include <qpe/qpeapplication.h>
7
8#include "ofileselector.h"
9#include "ofileselectoritem.h"
10#include "ofilelistview.h"
11
12
13OFileListView::OFileListView( QWidget* parent, OFileSelector* sel)
14 : QListView( parent ), OFileView( sel )
15{
16 QPEApplication::setStylusOperation( viewport(),
17 QPEApplication::RightOnHold);
18 addColumn(" " );
19 addColumn(tr("Name"), 135 );
20 addColumn(tr("Size"), -1 );
21 addColumn(tr("Date"), 60 );
22 addColumn(tr("Mime Type"), -1 );
23 QHeader *head = header();
24 head->hide();
25 setSorting( 1 );
26 setAllColumnsShowFocus( TRUE );
27
28 connect(this, SIGNAL(selectionChanged() ),
29 this, SLOT(slotSelectionChanged() ) );
30
31 connect(this, SIGNAL(currentChanged(QListViewItem *) ),
32 this, SLOT(slotCurrentChanged(QListViewItem * ) ) );
33
34 connect(this, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ),
35 this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) );
36
37 connect(this, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )),
38 this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) );
39}
40OFileListView::~OFileListView() {
41
42}
43void OFileListView::clear() {
44 QListView::clear();
45}
46void OFileListView::addFile( const QPixmap& pix,
47 const QString&,
48 QFileInfo* info,
49 const QString& extra,
50 bool isSymlink ) {
51 QString dir;
52 QString name;
53 bool locked = false;
54
55 dir = info->dirPath( true );
56
57 if( isSymlink )
58 name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink();
59 else {
60 name = info->fileName();
61 if( ( selector()->mode() == OFileSelector::Open && !info->isReadable() ) ||
62 ( selector()->mode() == OFileSelector::Save && !info->isWritable() ) ){
63
64 locked = true;
65 }
66 }
67 new OFileSelectorItem( this, pix, name,
68 info->lastModified().toString(),
69 QString::number( info->size() ),
70 dir, locked, extra );
71}
72void OFileListView::addFile( const QPixmap&,
73 const QString& /*mime*/, const QString& /*dir*/,
74 const QString& /*file*/,
75 const QString& /*extra*/,
76 bool /*isSyml*/ ) {
77
78}
79void OFileListView::addDir( const QPixmap& pix, const QString&,
80 QFileInfo* info,
81 const QString& extra ,
82 bool symlink ) {
83
84 bool locked = false;
85 QString name;
86
87 name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ;
88
89 new OFileSelectorItem( this, pix, name,
90 info->lastModified().toString(),
91 QString::number( info->size() ),
92 info->dirPath( true ), locked, extra,
93 true );
94
95}
96void OFileListView::addDir( const QPixmap&,
97 const QString& /*mime*/, const QString& /*dir*/,
98 const QString& /*file*/,
99 const QString& /*extra*/,
100 bool ) {
101
102}
103void OFileListView::addSymlink( const QPixmap&,
104 const QString& /*mime*/,
105 QFileInfo* /*info*/,
106 const QString& /*extra*/,
107 bool /*isSym*/ ) {
108
109}
110void OFileListView::addSymlink(const QPixmap&,
111 const QString& /*m*/, const QString& /*path*/,
112 const QString& /*file*/,
113 const QString& /*extra*/,
114 bool /*isSym*/ ) {
115
116}
117void OFileListView::cd( const QString& ) {
118
119}
120QWidget* OFileListView::widget() {
121 return this;
122}
123QString OFileListView::selectedName()const{
124 QListViewItem *item = currentItem();
125 if (!item )
126 return QString::null;
127
128 return item->text( 1 );
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}
137QStringList OFileListView::selectedNames()const {
138 QStringList list;
139 list << selectedName();
140 return list;
141}
142QString OFileListView::selectedPath()const {
143 return QString::null;
144}
145QStringList OFileListView::selectedPaths()const {
146 QStringList list;
147 list << selectedPath();
148 return list;
149}
150int OFileListView::fileCount() {
151 return childCount();
152}
153void OFileListView::sort() {
154 QListView::sort();
155}
156void OFileListView::slotSelectionChanged() {
157
158}
159void OFileListView::slotCurrentChanged( QListViewItem* item) {
160 if (!item )
161 return;
162
163 OFileSelectorItem* sel = (OFileSelectorItem*) item;
164
165 qWarning("current changed");
166 if(!sel->isDir() ){
167 updateLine( sel->text(1) );
168
169 if (selector()->mode() == OFileSelector::Fileselector ) {
170 QStringList str = QStringList::split("->", sel->text(1) );
171 fileSelected(sel->directory(), str[0].stripWhiteSpace(),sel->extra() );
172 }
173 }
174}
175void OFileListView::slotClicked( int button, QListViewItem* item,
176 const QPoint&, int ) {
177 if ( !item )
178 return;
179
180 if( button != Qt::LeftButton )
181 return;
182
183 OFileSelectorItem *sel = (OFileSelectorItem*)item;
184
185 if(!sel->isLocked() ){
186 QStringList str = QStringList::split("->", sel->text(1) );
187 if( sel->isDir() ){
188 changedDir( sel->directory(), str[0].stripWhiteSpace(),sel->extra() );
189 }else{
190 updateLine( str[0].stripWhiteSpace() );
191 fileSelected( sel->directory(),str[0].stripWhiteSpace(), sel->extra() );
192 }
193 }
194}
195void OFileListView::slotRightButton( int button, QListViewItem* item,
196 const QPoint&, int ) {
197 if (!item || (button != Qt::RightButton ))
198 return;
199
200 /* raise contextmenu */
201}
diff --git a/libopie/ofileselector/ofilelistview.h b/libopie/ofileselector/ofilelistview.h
deleted file mode 100644
index f2eac57..0000000
--- a/libopie/ofileselector/ofilelistview.h
+++ b/dev/null
@@ -1,69 +0,0 @@
1#ifndef OPIE_FILE_LIST_VIEW_H
2#define OPIE_FILE_LIST_VIEW_H
3
4#include <qlistview.h>
5#include <qpixmap.h>
6
7#include "ofileview.h"
8
9class OFileListView : public QListView, public OFileView {
10 Q_OBJECT
11public:
12 OFileListView( QWidget* parent, OFileSelector* );
13 ~OFileListView();
14
15 void clear();
16 void addFile( const QPixmap&,
17 const QString& mine,
18 QFileInfo* info,
19 const QString& extra = QString::null,
20 bool isSymlink = FALSE );
21
22 void addFile( const QPixmap&,
23 const QString& mime,
24 const QString& dir,
25 const QString& file,
26 const QString& extra = QString::null,
27 bool = false );
28
29 void addDir( const QPixmap&,
30 const QString& mime,
31 QFileInfo* info,
32 const QString& extra = QString::null,
33 bool = FALSE );
34
35 void addDir( const QPixmap&,
36 const QString& mime, const QString& dir,
37 const QString& file,
38 const QString& extra = QString::null,
39 bool = FALSE );
40
41 void addSymlink( const QPixmap&,
42 const QString& mime,
43 QFileInfo* info,
44 const QString& extra = QString::null,
45 bool = FALSE );
46 void addSymlink( const QPixmap&,
47 const QString& mine, const QString& path,
48 const QString& file,
49 const QString& extra = QString::null,
50 bool isSymlink = FALSE );
51 void cd( const QString& path );
52 QWidget* widget();
53 void sort();
54
55 QString selectedName()const ;
56 QStringList selectedNames()const;
57
58 QString selectedPath()const;
59 QStringList selectedPaths()const;
60 QString selectedExtra()const;
61 int fileCount();
62private slots:
63 void slotSelectionChanged();
64 void slotCurrentChanged(QListViewItem* );
65 void slotClicked( int, QListViewItem*, const QPoint&, int );
66 void slotRightButton(int, QListViewItem*, const QPoint&, int );
67};
68
69#endif
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp
deleted file mode 100644
index abc2889..0000000
--- a/libopie/ofileselector/ofileselector.cpp
+++ b/dev/null
@@ -1,1095 +0,0 @@
1
2
3#include <qcheckbox.h>
4#include <qcombobox.h>
5#include <qheader.h>
6#include <qlabel.h>
7#include <qabstractlayout.h>
8#include <qlayout.h>
9#include <qlineedit.h>
10#include <qlistview.h>
11#include <qmessagebox.h>
12#include <qpainter.h>
13#include <qpushbutton.h>
14#include <qwidgetstack.h>
15#include <qpopupmenu.h>
16#include <qdir.h>
17#include <qfile.h>
18#include <qfileinfo.h>
19#include <qtimer.h>
20
21#include <qpe/qpeapplication.h>
22#include <qpe/applnk.h>
23#include <qpe/global.h>
24#include <qpe/mimetype.h>
25#include <qpe/resource.h>
26#include <qpe/storage.h>
27
28#include <unistd.h>
29#include <stdlib.h>
30#include <sys/stat.h>
31
32#include "ofileview.h"
33#include "ofileselectormain.h"
34#include "ofileselector.h"
35#include "olocallister.h"
36#include "olister.h"
37#include "odefaultfactories.h"
38
39QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0;
40
41namespace {
42 /* let's find the index for a specified string */
43 int indexByString( const QComboBox *box, const QString &str ){
44 int index= 0;
45 for(int i= 0; i < box->count(); i++ ){
46 /* found */
47 if( str == box->text(i ) ){
48 index= i;
49 break;
50 }
51 }
52 return index;
53 }
54}
55
56OFileSelector::OFileSelector( QWidget *wid, int mode, int selector,
57 const QString &dirName,
58 const QString &fileName,
59 const QMap<QString,QStringList>& mimeTypes)
60 : QWidget( wid, "OFileSelector")
61{
62 m_mimetypes = mimeTypes;
63 if (mode == Save )
64 m_name = fileName;
65
66 initVars();
67
68 m_mode = mode;
69 m_selector = selector;
70 m_currentDir = dirName;
71 init();
72}
73
74OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent,
75 const char *name, bool newVisible,
76 bool closeVisible )
77 : QWidget( parent, name )
78{
79 /* update the mimefilter */
80 if (!mimeFilter.isEmpty() ) {
81 QStringList list = QStringList::split(";", mimeFilter );
82 m_mimetypes.insert(mimeFilter, list );
83 }
84 initVars();
85 m_currentDir = QPEApplication::documentDir();
86 m_mode = Fileselector;
87 m_selector = Normal;
88 m_shClose = closeVisible;
89 m_shNew = newVisible;
90 m_shLne = false;
91 m_shPerm = false;
92 m_shYesNo = false;
93 init();
94
95
96}
97
98OFileSelector::~OFileSelector()
99{
100
101
102}
103
104void OFileSelector::setNewVisible( bool visible )
105{
106 m_shNew = visible;
107 if (m_new )
108 m_new->show();
109}
110void OFileSelector::setCloseVisible( bool visible )
111{
112 m_shClose = visible;
113
114 if( m_close )
115 m_close->show();
116}
117void OFileSelector::reread()
118{
119 if( m_selector == Normal )
120 initializeOldSelector();
121 else
122 reparse();
123}
124
125const DocLnk *OFileSelector::selected()
126{
127 DocLnk *lnk = new DocLnk(selectedDocument() );
128 return lnk;
129}
130
131void OFileSelector::setYesCancelVisible( bool show )
132{
133 initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :(
134 m_shYesNo = show;
135
136 if( m_shYesNo )
137 m_boxOk->show();
138 else
139 m_boxOk->hide();
140
141}
142void OFileSelector::setToolbarVisible( bool show )
143{
144 m_shTool = show;
145
146 if(!m_shTool ){
147 m_location->hide();
148 m_up->hide();
149 m_homeButton->hide();
150 m_docButton->hide();
151 }else{
152 m_location->show();
153 m_up->show();
154 m_homeButton->show();
155 m_docButton->show();
156 }
157}
158void OFileSelector::setPermissionBarVisible( bool show )
159{
160 m_shPerm = show;
161 initializePerm();
162
163 if( m_shPerm )
164 m_checkPerm->show();
165 else
166 m_checkPerm->hide();
167}
168void OFileSelector::setLineEditVisible( bool show )
169{
170 if( show ){
171 initializeName();
172 m_boxName->show();
173 }else{
174 // check if we showed before this is the way to go
175 if( m_shLne && m_boxName != 0 )
176 m_boxName->hide();
177 }
178 m_shLne = show;
179}
180
181void OFileSelector::setChooserVisible( bool show )
182{
183 m_shChooser = show;
184 initializeChooser();
185
186 if( m_shChooser )
187 m_boxView->hide();
188 else
189 m_boxView->show();
190
191}
192
193QCheckBox* OFileSelector::permissionCheckbox()
194{
195 if( m_selector == Normal )
196 return 0l;
197 else
198 return m_checkPerm;
199}
200bool OFileSelector::setPermission()const
201{
202 return m_checkPerm == 0 ? false : m_checkPerm->isChecked();
203}
204void OFileSelector::setPermissionChecked( bool check )
205{
206 if( m_checkPerm )
207 m_checkPerm->setChecked( check );
208}
209
210void OFileSelector::setMode(int mode) // FIXME do direct raising
211{
212 m_mode = mode;
213 if( m_selector == Normal )
214 return;
215}
216void OFileSelector::setShowDirs(bool dir)
217{
218 m_dir = dir;
219 if ( m_selector != Fileselector )
220 reparse();
221}
222void OFileSelector::setCaseSensetive(bool caSe )
223{
224 m_case = caSe;
225
226 if ( m_selector != Fileselector )
227 reparse();
228}
229void OFileSelector::setShowFiles(bool show )
230{
231 m_files = show;
232 reparse();
233}
234///
235bool OFileSelector::cd(const QString &path )
236{
237 m_currentDir = path;
238 reparse();
239 return true;
240}
241void OFileSelector::setSelector(int mode )
242{
243 QString text;
244 switch( mode ){
245 case Normal:
246 text = tr("Documents");
247 break;
248 case Extended:
249 text = tr("List View");
250 break;
251 case ExtendedAll:
252 text = tr("All List View");
253 break;
254 }
255 slotViewCheck( text );
256}
257
258void OFileSelector::setPopupFactory(OPopupMenuFactory */*popup*/ )
259{
260/* m_custom = popup;
261 m_showPopup = true;
262*/
263}
264
265QString OFileSelector::selectedName() const
266{
267 QString name;
268 if( m_selector == Normal ){
269 DocLnk lnk = m_select->selectedDocument();
270 name = lnk.file();
271 }else {
272 name = currentLister()->selectedName();
273 }
274 return name;
275}
276QStringList OFileSelector::selectedNames()const
277{
278 QStringList list;
279 if( m_selector == Normal ){
280 list << selectedName();
281 }else {
282 list << selectedName(); // FIXME implement multiple Selections
283 }
284 return list;
285}
286/** If mode is set to the Dir selection this will return the selected path.
287 *
288 *
289 */
290QString OFileSelector::selectedPath()const
291{
292 QString path;
293 if( m_selector == Normal ){
294 path = QPEApplication::documentDir();
295 } /* normal case to do */
296 return path;
297}
298QStringList OFileSelector::selectedPaths() const
299{
300 QStringList list;
301 list << selectedPath();
302 return list;
303}
304QString OFileSelector::directory()const
305{
306 if( m_selector == Normal )
307 return QPEApplication::documentDir();
308
309 return QDir(m_currentDir).absPath();
310}
311
312int OFileSelector::fileCount()
313{
314 int count;
315 switch( m_selector ){
316 case Normal:
317 count = m_select->fileCount();
318 break;
319 case Extended:
320 case ExtendedAll:
321 default:
322 count = currentView()->fileCount();
323 break;
324 }
325 return count;
326}
327DocLnk OFileSelector::selectedDocument() const
328{
329 DocLnk lnk;
330 switch( m_selector ){
331 case Normal:{
332 lnk = m_select->selectedDocument();
333 break;
334 }
335 case Extended:
336 case ExtendedAll:
337 default:
338 lnk = DocLnk( selectedName() );
339 break;
340 }
341 return lnk;
342}
343QValueList<DocLnk> OFileSelector::selectedDocuments() const
344{
345 QValueList<DocLnk> docs;
346 docs.append( selectedDocument() );
347 return docs;
348}
349
350
351// slots internal
352
353void OFileSelector::slotOk()
354{
355 emit ok();
356}
357void OFileSelector::slotCancel()
358{
359 emit cancel();
360}
361/* switch the views */
362void OFileSelector::slotViewCheck(const QString &sel)
363{
364 setView( sel );
365}
366
367QString OFileSelector::currentMimeType() const{
368 QString mime;
369 QString currentText;
370 if (m_shChooser && m_mimeCheck )
371 currentText = m_mimeCheck->currentText();
372
373 qWarning("CurrentText" + currentText );
374 if (tr("All") == currentText ) return QString::null;
375 else if (currentText.isEmpty() ) {
376 ;
377 }else {
378 QMap<QString, QStringList>::ConstIterator it;
379 it = m_mimetypes.find( currentText );
380 if ( it != m_mimetypes.end() ) {
381 mime = it.data().join(";");
382 }else{
383 mime = currentText;
384 }
385 }
386 return mime;
387}
388void OFileSelector::slotMimeCheck(const QString &mime)
389{
390 if( m_selector == Normal ){
391 initializeOldSelector();
392
393 updateMimes();
394 updateMimeCheck();
395 m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
396 }else{ // others
397 qWarning("Mime %s", mime.latin1() );
398 if(m_shChooser ){
399 qWarning("Current Text %s", m_mimeCheck->currentText().latin1() );
400 //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
401 }
402 reparse();
403 }
404}
405/*
406 * Ok if a non dir gets inserted into this combobox
407 * we need to change it
408 * QFileInfo and dirPath will give us the right Dir
409 */
410void OFileSelector::slotLocationActivated(const QString &file)
411{
412 qWarning("slotLocationActivated");
413 QString name = file.left( file.find("<-", 0, TRUE ) );
414 QFileInfo info( name );
415 if ( info.isFile() )
416 cd(info.dirPath( TRUE ) ); //absolute
417 else
418 cd(name );
419}
420void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count)
421{
422 QStringList pathList;
423 bool underDog = FALSE;
424 for(int i=0;i<count;i++) {
425 pathList << m_location->text(i);
426 if( m_location->text(i) == currentPath)
427 underDog = TRUE;
428 }
429 if( !underDog) {
430 m_location->clear();
431 if( currentPath.left(2)=="//")
432 pathList.append( currentPath.right(currentPath.length()-1) );
433 else
434 pathList.append( currentPath );
435 m_location->insertStringList( pathList,-1);
436 }
437}
438/*
439 * Do not crash anymore
440 * don't try to change dir to a file
441 */
442void OFileSelector::locationComboChanged()
443{
444 QFileInfo info( m_location->lineEdit()->text() );
445 qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() );
446 if (info.isFile() )
447 cd(info.dirPath(TRUE) ); //absolute path
448 else
449 cd( m_location->lineEdit()->text() );
450}
451void OFileSelector::init()
452{
453 initFactory();
454 m_lay = new QVBoxLayout( this );
455 m_lay->setSpacing(0 );
456
457 /* take care of the main view... */
458 initToolbar();
459 //if( m_shChooser ) // the Chooser for the view and Mimetypes
460 initializeChooser();
461
462 /* initialize the file lister */
463 if( m_selector == Normal ){
464 QString mime;
465 if (!m_autoMime) {
466 if (!m_mimetypes.isEmpty() ) {
467 QMap<QString, QStringList>::Iterator it;
468 it = m_mimetypes.begin(); // cause we're in the init
469 mime = it.data().join(";");
470 }
471 }
472 initializeOldSelector();
473 }else{
474 initializeView();
475 }
476
477 if( m_shLne ) // the LineEdit with the current FileName
478 initializeName();
479
480 if( m_shPerm ) // the Permission QCheckBox
481 initializePerm();
482
483 if( m_shYesNo ) // the Yes No button row
484 initializeYes( );
485
486 if (m_selector != Normal )
487 reparse();
488
489 showMaximized();
490}
491void OFileSelector::updateMimes()
492{
493 if( m_autoMime ){
494 m_mimetypes.clear();
495 m_mimetypes.insert( tr("All"), QString::null );
496 if( m_selector == Normal ){
497 DocLnkSet set;
498 Global::findDocuments(&set, QString::null );
499 QListIterator<DocLnk> dit( set.children() );
500 for( ; dit.current(); ++dit ){
501 if( !m_mimetypes.contains( (*dit)->type() ) )
502 m_mimetypes.insert( (*dit)->type(), (*dit)->type() );
503 }
504 }// else done in reparse
505 }
506}
507void OFileSelector::initVars()
508{
509 if( m_mimetypes.isEmpty() )
510 m_autoMime = true;
511 else
512 m_autoMime = false;
513
514 m_shClose = false;
515 m_shNew = false;
516 m_shTool = true;
517 m_shPerm = false;
518 m_shLne = true;
519 m_shChooser = true;
520 m_shYesNo = true;
521 m_case = false;
522 m_dir = true;
523 m_files = true;
524 m_showPopup = false;
525 m_mainView = 0l;
526 m_fileView = 0l;
527 m_lister = 0l;
528
529 if(m_pixmaps == 0 ) // init the pixmaps
530 initPics();
531
532 // pointers
533 m_location = 0;
534 m_mimeCheck = 0;
535 m_viewCheck = 0;
536 m_homeButton = 0;
537 m_docButton = 0;
538 m_hideButton = 0;
539 m_ok = 0;
540 m_cancel = 0;
541 m_reread = 0;
542 m_up = 0;
543 m_View = 0;
544 m_checkPerm = 0;
545 m_pseudo = 0;
546 m_pseudoLayout = 0;
547 m_select = 0;
548 m_lay = 0;
549 m_Oselector = 0;
550 m_boxToolbar = 0;
551 m_boxOk = 0;
552 m_boxName = 0;
553 m_boxView = 0;
554 m_edit = 0;
555 m_fnLabel = 0;
556 m_new = 0;
557 m_close = 0;
558}
559void OFileSelector::initializeName()
560{
561 /** Name Layout Line
562 * This is the Layout line arranged in
563 * horizontal way each components
564 * are next to each other
565 * but we will only do this if
566 * we didn't initialize a while ago.
567 */
568 if( m_boxName == 0 ){
569 m_boxName = new QHBox( this ); // remove this this? or use a QHBox
570 m_fnLabel = new QLabel( m_boxName );
571 m_fnLabel->setText( tr("Name:") );
572 m_edit = new QLineEdit( m_boxName );
573 m_edit->setText( m_name );
574 //m_boxName->addWidget( m_fnLabel );
575 m_boxName->setMargin( 5 );
576 m_boxName->setSpacing( 8 );
577 //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor
578
579 m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout
580 }// else we already initialized
581 // maybe show the components?
582 //
583}
584void OFileSelector::initializeYes()
585{
586 /** The Save Cancel bar
587 *
588 */
589 if( m_boxOk == 0 ){
590 m_boxOk = new QHBox( this );
591 m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" );
592 m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" );
593
594 //m_boxOk->addWidget( m_ok );
595 //m_boxOk->addWidget( m_cancel );
596 m_boxOk->setMargin( 5 );
597 m_boxOk->setSpacing( 10 );
598 m_lay->addWidget( m_boxOk, 0 );
599
600 connect( m_ok, SIGNAL( clicked() ),
601 this, SLOT(slotOk() ) );
602 connect( m_cancel, SIGNAL( clicked() ),
603 this, SLOT( slotCancel() ) );
604 }
605}
606/*
607 * OK m_mimeCheck is a QComboBox we now want to fill
608 * out that combobox
609 * if automime we need to update the mimetypes
610 */
611void OFileSelector::updateMimeCheck() {
612 m_mimeCheck->clear();
613 if (m_autoMime ) {
614 //m_mimeCheck->insertItem( tr("All") );
615 updateMimes();
616 }
617
618 QMap<QString, QStringList>::Iterator it;
619 for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) {
620 m_mimeCheck->insertItem( it.key() );
621 }
622}
623
624void OFileSelector::initializeChooser()
625{
626 if( m_boxView == 0 ){
627 m_boxView = new QHBox( this );
628 m_viewCheck = new QComboBox( m_boxView, "view check");
629 m_mimeCheck = new QComboBox( m_boxView, "mime check");
630 m_boxView->setSpacing( 8 );
631 m_lay->addWidget(m_boxView, 0 );
632
633
634 updateMimeCheck();
635 fillList();
636
637 connect( m_viewCheck, SIGNAL( activated(const QString & ) ),
638 this, SLOT( slotViewCheck(const QString & ) ) );
639 connect( m_mimeCheck, SIGNAL( activated(const QString & ) ),
640 this, SLOT( slotMimeCheck( const QString & ) ) );
641 }
642}
643/* generate the buttons for the toolbar */
644void OFileSelector::initToolbar() {
645 m_mainView = new OFileSelectorMain( this );
646
647 /* now generate the tool bar */
648 qWarning( "toolbar" );
649 m_pseudo = new QWidget( m_mainView, "Pseudo Widget" );
650 m_pseudoLayout = new QVBoxLayout( m_pseudo );
651
652 m_boxToolbar = new QHBox( m_pseudo );
653 m_boxToolbar->setSpacing( 0 );
654
655 // tool bar members now
656 m_location = new QComboBox( m_boxToolbar );
657 m_location->setEditable( TRUE );
658 m_location->setDuplicatesEnabled( FALSE );
659 connect( m_location, SIGNAL(activated(const QString& ) ),
660 this, SLOT(slotLocationActivated(const QString& )) );
661 connect( m_location->lineEdit(), SIGNAL(returnPressed() ) ,
662 this, SLOT(locationComboChanged() ) );
663
664 // UP Button
665 m_up = new QPushButton( Resource::loadIconSet("up"), QString::null,
666 m_boxToolbar, "cdUpButton" );
667 m_up->setFixedSize( QSize(20, 20 ) );
668 connect( m_up, SIGNAL( clicked() ), this, SLOT(cdUP() ) );
669 m_up->setFlat( TRUE );
670
671 // Home Button
672 m_homeButton = new QPushButton(Resource::loadIconSet("home"),
673 QString::null, m_boxToolbar );
674 m_homeButton->setFixedSize( QSize(20, 20 ) );
675 connect(m_homeButton, SIGNAL(clicked() ), this, SLOT(slotHome() ) );
676 m_homeButton->setFlat( TRUE );
677
678 // Documents Button
679 m_docButton = new QPushButton( Resource::loadIconSet("DocsIcon"),
680 QString::null, m_boxToolbar,
681 "docsButton" );
682 m_docButton->setFixedSize( QSize(20, 20 ) );
683 m_docButton->setFlat( true );
684 connect( m_docButton, SIGNAL(clicked() ),
685 this, SLOT(slotDoc() ) );
686
687 // close button
688 m_close = new QPushButton( Resource::loadIconSet( "close"), "",
689 m_boxToolbar );
690 connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) );
691 m_close->setFixedSize( 20, 20 );
692
693 m_boxToolbar->setFixedHeight( 20 );
694 m_pseudoLayout->addWidget(m_boxToolbar );
695
696 /* init the locations */
697 initLocations();
698
699 if( !m_shTool ){
700 m_location->hide( );
701 m_up->hide( );
702 m_homeButton->hide( );
703 m_docButton->hide( );
704 }
705 if(!m_shClose )
706 m_close->hide();
707
708 m_mainView->setToolbar( m_pseudo );
709 m_lay->addWidget( m_mainView, 100 );
710}
711/* put default locations into the bar */
712void OFileSelector::initLocations () {
713
714 // let;s fill the Location ComboBox
715 StorageInfo storage;
716 const QList<FileSystem> &fs = storage.fileSystems();
717 QListIterator<FileSystem> it ( fs );
718 for( ; it.current(); ++it ){
719 const QString disk = (*it)->name();
720 const QString path = (*it)->path();
721 m_location->insertItem(path+ "<-"+disk );
722 }
723 int count = m_location->count();
724 m_location->insertItem( m_currentDir );
725 m_location->setCurrentItem( count );
726
727}
728void OFileSelector::initializePerm()
729{
730 if( m_checkPerm == 0 ){
731 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm");
732 m_checkPerm->setChecked( false );
733 m_lay->addWidget( m_checkPerm );
734 }
735}
736void OFileSelector::initPics()
737{
738 m_pixmaps = new QMap<QString,QPixmap>;
739 QPixmap pm = Resource::loadPixmap( "folder" );
740 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
741
742 QPainter painter( &pm );
743 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
744 pm.setMask( pm.createHeuristicMask( FALSE ) );
745 m_pixmaps->insert("dirsymlink", pm );
746
747 QPixmap pm2 = Resource::loadPixmap( "lockedfolder" );
748 QPainter pen(&pm2 );
749 pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk );
750 pm2.setMask( pm2.createHeuristicMask( FALSE ) );
751 m_pixmaps->insert("symlinkedlocked", pm2 );
752}
753// if a mime complies with the m_mimeCheck->currentItem
754bool OFileSelector::compliesMime( const QString &path, const QString &mime )
755{
756 if( mime == "All" )
757 return true;
758 MimeType type( path );
759 if( type.id() == mime )
760 return true;
761 return false;
762}
763/* check if the mimetype in mime
764 * complies with the one which is current
765 */
766/*
767 * We've the mimetype of the file
768 * We need to get the stringlist of the current mimetype
769 *
770 * mime = image/jpeg
771 * QStringList = 'image/*'
772 * or QStringList = image/jpeg;image/png;application/x-ogg
773 * or QStringList = application/x-ogg;image/*;
774 * with all these mime filters it should get acceptes
775 * to do so we need to look if mime is contained inside
776 * the stringlist
777 * if it's contained return true
778 * if not ( I'm no RegExp expert at all ) we'll look if a '/*'
779 * is contained in the mimefilter and then we will
780 * look if both are equal until the '/'
781 */
782bool OFileSelector::compliesMime( const QString& mime ) {
783 qWarning("mimetype is %s", mime.latin1() );
784 QString currentText;
785 if (m_shChooser )
786 currentText = m_mimeCheck->currentText();
787
788 qWarning("current text is %s", currentText.latin1() );
789 QMap<QString, QStringList>::Iterator it;
790 QStringList list;
791 if ( currentText == tr("All") ) return true;
792 else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) {
793 it = m_mimetypes.begin();
794 list = it.data();
795 }else if ( currentText.isEmpty() ) return true;
796 else{
797 it = m_mimetypes.find(currentText );
798 if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText;
799 else qWarning("found"), list = it.data();
800 }
801
802
803 if ( list.contains(mime) ) return true;
804 qWarning("list doesn't contain it ");
805 QStringList::Iterator it2;
806 int pos;
807 for ( it2 = list.begin(); it2 != list.end(); ++it2 ) {
808 pos = (*it2).findRev("/*");
809 if ( pos >= 0 ) {
810 if ( mime.contains( (*it2).left(pos) ) ) return true;
811 }
812 }
813 return false;
814}
815void OFileSelector::slotFileSelected( const QString &string )
816{
817 if( m_shLne )
818 m_edit->setText( string );
819 emit fileSelected( string );
820}
821void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
822{
823 slotFileSelected( lnk.name() );
824 // emit fileSelected( lnk );
825}
826
827
828void OFileSelector::slotDelete()
829{
830 /*
831 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
832 QStringList list = QStringList::split("->", sel->text(1) );
833 if( sel->isDir() ){
834 QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry
835 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0],
836 tr("Yes"),tr("No"),0,1,1) ) {
837 case 0:
838 ::system(str.utf8().data() );
839 break;
840 }
841 } else {
842 QFile::remove( list[0] );
843 }
844 m_View->takeItem( sel );
845 delete sel;
846 */
847}
848void OFileSelector::cdUP()
849{
850 // FIXME won't work on non filesystem based systems
851 // better call the Olister
852 QDir dir( m_currentDir );
853 dir.cdUp();
854 if(dir.exists() ){
855 m_currentDir = dir.absPath();
856 reparse();
857 int count = m_location->count();
858 slotInsertLocationPath( m_currentDir, count);
859 m_location->setCurrentItem( indexByString( m_location, m_currentDir));
860 }
861}
862void OFileSelector::slotHome()
863{
864 cd(QDir::homeDirPath() );
865}
866void OFileSelector::slotDoc()
867{
868 cd(QPEApplication::documentDir() );
869}
870void OFileSelector::slotNavigate( )
871{
872
873}
874// fill the View with life
875void OFileSelector::reparse()
876{
877 if( m_selector == Normal )
878 return;
879
880 currentView()->clear();
881
882 if( m_shChooser)
883 qWarning("reparse %s", m_mimeCheck->currentText().latin1() );
884
885 QString currentMimeType;
886
887 // let's update the mimetype
888 if( m_autoMime ){
889 m_mimetypes.clear();
890 // ok we can change mimetype so we need to be able to give a selection
891 if( m_shChooser ) {
892 currentMimeType = m_mimeCheck->currentText();
893 m_mimeCheck->clear();
894
895 // let's find possible mimetypes
896 m_mimetypes = currentLister()->mimeTypes( m_currentDir );
897
898 // add them to the chooser
899 updateMimeCheck();
900 m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) );
901 currentMimeType = m_mimeCheck->currentText();
902 }
903 }else { // no autoMime
904 // let the mimetype be set from out side the m_mimeCheck FEATURE
905
906 if( m_shChooser )
907 currentMimeType = m_mimeCheck->currentText();
908
909 }
910 // now we got our mimetypes we can add the files
911
912 currentLister()->reparse( m_currentDir );
913 /* we're done with adding let's sort */
914 currentView()->sort();
915
916
917 if( m_shTool ){
918 m_location->insertItem( m_currentDir );
919
920 }
921 // reenable painting and updates
922}
923/* switch lister to @param lister */
924void OFileSelector::setLister(const QString& lister) {
925 QStringList listerList = factory()->lister();
926
927 if (listerList.contains(lister) ) {
928 delete (OLister*) m_lister;
929 m_lister = factory()->lister( lister, this );
930 }else if (!m_lister ) {
931 /*
932 * if we do not have a lister
933 * we need to take the default one
934 */
935 m_lister = new OLocalLister(this);
936 }
937 m_listerName = lister;
938}
939void OFileSelector::setView( const QString& lis ) {
940 qWarning("setView ");
941 fillList();
942 if ( lis == tr("Documents") ) {
943 m_selector = Normal;
944 delete m_lister;
945 delete m_fileView;
946 m_lister = 0l;
947 m_fileView = 0l;
948 initializeOldSelector();
949 }else {
950 qWarning("lis %s", lis.latin1() );
951 QString list;
952
953 delete m_lister;
954 delete m_fileView;
955 delete m_select;
956 m_lister =0l;
957 m_fileView = 0l;
958 m_select = 0l;
959 if ( lis.startsWith("All") ) {
960 m_selector = ExtendedAll;
961 list = lis.mid(4 ).stripWhiteSpace();
962 } else{
963 list = lis;
964 m_selector = Extended;
965 }
966 setLister(m_listerName);
967 m_fileView = factory()->view( list, this, m_mainView );
968 m_mainView->setWidget( m_fileView->widget() );
969 reparse();
970 }
971}
972/*
973 * the factory
974 */
975void OFileSelector::initFactory() {
976 m_fileFactory = new OFileFactory();
977 m_fileFactory->addLister(tr("Files"), newLocalLister );
978 m_fileFactory->addView(tr("List View"), newFileListView );
979 /* dummy entry */
980 m_fileFactory->addView(tr("Documents"), newFileListView );
981}
982
983void OFileSelector::fillList() {
984 qWarning("fill list");
985 if (!m_viewCheck )
986 return;
987
988 m_viewCheck->clear();
989 QStringList list = factory()->views();
990 qWarning("views: " + list.join(";") );
991 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
992 qWarning( (*it) );
993 if ( (*it) == tr("Documents") ) {
994 m_viewCheck->insertItem( (*it) );
995 }else{
996 m_viewCheck->insertItem( (*it) );
997 m_viewCheck->insertItem( tr("All ") + (*it) );
998 }
999 }
1000}
1001OFileFactory* OFileSelector::factory() {
1002 return m_fileFactory;
1003}
1004
1005
1006OFileView* OFileSelector::currentView() {
1007 return m_fileView;
1008}
1009OFileView* OFileSelector::currentView() const{
1010 return m_fileView;
1011}
1012int OFileSelector::filter() {
1013 int filter;
1014 if ( m_selector == ExtendedAll )
1015 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
1016 else
1017 filter = QDir::Files | QDir::Dirs | QDir::All ;
1018
1019 return filter;
1020}
1021int OFileSelector::sorting() {
1022 int sort;
1023
1024 if (m_case )
1025 sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed );
1026 else
1027 sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed );
1028
1029 return sort;
1030}
1031void OFileSelector::internFileSelected( const QString& s) {
1032 emit fileSelected( s );
1033 DocLnk lnk( s );
1034 internFileSelected( lnk );
1035}
1036void OFileSelector::internFileSelected( const DocLnk& d ) {
1037 emit fileSelected( d );
1038}
1039void OFileSelector::internContextMenu() {
1040 emit contextMenu();
1041}
1042void OFileSelector::internChangedDir( const QString& s) {
1043 emit dirSelected( s );
1044 cd(s );
1045}
1046void OFileSelector::internChangedDir( const QDir& s) {
1047 emit dirSelected( s );
1048}
1049QPixmap OFileSelector::pixmap( const QString& s ) {
1050
1051 return (*m_pixmaps)[s];
1052}
1053OLister* OFileSelector::currentLister()const {
1054 return m_lister;
1055}
1056void OFileSelector::initializeOldSelector() {
1057 qWarning("initializeOldSelector");
1058
1059 delete m_select;
1060
1061 // we need to initialize but keep the selected mimetype
1062 /* we default not to show close and new buttons */
1063 QString mime = currentMimeType();
1064 qWarning("MimeType " + mime );
1065 m_select = new FileSelector( mime ,
1066 m_mainView, "fileselector",
1067 FALSE, FALSE);
1068 m_select->setCategorySelectVisible( FALSE );
1069 m_select->setTypeComboVisible( FALSE );
1070
1071 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
1072 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
1073 connect(m_select, SIGNAL(closeMe() ),
1074 this, SIGNAL(closeMe() ) );
1075 //connect to close me and other signals as well
1076 m_mainView->setWidget( m_select );
1077}
1078/*
1079 * initialize the listview
1080 * we will call fillList
1081 * setLister
1082 * with QString::null to get the default
1083 * setView with either Files or All Files
1084 * depending on Extended
1085 */
1086void OFileSelector::initializeView() {
1087 setLister(QString::null);
1088 fillList();
1089 if (m_selector == Extended ) {
1090 setView( tr("List View") );
1091 }else{
1092 setView( tr("All List View") );
1093 }
1094}
1095
diff --git a/libopie/ofileselector/ofileselector.h b/libopie/ofileselector/ofileselector.h
deleted file mode 100644
index 76c3ced..0000000
--- a/libopie/ofileselector/ofileselector.h
+++ b/dev/null
@@ -1,492 +0,0 @@
1/*
2 This is based on code and ideas of
3 L. J. Potter ljp@llornkcor.com
4 Thanks a lot
5
6
7               =. This file is part of the OPIE Project
8             .=l. Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
9           .>+-=
10 _;:,     .>    :=|. This library is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This library is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details.
24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA.
31
32*/
33
34#ifndef opiefileselector_h
35#define opiefileselector_h
36
37#include <qpe/fileselector.h>
38
39#include <qdir.h>
40#include <qguardedptr.h>
41#include <qwidget.h>
42#include <qstring.h>
43#include <qpixmap.h>
44#include <qstringlist.h>
45#include <qmap.h>
46#include <qvaluelist.h>
47
48#include <qpe/applnk.h>
49#include <qlistview.h>
50
51/** This is OPIEs FileDialog Widget. You can use it
52 * as a dropin replacement of the fileselector and
53 * or use any of the new features.
54 * This is also a complete FileSave and FileLoad widget
55 * If you look for a Dialog check OFileDialog
56 *
57 */
58class DocLnk;
59class QCheckBox;
60class QComboBox;
61class QPushButton;
62class QGridLayout;
63class QLineEdit;
64class QLabel;
65class QWidgetStack;
66class QHBoxLayout;
67class QVBoxLayout;
68class QPopupMenu;
69class QFileInfo;
70class QHBox;
71class OFileView;
72class OLister;
73class OFileSelectorMain;
74class OFileFactory;
75//
76
77/* the mimetypes one name and a list of mimetypes */
78typedef QMap< QString, QStringList> MimeTypes;
79
80/**
81 * FIXME later
82 */
83struct OPopupMenuFactory {
84 OPopupMenuFactory() {}
85
86};
87
88
89/**
90 * Opie the default OFileSelector
91 * It features multiple views.
92 */
93class OFileSelector : public QWidget {
94 Q_OBJECT
95
96 /* friends are evil but I don't want to make the
97 * methods public
98 */
99 friend class OLister;
100 friend class OFileView;
101 public:
102 /**
103 * The mode of the file selector
104 * Either open, save, fileselector or dir browsing mode
105 *
106 */
107 enum Mode {Open = 1, Save = 2, Fileselector = 4, Dir = 8 };
108
109 /**
110 * Selector. Either Normal for the one shipped with
111 * libqpe or Extended. for the Extended
112 * ExtendedAll also shows 'hidden' files
113 */
114 enum Selector{Normal=0, Extended = 1, ExtendedAll = 2};
115
116 /**
117 * This is reserved for futrue views
118 */
119 enum View { Dirs = 1, Files = 2, Tree = 4, Icon = 8 };
120
121 /**
122 * A c'tor which should be used for advanced mode
123 * @param wid the parent
124 * @param mode the Mode of the Selector
125 * @param selector the current View of the Selector
126 * @param dirName in which dir to start
127 * @param fileName a proposed filename
128 * @param mimetypes A list of mimetypes \
129 * QString is for a identifier name like "Text files"
130 * the coresponding QStringList is used for the mimetypes
131 * if empty it'll fill the list of mimetypes depending
132 * on the content of the current directory
133 */
134
135 OFileSelector(QWidget *wid, int mode, int selector,
136 const QString &dirName,
137 const QString &fileName = QString::null,
138 const MimeTypes &mimetypes = MimeTypes() );
139
140
141 /**
142 * This is a QPE compatible c'tor
143 */
144 OFileSelector(const QString &mimeFilter, QWidget *parent,
145 const char *name, bool newVisible = TRUE,
146 bool closeVisible = FALSE );
147
148 ~OFileSelector();
149
150 // currently only for the FileSelector Mode
151 /* compability mode but only work
152 * with FileSelector
153 */
154 void setNewVisible( bool /*b*/ );
155 void setCloseVisible(bool /*b*/ );
156
157 // end file selector mode
158 // deprecated
159 void reread();
160 // make sure not to leak please
161 const DocLnk *selected();
162 // end deprecated
163
164 /**
165 * @return if the toolbar is visible
166 */
167 bool isToolbarVisible() const { return m_shTool; };
168
169 /**
170 * @return if the permissionBas is visible
171 */
172 bool isPermissionBarVisible() const { return m_shPerm; };
173
174 /**
175 * @return if the lineEdit is visible
176 */
177 bool isLineEditVisible()const { return m_shLne; };
178
179 /**
180 * if the chooser is visible
181 */
182 bool isChooserVisible( )const { return m_shChooser; };
183
184 /**
185 * @return if the yesCancel Bar is visible
186 */
187 bool isYesCancelVisible()const { return m_shYesNo; };
188
189 /**
190 * set Yes/Cancel visible
191 */
192 void setYesCancelVisible( bool show );
193
194 /**
195 * set the toolbar visible
196 */
197 void setToolbarVisible( bool show );
198
199 /**
200 * set the permissionBar to be visible
201 */
202 void setPermissionBarVisible( bool show );
203
204 /**
205 * set the lineedit for file entering visible
206 */
207 void setLineEditVisible(bool show) ;
208
209 /**
210 * set the chooser is visible
211 */
212 void setChooserVisible( bool chooser );
213
214 /**
215 * The permissionCheckbox
216 *
217 */
218 QCheckBox* permissionCheckbox();
219
220 /**
221 * setPermission
222 */
223 bool setPermission() const;
224
225 /**
226 * set ther permission to bool
227 */
228 void setPermissionChecked( bool check );
229
230 /**
231 * set the Selector Mode
232 */
233 void setMode( int );
234
235 void setLister( const QString& name );
236 void setView( const QString& all );
237 /**
238 * whether or not to show dirs
239 */
240 bool showDirs()const { return m_dir; }
241
242 /**
243 * setShowDirs
244 */
245 void setShowDirs(bool );
246
247 /**
248 * set CaseSensetive
249 */
250 bool isCaseSensetive()const { return m_case; }
251
252 /**
253 * set if to be case sensetive
254 */
255 void setCaseSensetive(bool caSe );
256
257 /**
258 * @return if to show files
259 */
260 bool showFiles()const { return m_files; };
261
262 /**
263 * set if files should be shown
264 */
265 void setShowFiles(bool );
266
267 /**
268 * change dir to path
269 */
270 bool cd(const QString &path );
271
272
273 /**
274 * return the mode of the fileselector
275 */
276 int mode()const { return m_mode; };
277
278 /**
279 * return the selector
280 */
281 int selector()const { return m_selector; };
282
283 /**
284 * set the Selector
285 */
286 void setSelector( int );
287
288 /**
289 * wether or not to show popups
290 */
291 bool showPopup()const { return m_showPopup; };
292
293 /**
294 * set show popups
295 */
296 void setShowPopup( bool pop ) { m_showPopup = pop; }
297
298 /**
299 * set the popup factory
300 */
301 void setPopupFactory( OPopupMenuFactory * );
302
303 /**
304 * reparse the current directory and updates
305 * the views + mimetypes
306 */
307 void reparse(); // re reads the dir
308
309 /**
310 * return the selected name
311 */
312 QString selectedName( )const;
313
314 /**
315 * for multiple selections return multiple
316 * filenames
317 */
318 QStringList selectedNames()const;
319
320 /**
321 * return the complete to the file
322 */
323 QString selectedPath() const;
324
325 /**
326 * return the completed paths
327 */
328 QStringList selectedPaths() const;
329
330 /**
331 * the current directory
332 */
333 QString directory()const;
334
335 /**
336 * fileCount
337 */
338 int fileCount();
339
340 DocLnk selectedDocument()const;
341
342 QValueList<DocLnk> selectedDocuments()const;
343
344 OFileView* currentView();
345 OFileView* currentView()const;
346 OLister* currentLister()const;
347 OFileFactory* factory();
348 int filter();
349 int sorting();
350 QPixmap pixmap( const QString& );
351 /* our tool bar */
352 QWidget* toolBar();
353
354 signals:
355 void fileSelected( const DocLnk & );
356 void fileSelected( const QString & );
357 void dirSelected(const QString &dir );
358 void dirSelected( const QDir& );
359 void closeMe();
360 void ok();
361 void cancel();
362 void contextMenu();
363
364 private slots:
365 void slotOk();
366 void slotCancel();
367 void slotViewCheck(const QString & );
368 void slotMimeCheck(const QString & );
369 void slotLocationActivated(const QString & );
370 void slotInsertLocationPath(const QString &, int);
371 void locationComboChanged();
372
373 private:
374 void init();
375 void updateMimes();
376
377
378 private:
379
380 OFileFactory* m_fileFactory;
381 OFileSelectorMain* m_mainView;
382 OLister* m_lister;
383 QString m_listerName;
384 OFileView* m_fileView;
385 FileSelector* m_select;
386 int m_mode, m_selector;
387 QComboBox *m_location,
388 *m_mimeCheck,
389 *m_viewCheck;
390
391 QPushButton *m_homeButton,
392 *m_docButton,
393 *m_hideButton,
394 *m_ok, *m_cancel;
395 QPushButton *m_reread,
396 *m_up,
397 *m_new,
398 *m_close;
399 QListView *m_View;
400 QCheckBox *m_checkPerm;
401 QWidget *m_pseudo;
402 QVBoxLayout *m_pseudoLayout;
403
404 QString m_currentDir;
405 QString m_name;
406
407 QMap<QString, QStringList> m_mimetypes;
408
409 QVBoxLayout *m_lay;
410 QGridLayout *m_Oselector;
411
412 QHBox *m_boxToolbar;
413 QHBox *m_boxOk;
414 QHBox *m_boxName;
415 QHBox *m_boxView;
416
417
418 QLineEdit *m_edit;
419 QLabel *m_fnLabel;
420
421 bool m_shClose : 1;
422 bool m_shNew : 1;
423 bool m_shTool : 1;
424 bool m_shPerm : 1;
425 bool m_shLne : 1;
426 bool m_shChooser : 1;
427 bool m_shYesNo : 1;
428 bool m_boCheckPerm : 1;
429 bool m_autoMime : 1;
430 bool m_case : 1;
431 bool m_dir : 1;
432 bool m_files : 1;
433 bool m_showPopup : 1;
434 bool m_showHidden : 1;
435
436 void initVars();
437
438 void delItems();
439 void initializeName();
440 void initializeYes();
441 void initializeChooser();
442 void initializePerm();
443 void initPics();
444 bool compliesMime(const QString &path,
445 const QString &mime);
446 bool compliesMime(const QString& mime );
447 /**
448 * Updates the QComboBox with the current mimetypes
449 */
450 void updateMimeCheck();
451
452 void initializeOldSelector();
453 void initToolbar();
454 void initLocations();
455 void initializeView(); // FIXME
456 void fillList();
457 void initFactory();
458 /**
459 * Returns the current mimetype
460 */
461 QString currentMimeType()const;
462 class OFileSelectorPrivate;
463 OFileSelectorPrivate *d;
464 static QMap<QString,QPixmap> *m_pixmaps;
465
466private slots:
467 void slotFileSelected(const QString & ); // not really meant to be a slot
468 void slotFileBridgeSelected( const DocLnk & );
469 // listview above
470 // popup below
471 virtual void slotDelete();
472 virtual void cdUP();
473 virtual void slotHome();
474 virtual void slotDoc();
475 virtual void slotNavigate( );
476
477 /* for OLister */
478private:
479
480 /* for OFileView */
481private:
482 void internFileSelected( const QString& );
483 void internFileSelected( const DocLnk& );
484 void internContextMenu();
485 void internChangedDir( const QString& );
486 void internChangedDir( const QDir& ) ;
487
488};
489
490
491#endif
492
diff --git a/libopie/ofileselector/ofileselectoritem.cpp b/libopie/ofileselector/ofileselectoritem.cpp
deleted file mode 100644
index 4ef8fe3..0000000
--- a/libopie/ofileselector/ofileselectoritem.cpp
+++ b/dev/null
@@ -1,58 +0,0 @@
1#include "ofileselectoritem.h"
2
3OFileSelectorItem::OFileSelectorItem( QListView*view,
4 const QPixmap& pix,
5 const QString& path,
6 const QString& date,
7 const QString& size,
8 const QString& dir,
9 bool isLocked,
10 const QString& extra,
11 bool isDir )
12 : QListViewItem( view )
13{
14 setPixmap( 0, pix );
15 setText( 1, path );
16 setText( 2, size );
17 setText( 3, date );
18 m_dir = isDir;
19 m_locked = isLocked;
20 m_dirStr = dir;
21 m_extra = extra;
22}
23OFileSelectorItem::~OFileSelectorItem() {
24}
25bool OFileSelectorItem::isLocked()const {
26 return m_locked;
27}
28QString OFileSelectorItem::directory()const {
29 return m_dirStr;
30}
31bool OFileSelectorItem::isDir()const {
32 return m_dir;
33}
34QString OFileSelectorItem::path() const {
35 return text(1);
36}
37QString OFileSelectorItem::key( int id, bool ) {
38 QString ke;
39
40 if( id == 0 || id == 1 ){ // name
41 if( m_dir ){
42 ke.append("0" );
43 ke.append( text(1) );
44 }else{
45 ke.append("1" );
46 ke.append( text(1) );
47 }
48 }else if( id == 2 ){ // size
49 return text(2);
50 }else if( id == 3 ){ // date
51 return text(3);
52 }
53
54 return ke;
55}
56QString OFileSelectorItem::extra()const {
57 return m_extra;
58}
diff --git a/libopie/ofileselector/ofileselectoritem.h b/libopie/ofileselector/ofileselectoritem.h
deleted file mode 100644
index 81966ae..0000000
--- a/libopie/ofileselector/ofileselectoritem.h
+++ b/dev/null
@@ -1,35 +0,0 @@
1#ifndef OPIE_FILE_SELECTOR_ITEM_H
2#define OPIE_FILE_SELECTOR_ITEM_H
3
4#include <qlistview.h>
5
6class OFileSelectorItem : public QListViewItem {
7public:
8 OFileSelectorItem( QListView* view,
9 const QPixmap&,
10 const QString& path,
11 const QString& date,
12 const QString& size,
13 const QString& dir,
14 bool isLocked,
15 const QString& extra,
16 bool isDir = false);
17 ~OFileSelectorItem();
18 bool isLocked() const;
19 QString directory()const;
20 bool isDir()const;
21 QString path()const;
22 QString key(int id, bool );
23 QString extra()const;
24
25private:
26 bool m_locked : 1;
27 bool m_dir : 1;
28 QString m_dirStr;
29 QString m_extra;
30
31 class Private;
32 Private* d;
33};
34
35#endif
diff --git a/libopie/ofileselector/ofileselectormain.cpp b/libopie/ofileselector/ofileselectormain.cpp
deleted file mode 100644
index dd3b08c..0000000
--- a/libopie/ofileselector/ofileselectormain.cpp
+++ b/dev/null
@@ -1,41 +0,0 @@
1#include <qwidgetstack.h>
2#include <qlayout.h>
3
4#include "ofileselectormain.h"
5
6OFileSelectorMain::OFileSelectorMain( QWidget* parent )
7 : QWidget( parent ), m_tool(0)
8{
9 m_lay = 0;
10 init();
11}
12OFileSelectorMain::~OFileSelectorMain() {
13
14}
15void OFileSelectorMain::setToolbar( QWidget* tool ) {
16 delete m_tool;
17 m_tool = tool;
18 add();
19}
20void OFileSelectorMain::setWidget( QWidget* wid ) {
21 static int i = 0;
22 m_stack->addWidget( wid, i );
23 m_stack->raiseWidget( i );
24 i++;
25}
26void OFileSelectorMain::add() {
27 qWarning("adding items ");
28 if (m_tool )
29 m_lay->addWidget( m_tool, 0, 0 );
30
31}
32void OFileSelectorMain::init() {
33 delete m_lay;
34
35 m_lay = new QGridLayout( this, 2, 1 );
36 m_lay->setRowStretch( 0, 1 );
37 m_lay->setRowStretch( 1, 500 );
38
39 m_stack = new QWidgetStack( this );
40 m_lay->addWidget( m_stack, 1, 0 );
41}
diff --git a/libopie/ofileselector/ofileselectormain.h b/libopie/ofileselector/ofileselectormain.h
deleted file mode 100644
index b540b9a..0000000
--- a/libopie/ofileselector/ofileselectormain.h
+++ b/dev/null
@@ -1,23 +0,0 @@
1#ifndef OPIE_FILESELECTOR_MAIN_H
2#define OPIE_FILESELECTOR_MAIN_H
3
4#include <qwidget.h>
5
6class QGridLayout;
7class QWidgetStack;
8class OFileSelectorMain : public QWidget {
9 Q_OBJECT
10public:
11 OFileSelectorMain( QWidget* parent );
12 ~OFileSelectorMain();
13 void setToolbar( QWidget* tool );
14 void setWidget( QWidget* view );
15private:
16 void init();
17 void add();
18 QGridLayout *m_lay;
19 QWidget* m_tool;
20 QWidgetStack *m_stack;
21};
22
23#endif
diff --git a/libopie/ofileselector/ofileview.cpp b/libopie/ofileselector/ofileview.cpp
deleted file mode 100644
index 4203ca3..0000000
--- a/libopie/ofileselector/ofileview.cpp
+++ b/dev/null
@@ -1,32 +0,0 @@
1#include <qlineedit.h>
2
3#include <qpe/applnk.h>
4
5#include "ofileselector.h"
6#include "olister.h"
7#include "ofileview.h"
8
9
10
11OFileView::OFileView( OFileSelector* sel)
12 : m_sel( sel )
13{
14}
15OFileView::~OFileView() {
16}
17void OFileView::fileSelected( const QString& dir,const QString& file,const QString& extra ) {
18 m_sel->currentLister()->fileSelected( dir,file,extra );
19}
20void OFileView::contextMenu() {
21 m_sel->internContextMenu();
22}
23void OFileView::changedDir( const QString& s, const QString& file, const QString& extra) {
24 m_sel->currentLister()->changedDir( s, file,extra );
25}
26OFileSelector* OFileView::selector() const {
27 return m_sel;
28}
29void OFileView::updateLine( const QString& str ) {
30 if (m_sel->m_shLne )
31 m_sel->m_edit->setText( str );
32}
diff --git a/libopie/ofileselector/ofileview.h b/libopie/ofileselector/ofileview.h
deleted file mode 100644
index e84a3e1..0000000
--- a/libopie/ofileselector/ofileview.h
+++ b/dev/null
@@ -1,140 +0,0 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 zecke <zecke@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef ofileview_h
30#define ofileview_h
31
32#include <qobject.h>
33#include <qwidget.h>
34#include <qpopupmenu.h>
35
36class QFileInfo;
37class QDir;
38class DocLnk;
39
40/**
41 * A OFileView is a specialised View for the
42 * OFileSelector
43 * With a View you can chage the user visible
44 * representation of a OFileLister
45 * OFileView is just a basic interface which helps you to
46 * write new views
47 */
48class OFileSelector;
49class OFileView {
50public:
51 OFileView( OFileSelector* );
52 OFileView();
53 virtual ~OFileView();
54
55 virtual void clear() = 0;
56 virtual void addFile(const QPixmap&,
57 const QString &mine,
58 QFileInfo *info,
59 const QString& extra = QString::null,
60 bool isSymlink = FALSE ) = 0;
61
62 virtual void addFile(const QPixmap&,
63 const QString& mine, const QString& dir,
64 const QString& file,
65 const QString& extra = QString::null,
66 bool = FALSE ) = 0;
67
68 virtual void addDir (const QPixmap&,
69 const QString &mine,
70 QFileInfo *info,
71 const QString& extra = QString::null,
72 bool isSymlink = FALSE ) = 0;
73 virtual void addDir (const QPixmap&,
74 const QString& mine, const QString& dir,
75 const QString& file,
76 const QString& extra = QString::null,
77 bool = FALSE) = 0;
78
79 virtual void addSymlink(const QPixmap&,
80 const QString &mime,
81 QFileInfo *info,
82 const QString& extra = QString::null,
83 bool isSymlink = FALSE ) = 0;
84
85 virtual void addSymlink(const QPixmap&,
86 const QString& mine,
87 const QString& path,
88 const QString& file,
89 const QString& extra = QString::null,
90 bool isSymlink = FALSE ) = 0;
91
92 virtual void cd(const QString &path ) = 0;
93 virtual QWidget* widget() = 0;
94
95 virtual QString selectedName()const = 0;
96 virtual QStringList selectedNames()const = 0;
97 virtual QString selectedPath()const = 0;
98 virtual QStringList selectedPaths()const = 0;
99 virtual QString selectedExtra()const = 0;
100 virtual int fileCount() = 0;
101 virtual void sort() =0;
102
103/*signals:*/
104protected:
105
106 /**
107 * @param dir The dir name
108 * @param file The file name
109 * @param extra The extra information
110 */
111 void fileSelected(const QString &dir, const QString& file, const QString& extra = QString::null);
112 void contextMenu();
113
114 /**
115 *
116 * @param dir The dir name
117 * @param file The file name
118 * @param extra The extra informations
119 */
120 void changedDir(const QString &dir, const QString& file, const QString& extra = QString::null);
121
122 /* updates the file name line of the FileSelector */
123 void updateLine( const QString& );
124 OFileSelector* selector()const;
125
126private:
127 OFileSelector* m_sel;
128};
129
130class OFileViewFactory {
131 public:
132 OFileViewFactory() {} ;
133 virtual ~OFileViewFactory() = 0;
134
135 OFileView* newView(QWidget *parent, const char *name );
136 QString name()const;
137};
138
139
140#endif
diff --git a/libopie/ofileselector/olister.cpp b/libopie/ofileselector/olister.cpp
deleted file mode 100644
index aaaf6a2..0000000
--- a/libopie/ofileselector/olister.cpp
+++ b/dev/null
@@ -1,181 +0,0 @@
1#include <qcombobox.h>
2#include <qlineedit.h>
3
4#include "olister.h"
5#include "ofileview.h"
6#include "opixmapprovider.h"
7#include "ofileselector.h"
8
9
10OLister::OLister( OFileSelector* view)
11 : m_view( view ), m_acc( 0l )
12{
13 m_prov = new OPixmapProvider( view );
14}
15OLister::~OLister() {
16 delete m_prov;
17}
18void OLister::setPixmapProvider( OPixmapProvider* prov ) {
19 delete m_prov;
20 m_prov = prov;
21}
22bool OLister::showFiles()const {
23 return m_view->showFiles();
24}
25bool OLister::showDirs()const {
26 return m_view->showDirs();
27}
28void OLister::addFile( const QString& mine,
29 QFileInfo* info,
30 const QString& extra,
31 bool isSymlink ) {
32 int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink :
33 OPixmapProvider::File;
34 QPixmap pix = provider()->pixmap(t, mine,
35 info);
36 view()->currentView()->addFile( pix,
37 mine,
38 info,
39 extra,
40 isSymlink );
41}
42void OLister::addFile( const QString& mine,
43 const QString& path,
44 const QString& file,
45 const QString& extra,
46 bool isSymlink ) {
47 int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink :
48 OPixmapProvider::File;
49
50 QPixmap pix = provider()->pixmap(t, mine, path, file );
51 view()->currentView()->addFile( pix,
52 mine,
53 path,
54 file,
55 extra,
56 isSymlink );
57}
58void OLister::addDir( const QString& mine,
59 QFileInfo* info,
60 const QString& extra,
61 bool isSymlink ) {
62 int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink :
63 OPixmapProvider::Dir;
64 QPixmap pix = provider()->pixmap(t, mine, info );
65 view()->currentView()->addDir( pix,
66 mine,
67 info,
68 extra,
69 isSymlink );
70}
71void OLister::addDir( const QString& mine,
72 const QString& path,
73 const QString& dir,
74 const QString& extra,
75 bool isSymlink ) {
76
77 int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink :
78 OPixmapProvider::Dir;
79 QPixmap pix = provider()->pixmap(t, mine, path, dir );
80
81 view()->currentView()->addDir( pix,
82 mine,
83 path,
84 dir,
85 extra,
86 isSymlink );
87}
88void OLister::addSymlink( const QString& mine,
89 QFileInfo* info,
90 const QString& extra,
91 bool isSymlink ) {
92 QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, info );
93 view()->currentView()->addSymlink( pix,
94 mine,
95 info,
96 extra,
97 isSymlink );
98}
99void OLister::addSymlink( const QString& mine,
100 const QString& path,
101 const QString& name,
102 const QString& extra,
103 bool isSymlink ) {
104 QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine,
105 path, name );
106 view()->currentView()->addSymlink( pix,
107 mine,
108 path,
109 name,
110 extra,
111 isSymlink );
112}
113OFileSelector* OLister::view() {
114 return m_view;
115}
116OFileSelector* OLister::view()const {
117 return m_view;
118}
119OPixmapProvider* OLister::provider() {
120 return m_prov;
121}
122bool OLister::compliesMime( const QString& mime ) {
123 return view()->compliesMime( mime );
124}
125void OLister::internFileSelected( const QString& dir ) {
126 view()->internFileSelected( dir );
127}
128void OLister::internChangedDir( const QString& dir ) {
129 view()->internChangedDir( dir );
130}
131OListerCmbAccess* OLister::comboBox() {
132 if (!m_acc )
133 m_acc = new OListerCmbAccess( view()->m_location );
134
135 return m_acc;
136}
137
138
139OListerCmbAccess::OListerCmbAccess(QComboBox* cmb )
140 : m_cmb( cmb )
141{}
142OListerCmbAccess::~OListerCmbAccess() {
143}
144void OListerCmbAccess::clear() {
145 if ( m_cmb )
146 m_cmb->clear();
147}
148void OListerCmbAccess::setCurrentItem( const QString& add, bool FORCE_ADD) {
149 if ( !m_cmb ) return;
150
151
152 int c = m_cmb->count();
153 for ( int i = 0; i < m_cmb->count(); i++ ) {
154 if ( m_cmb->text(i) == add ) {
155 m_cmb->setCurrentItem( i );
156 return;
157 }
158 }
159 if (!FORCE_ADD ) return;
160
161
162 m_cmb->insertItem(add );
163 m_cmb->setCurrentItem( c );
164}
165void OListerCmbAccess::insert( const QString& str ) {
166 if ( m_cmb )
167 m_cmb->insertItem( str );
168}
169QString OListerCmbAccess::currentText()const {
170 QString str;
171 if (m_cmb )
172 str = m_cmb->currentText();
173
174 return str;
175}
176QString OLister::lineEdit()const {
177 if ( view()->m_shLne )
178 return view()->m_edit->text();
179
180 return QString::null;
181}
diff --git a/libopie/ofileselector/olister.h b/libopie/ofileselector/olister.h
deleted file mode 100644
index 4adb9f8..0000000
--- a/libopie/ofileselector/olister.h
+++ b/dev/null
@@ -1,144 +0,0 @@
1#ifndef OPIE_FILE_LISTER_H
2#define OPIE_FILE_LISTER_H
3
4#include <qfileinfo.h>
5#include <qmap.h>
6#include <qstring.h>
7#include <qstringlist.h>
8
9class QComboBox;
10class OPixmapProvider;
11class OFileSelector;
12
13class OListerCmbAccess;
14/**
15 * lister is something like KIO but very
16 * very basic and currently only for
17 * populating our views.
18 * This is a base class which needs to be implemented.
19 * @see OLocalLister for a filesystem based implementation
20 */
21
22class OLister {
23public:
24 OLister( OFileSelector* );
25 virtual ~OLister();
26
27 /**
28 * if path == QString::null reread current dir
29 */
30 virtual void reparse(const QString& path = QString::null ) = 0;
31
32 /**
33 * return a list of available mimetypes
34 */
35 virtual QMap<QString, QStringList> mimeTypes( const QString& dir ) = 0;
36 void setPixmapProvider( OPixmapProvider* );
37
38
39 /* some way a slot */
40 virtual void fileSelected( const QString& dir, const QString& file, const QString& extra ) = 0;
41 virtual void changedDir( const QString& dir, const QString& file, const QString& extra ) = 0;
42 virtual QString selectedName()const = 0;
43 virtual QStringList selectedNames()const = 0;
44protected:
45 /**
46 * I hate too big classes
47 * this is a way to group
48 * access to a ComboBox
49 * which might exist or
50 * not in a secure way
51 */
52 OListerCmbAccess* comboBox();
53
54 bool showFiles()const;
55 bool showDirs()const;
56 bool compliesMime( const QString& mime );
57 void addFile( const QString& mine,
58 QFileInfo*,
59 const QString& extra = QString::null,
60 bool isSymlink = FALSE );
61
62 void addFile( const QString& mine,
63 const QString& path,
64 const QString& file,
65 const QString& extra = QString::null,
66 bool isSymlink = FALSE );
67 void addDir( const QString& mine,
68 QFileInfo*,
69 const QString& extra = QString::null,
70 bool isSymlink = FALSE );
71 void addDir( const QString& mine,
72 const QString& path,
73 const QString& dir,
74 const QString& extra = QString::null,
75 bool isSymlink = FALSE );
76 void addSymlink( const QString& mine,
77 QFileInfo* info,
78 const QString& extra = QString::null,
79 bool isSymlink = FALSE);
80 void addSymlink( const QString& mine,
81 const QString& path,
82 const QString& name,
83 const QString& extra = QString::null,
84 bool isSymlink = FALSE );
85 OFileSelector* view();
86 OFileSelector* view()const;
87 OPixmapProvider* provider();
88 void internFileSelected( const QString& file );
89 void internChangedDir( const QString& dir );
90
91 /**
92 * try to take
93 * the text from the mainwindows
94 * lineedit
95 * if it's not available QString::null
96 * will be returned
97 */
98 QString lineEdit()const;
99private:
100 OFileSelector* m_view;
101 OPixmapProvider* m_prov;
102 OListerCmbAccess* m_acc;
103
104 class Private;
105 Private *d;
106};
107
108class OListerCmbAccess {
109 friend class OLister;
110public:
111 OListerCmbAccess( QComboBox* = 0l);
112 ~OListerCmbAccess();
113
114 /**
115 * clears the combobox
116 */
117 void clear();
118
119 /**
120 * set's @param add to be the current Item
121 * if the item is not present it'll be removed
122 */
123 void setCurrentItem( const QString& add, bool FORECE_ADD = TRUE );
124
125 /**
126 * inserts the the String at
127 * a non predictable position... The position is determined
128 * by the QComboBox code
129 */
130 void insert( const QString& );
131
132 /**
133 *
134 */
135 QString currentText()const;
136
137private:
138 class Private;
139 Private* d;
140 QComboBox* m_cmb;
141
142};
143
144#endif
diff --git a/libopie/ofileselector/olocallister.cpp b/libopie/ofileselector/olocallister.cpp
deleted file mode 100644
index 4d36d64..0000000
--- a/libopie/ofileselector/olocallister.cpp
+++ b/dev/null
@@ -1,150 +0,0 @@
1#include <qdir.h>
2#include <qfileinfo.h>
3#include <qmap.h>
4
5#include <qpe/mimetype.h>
6
7#include "ofileselector.h"
8#include "ofileview.h"
9#include "olocallister.h"
10
11OLocalLister::OLocalLister( OFileSelector* file )
12 : OLister( file )
13{
14 m_dir = QDir::homeDirPath();
15}
16OLocalLister::~OLocalLister() {
17}
18
19QMap<QString, QStringList> OLocalLister::mimeTypes( const QString& curDir ) {
20 QMap<QString, QStringList> mimes;
21
22 // let's find possible mimetypes
23 QDir dir( curDir );
24 dir.setFilter( QDir::Files | QDir::Readable );
25 dir.setSorting( QDir::Size );
26
27 const QFileInfoList *list = dir.entryInfoList();
28 QFileInfoListIterator it( *list );
29 QFileInfo *fi;
30
31 while( (fi=it.current() ) ) {
32 /* skip .desktop */
33 if( fi->extension() == QString::fromLatin1("desktop") ){
34 ++it;
35 continue;
36 }
37 MimeType type( fi->absFilePath() );
38
39 if( !mimes.contains( type.id() ) ){
40 mimes.insert( type.id(), type.id() );
41 }
42
43 ++it;
44 }
45
46 return mimes;
47}
48/**
49 * FIXME mimecheck
50 * use mime check for that
51 * filter dirs
52 * filter filters
53 * filter files
54 * filter mimetypes
55 */
56void OLocalLister::reparse( const QString& pa ) {
57 if (!pa.isEmpty() )
58 m_dir = pa;
59
60 QString currentMimeType;
61 QDir dir( m_dir );
62
63 dir.setSorting( view()->sorting() );
64 dir.setFilter( view()->filter() );
65
66
67 const QFileInfoList *list = dir.entryInfoList();
68 QFileInfoListIterator it( *list );
69 QFileInfo *fi;
70
71 while( (fi=it.current() ) ){
72
73 if( fi->fileName() == QString::fromLatin1("..") ||
74 fi->fileName() == QString::fromLatin1(".") ){
75 ++it;
76 continue;
77 }
78 if( fi->isSymLink() ){
79 QString file = fi->dirPath( true ) + "/" + fi->readLink();
80 /*
81 * 5 tries to prevent dos attack
82 */
83 for( int i = 0; i<=4; i++) {
84 QFileInfo info( file );
85 if( !info.exists() ){
86 addSymlink( currentMimeType, fi, QString::null, TRUE );
87 break;
88 }else if( info.isDir() ){
89 if (!showDirs() )
90 break;
91
92 addDir( currentMimeType, fi, QString::null,
93 TRUE );
94 break;
95 }else if( info.isFile() ){
96 /* if not show files skip it */
97 if (!showFiles() )
98 break;
99
100 /* check if we comply to the mimetype */
101 MimeType type( info.absFilePath() );
102 if (compliesMime( type.id() ) )
103 addFile( currentMimeType, fi, QString::null, TRUE );
104
105 break;
106 }else if( info.isSymLink() ){
107 file = info.dirPath(true ) + "/" + info.readLink() ;
108 break;
109 }else if( i == 4){
110 addSymlink( currentMimeType, fi );
111 }
112 }
113
114 }else if( fi->isDir() ){
115 if (showDirs() )
116 addDir( currentMimeType, fi );
117 }else if( fi->isFile() ){
118 if ( showFiles() )
119 addFile( currentMimeType, fi );
120 }
121 ++it;
122 } // of while loop
123}
124/* more accepting it code */
125void OLocalLister::fileSelected( const QString& dir, const QString& file, const QString& ) {
126 internFileSelected( dir + "/" + file );
127}
128void OLocalLister::changedDir( const QString& dir, const QString& file, const QString& ) {
129 internChangedDir( dir + "/" + file );
130}
131/*
132 * assemble the the Url now
133 */
134QString OLocalLister::selectedName()const {
135 QString str = m_dir;
136 QString name = lineEdit();
137
138 if ( name.isEmpty() )
139 name = view()->currentView()->selectedName();
140
141 str += "/" + name;
142
143 return str;
144}
145QStringList OLocalLister::selectedNames()const {
146 QStringList list;
147 list << selectedName();
148
149 return list;
150}
diff --git a/libopie/ofileselector/olocallister.h b/libopie/ofileselector/olocallister.h
deleted file mode 100644
index 0cdf51f..0000000
--- a/libopie/ofileselector/olocallister.h
+++ b/dev/null
@@ -1,21 +0,0 @@
1#ifndef OPIE_LOCAL_LISTER
2#define OPIE_LOCAL_LISTER
3
4#include "olister.h"
5
6class OLocalLister : public OLister {
7public:
8 OLocalLister( OFileSelector* );
9 ~OLocalLister();
10 void reparse( const QString& path );
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& );
14 QString selectedName()const;
15 QStringList selectedNames()const;
16
17private:
18 QString m_dir;
19};
20
21#endif
diff --git a/libopie/ofileselector/opixmapprovider.cpp b/libopie/ofileselector/opixmapprovider.cpp
deleted file mode 100644
index b363e01..0000000
--- a/libopie/ofileselector/opixmapprovider.cpp
+++ b/dev/null
@@ -1,83 +0,0 @@
1#include <qfileinfo.h>
2
3#include <qpe/mimetype.h>
4#include <qpe/resource.h>
5
6#include "opixmapprovider.h"
7
8
9
10OPixmapProvider::OPixmapProvider( OFileSelector* sel )
11 : m_sel( sel ){
12}
13OPixmapProvider::~OPixmapProvider() {
14}
15QPixmap OPixmapProvider::pixmap( int t, const QString& ,
16 QFileInfo* info, bool isL ) {
17 QPixmap pix;
18 bool sy = t & Symlink ? true : false;
19 switch (t ) {
20 case File:
21 pix = file( info, sy, isL );
22 break;
23 case Dir:
24 pix = dir( info, sy, isL );
25 break;
26 case Symlink:
27 pix = sym( info, isL );
28 break;
29 }
30 return pix;
31
32}
33QPixmap OPixmapProvider::pixmap( int t, const QString& mime,
34 const QString& dir, const QString& file,
35 bool isL) {
36 QFileInfo *inf = new QFileInfo( dir + "/" + file );
37 QPixmap pix = pixmap( t, mime, inf, isL );
38 delete inf;
39 return pix;
40}
41OFileSelector* OPixmapProvider::selector() {
42 return m_sel;
43}
44QPixmap OPixmapProvider::file( QFileInfo* inf, bool , bool ) {
45 MimeType type( inf->absFilePath() );
46 QPixmap pix = type.pixmap();
47
48 if ( pix.isNull() )
49 pix = Resource::loadPixmap( "UnknownDocument-14");
50
51 if ( (selector()->mode() == OFileSelector::Open &&
52 !inf->isReadable() ) ||
53 (selector()->mode() == OFileSelector::Save &&
54 !inf->isWritable() ) ) {
55 pix = Resource::loadPixmap( "locked" );
56 }
57 return pix;
58
59}
60QPixmap OPixmapProvider::dir( QFileInfo* inf, bool sym, bool ) {
61 QPixmap pix;
62 /*
63 * look at selector()->mode() and determine
64 * if a dir is locked
65 */
66 if ( (selector()->mode() == OFileSelector::Open &&
67 !inf->isReadable() ) ||
68 (selector()->mode() == OFileSelector::Save &&
69 !inf->isWritable() ) ) {
70 if ( sym )
71 pix = selector()->pixmap("symlinkedlocked");
72 else
73 pix = Resource::loadPixmap("lockedfolder");
74 }else {
75 pix = sym ? selector()->pixmap("lockedfolder") :
76 Resource::loadPixmap("folder");
77
78 }
79 return pix;
80}
81QPixmap OPixmapProvider::sym( QFileInfo* , bool ) {
82 return Resource::loadPixmap("opie/symlink");
83}
diff --git a/libopie/ofileselector/opixmapprovider.h b/libopie/ofileselector/opixmapprovider.h
deleted file mode 100644
index 2165fdb..0000000
--- a/libopie/ofileselector/opixmapprovider.h
+++ b/dev/null
@@ -1,41 +0,0 @@
1#ifndef OPIE_PIXMPAP_PROVIDER
2#define OPIE_PIXMPAP_PROVIDER
3
4#include <qpixmap.h>
5
6#include "ofileselector.h"
7
8/**
9 * This is a basic interface for a Pixmap provider
10 * it provides pixmaps for a URL
11 * So the OLocalLister provides mimetype icons
12 */
13class QFileInfo;
14class OPixmapProvider {
15public:
16 /* you can or these
17 * but File | Dir would be insane ;)
18 */
19 enum Type { File = 0, Dir = 1, Symlink = 2 };
20 OPixmapProvider( OFileSelector* sel );
21 virtual ~OPixmapProvider();
22
23 virtual QPixmap pixmap( int t, const QString& mime, QFileInfo*,
24 bool isLocked = FALSE );
25 virtual QPixmap pixmap( int t, const QString& mime,
26 const QString& dir, const QString& file,
27 bool isLocked = FALSE );
28
29protected:
30 OFileSelector* selector();
31private:
32 QPixmap file( QFileInfo*,
33 bool sym, bool is );
34 QPixmap dir ( QFileInfo*,
35 bool sym, bool is );
36 QPixmap sym ( QFileInfo*,
37 bool is );
38 OFileSelector* m_sel;
39};
40
41#endif