author | zecke <zecke> | 2002-10-28 21:47:58 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-28 21:47:58 (UTC) |
commit | 98d46aa752026d53b4cf4ea8572fdf7c89f4c6c0 (patch) (side-by-side diff) | |
tree | 3e4a873011de405e5402d7eb53ae1c5c2867246a | |
parent | b963230163fc8069731374a19390fd0e5cb42532 (diff) | |
download | opie-98d46aa752026d53b4cf4ea8572fdf7c89f4c6c0.zip opie-98d46aa752026d53b4cf4ea8572fdf7c89f4c6c0.tar.gz opie-98d46aa752026d53b4cf4ea8572fdf7c89f4c6c0.tar.bz2 |
Almost done with the new data flow
only OFileSelector needs to adapt it now...
Besides that make it compile with the new api
Add a configure and a libopie.pro to actually build ofileselector
and a MANIFEST to explain some basics of the now a days
a bit bigger interface
-rw-r--r-- | libopie/ofileselector/MANIFEST | 29 | ||||
-rwxr-xr-x | libopie/ofileselector/configure | 301 | ||||
-rw-r--r-- | libopie/ofileselector/libopie.pro | 97 | ||||
-rw-r--r-- | libopie/ofileselector/ofilelistview.cpp | 32 | ||||
-rw-r--r-- | libopie/ofileselector/ofilelistview.h | 6 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselector.cpp | 2 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselectoritem.cpp | 4 | ||||
-rw-r--r-- | libopie/ofileselector/ofileview.cpp | 2 | ||||
-rw-r--r-- | libopie/ofileselector/ofileview.h | 4 | ||||
-rw-r--r-- | libopie/ofileselector/olister.cpp | 13 | ||||
-rw-r--r-- | libopie/ofileselector/olister.h | 7 | ||||
-rw-r--r-- | libopie/ofileselector/olocallister.cpp | 14 | ||||
-rw-r--r-- | libopie/ofileselector/olocallister.h | 2 |
13 files changed, 482 insertions, 31 deletions
diff --git a/libopie/ofileselector/MANIFEST b/libopie/ofileselector/MANIFEST new file mode 100644 index 0000000..2730a1c --- a/dev/null +++ b/libopie/ofileselector/MANIFEST @@ -0,0 +1,29 @@ +Hija, +dunno if that is to call a manifest but here is +an quick overview how the OFileSelector is implemented +and whats the whole purpose is. + +OFileSelector is meant to be extendable by design. It's divided +into a shell the class OFileSelector which is a dispatcher +between worlds and gives a common interface to the programmer. +Then there is the OLister class which is a lister of files. +It's responsible for taking care of a filesystem... but it's not limited +to local filesystem. You can have a FTP lister, Bluetooth Device Lister, +IrdaDevice Lister, Local Documents Lister, a PIM Lister an X-Ref lister... +they will operate on the level of filesystems.... + +A OFileView is the other part of the FileSelector it's responsible +for the things represented to the USER. +There is a ListView and a IconView and possible more views to come. + +Then there is a PixmapProvider which is responsible for providing pixmaps +for a mimetype. This can be used for something like a Pixmap preview.... + + +The lister is told to reparse() then it adds it things to the mainview +on selection the URL get's generated in more than one step. +1. The UI notifies the lister about activation +2. The Lister assembles the URL +3. the Lister notifies the OFileSelector +4. the OFileSelector emits a signal + diff --git a/libopie/ofileselector/configure b/libopie/ofileselector/configure new file mode 100755 index 0000000..c66fd82 --- a/dev/null +++ b/libopie/ofileselector/configure @@ -0,0 +1,301 @@ +#!/bin/sh +# +# Configures to build the Qtopia Environment +# +# Copyright 1999-2000 Trolltech AS. All rights reserved. +# + +PLATFORM=generic +SHARING=shared +DEBUG= +QCONFIGARG= + +touch .test.qpe. +if [ '!' -f ${OPIEDIR}/.test.qpe. ]; +then + rm .test.qpe. + echo + echo + echo ' The environment variable $OPIEDIR is not set correctly. It is currently' + echo ' set to "'$OPIEDIR'", but it should be set to this directory,' + echo ' which is "'`pwd`'".' + echo + echo ' Please read the INSTALL file for instructions on how to set $OPIEDIR' + echo ' correctly. If you have set $OPIEDIR in your .profile or .login, you ' + echo ' will need to log out and log in again to make the setting effective.' + echo + echo + exit 1 +fi +rm .test.qpe. + +if [ '!' -f $TMAKEPATH/tmake.conf ] +then + # You have tmake. We'll regenerate the file for you... + echo ' The environment variable $TMAKEPATH is not set correclty. ' + echo ' It should be set to the tmake path' + echo + echo ' Please read the INSTALL file for instructions on how to set $TMAKEPATH' + echo ' to the environment variable correctly.' + exit 1 +fi + +VERSION_MAJ=$(sed -n -e 's/.*QPE_VERSION "\([0-9]*\)\.[0-9]*\.[0-9]*.*".*/\1/p' <library/version.h) +VERSION_MIN=$(sed -n -e 's/.*QPE_VERSION "[0-9]*\.\([0-9]\)\.[0-9]*.*".*/\1/p' <library/version.h) +VERSION_PAT=$(sed -n -e 's/.*QPE_VERSION "[0-9]*\.[0-9]*\.\([0-9]*\).*".*/\1/p' <library/version.h) + +TOMAKE= + +if grep -q 'VERSION_STR.*"3' $QTDIR/include/qglobal.h +then + QT3=yes +else + QT3=no +fi + +# Parse the arguments, setting things to "yes" or "no". + +while [ -n "$1" ]; do + case $1 in + -platform|-xplatform) # No difference since we don't need to build moc, etc. + shift; PLATFORM=$1 + ;; + -release) + DEBUG= + ;; + -debug) + DEBUG=-debug + ;; + -shared) + SHARING=shared + ;; + -static) + SHARING=static + ;; + -qconfig) + # optional way to specify the qconfig-qpe.h is to pass -qconfig qpe + shift; QCONFIGARG=DEFINES+=QCONFIG='\"'$1'\"' # Don't quote me on that. + ;; + -make) + shift; TOMAKE="$TOMAKE $1" + ;; + -qt3) + QT3=yes + ;; + *) + HELP=yes;; + esac + shift +done + +TARGET=configs/$PLATFORM-$SHARING$DEBUG + +if [ '!' -f $TARGET ] +then + if [ -f configs/linux-$PLATFORM-g++-$SHARING$DEBUG ] + then + TARGET=configs/linux-$PLATFORM-g++-$SHARING$DEBUG + PLATFORM=linux-$PLATFORM-g++ + else + echo + echo ' The specified platform/compiler not supported: ' $TARGET + echo + exit 2 + fi +fi + +# Next, emit a usage message if something failed. + +if [ "$HELP" = "yes" ]; then + cat <<EOF +Usage: $0 [-debug] [-release] [-shared] [-static] [-qt3] [-platform ...] + +The defaults (*) are usually acceptable. Here is a short explanation of +each option: + + * -release ........... Compile and link Qt with debugging turned off. + -debug ............. Compile and link Qt with debugging turned on. + + * -shared ............ Create and use a shared Qt library (libqt.so) + -static ............ Create and use a static Qt library (libqt.a) + + -qt3 ............... Configure for use with Qt 3.x + + -platform target ... The platform you are building on ($PLATFORM) +EOF + exit 0; +fi + +CUSTOM=`echo $PLATFORM | sed -n -e "s/.*-\(.*\)-.*/\1/p"` + +if [ -f library/custom-$CUSTOM.h ] +then + rm -f library/custom.h + ln -s custom-$CUSTOM.h library/custom.h +fi + +mkdir -p include/qpe +( cd include/qpe && rm -f *.h; ln -s ../../library/*.h .; ln -s ../../library/backend/*.h .; rm -f *_p.h; ) +mkdir -p include/qtopia +( cd include/qtopia && rm -f *.h; ln -s ../../library/*.h .; ) +mkdir -p include/qtopia/private +( cd include/qtopia/private && rm -f *.h; ln -s ../../../library/backend/*.h .; ) +mkdir -p include/opie +( cd include/opie && rm -f *.h; ln -s ../../libopie/*.h .; rm -f *_p.h; ) +( cd include/opie && ln -s ../../libsql/*.h .; ) +( cd include/opie && ln -s ../../libopie/pim/*.h .; ) +( cd include/opie && ln -fs ../../libopie/ofileselector/*.h .; ) + +echo Creating makefiles... + +# Set version for library directly +# Version 1.5.0 right now for compat. +sed -e 's/^\(VERSION.*= \).*/\1'1.5.0.$VERSION_PAT/ <library/library.pro >library/library.pro-v +mv library/library.pro-v library/library.pro + +if [ "$QT3" = yes ] +then + VCONFIG="CONFIG+=qt3" +else + VCONFIG="CONFIG+=qt2" +fi + +if [ -f $TMAKEPATH/tmake.conf ] +then + # You have tmake. We'll regenerate the file for you... + echo "Makefiles will be regenerated." +fi + +H=`pwd` +if [ -z "$TOMAKE" ] +then + TOMAKE=`make showcomponents` +fi + +for a in $TOMAKE ; do + N=$a/Makefile + M=$a/Makefile.in + O=$a/Makefile.add + f=`basename $a` + + if [ -f "$TMAKEPATH/tmake.conf" -a -f "$a/$f.pro" ] + then + ( cd $a; + TMAKEPATH=$QTDIR/tmake:$TMAKEPATH \ + tmake $QCONFIGARG CONFIG+=embedded $VCONFIG \ + -t $H/qt/tmake/propagate.t $f.pro | + sed -e "s|$QTDIR|\$(QTDIR)|g" -e "s|$OPIEDIR|\$(OPIEDIR)|g" >Makefile.in; + ) + echo -n "." +# echo Building $N.. + appname=`grep '^TARGET' $a/$f.pro | sed 's/^TARGET.*=//' | tr -d " \t"` + translation=`grep '^TRANSLATION.*[^+]=.*' $a/$f.pro | sed 's,^TRANSL.*=.*i18n\/.*\/,,' | sed 's/ //g' | sed 's,\.ts.*,,' | sed 's,^lib,,' ` + if [ -n "$translation" -a -n "$appname" ] + then + if [ "$appname" != "$translation" ] + then + echo + echo "Warning: translation and appname disagree in $a/$f.pro" + fi + fi + + fi + + cat > $N <<EOF +############################################################################# +# Automatically generated from $M +# Build options from $1 +############################################################################# + +EOF + + SED= + PLATFORM_CFLAGS= + + if [ "$f" = "embeddedkonsole" ] + then + case $PLATFORM in + *x86*|*generic*|*ipaq*|*sharp*) + SED="$SED /^LIBS.*=/s/\$/ -lutil/;" + PLATFORM_CFLAGS="-DHAVE_OPENPTY" + ;; *) + SED= + esac + elif [ "$f" = "libmpeg3" ] + then + # Patch our Makefile.in file with the platform specifics for the libmpeg3 library + # Use the C++ compiler to compile the .c files (because the fixed-point classes are C++ code) + SED='s/\$(CC)/\$(CXX)/;' + case $PLATFORM + in + # For x86 turn on using floating point, compile mmx and css code + *x86*) + # "-funroll-loops -fomit-frame-pointer -malign-loops=2 -malign-jumps=2 -malign-functions=2 -march=i486" + PLATFORM_CFLAGS="-DHAVE_MMX -DHAVE_CSS" + SED="$SED /SOURCES.*=/s/=/= video\\/mmxidct.S video\\/reconmmx.s\ /;" + # For generic turn on using floating point + ;; *generic*) + PLATFORM_CFLAGS="" + # For the ipaq use fixed point maths, don't compile the mmx or css code + ;; *ipaq*|*sharp*) + PLATFORM_CFLAGS="-DUSE_FIXED_POINT" + ;; *) + # For 'other platforms', turn off optimizations and use fixed point + PLATFORM_CFLAGS="-O -DUSE_FIXED_POINT" + esac + elif [ "$f" = "libmad" ] + then + # Patch our Makefile.in file with the platform specifics for the libmad library + case $PLATFORM + in + # For x86 use intel optimizations + *x86*) + PLATFORM_CFLAGS="-DFPM_INTEL" + # For the ipaq use ARM asm optimizations + ;; *ipaq*|*sharp*) + PLATFORM_CFLAGS="-DFPM_ARM" + SED="$SED /SOURCES.*=/s/=/= idmt_arm.S /;" + # For generic platforms use the C 64-bit implementation + ;; *generic*) + PLATFORM_CFLAGS="-DFPM_64BIT" + # For 'other platforms' use the ARM code + ;; *) + PLATFORM_CFLAGS="-DFPM_ARM" + SED="$SED /SOURCES.*=/s/=/= idmt_arm.S /;" + esac + fi + if [ -n "$PLATFORM_CFLAGS" ] + then + # Append the addition c-flags we have defined + SED="$SED /CFLAGS.*=.*/s/\$/ $PLATFORM_CFLAGS/;" + SED="$SED /CXXFLAGS.*=.*/s/\$/ $PLATFORM_CFLAGS/;" + fi + cat $TARGET >> $N + if [ -n "$SED" ] + then + sed -e "$SED" $M >> $N + else + cat $M >> $N + fi + + cat >> $N <<EOF + +lupdate: + lupdate $f.pro + +lrelease: + lrelease $f.pro + +EOF + if [ -f "$O" ] + then + cat >> $N $O + fi + +done + +MAKE=make +echo +echo "Opie is now configured for building. Just run $MAKE (or $MAKE single)." +echo "To reconfigure, run $MAKE clean and configure." +echo diff --git a/libopie/ofileselector/libopie.pro b/libopie/ofileselector/libopie.pro new file mode 100644 index 0000000..0fa43fc --- a/dev/null +++ b/libopie/ofileselector/libopie.pro @@ -0,0 +1,97 @@ +TEMPLATE = lib +CONFIG += qte warn_on release +HEADERS = ofontmenu.h \ + ocolorbutton.h \ + ofileselector/odefaultfactories.h \ + ofileselector/ofiledialog.h \ + ofileselector/ofilelistview.h \ + ofileselector/ofileselector.h \ + ofileselector/ofileselectoritem.h \ + ofileselector/ofileseleczormain.h \ + ofileselector/ofileview.h \ + ofileselector/olister.h \ + ofileselector/olocallister.h \ + ofileselector/opixmapprovider.h \ + tododb.h \ + ocheckitem.h todoevent.h todoresource.h \ + todovcalresource.h xmltree.h \ + colordialog.h colorpopupmenu.h \ + oclickablelabel.h oprocctrl.h \ + oprocess.h odevice.h \ + otimepicker.h otabwidget.h \ + otabbar.h otabinfo.h \ + ofontselector.h \ + pim/opimrecord.h \ + pim/otodo.h \ + pim/orecordlist.h \ + pim/opimaccesstemplate.h \ + pim/opimaccessbackend.h \ + pim/otodoaccess.h \ + pim/otodacessbackend.h \ + pim/ocontact.h \ + pim/ocontactaccess.h \ + pim/ocontactaccessbackend.h \ + pim/ocontactaccessbackend_xml.h \ + pim/obackendfactory.h \ + pim/opimcache.h \ + pim/otodoaccessvcal.h \ + pim/orecur.h \ + orecurrancewidget.h +# pim/otodoaccesssql.h \ + +SOURCES = ofontmenu.cc \ + ocolorbutton.cpp \ + ofileselector/odefaultfactories.cpp \ + ofileselector/ofiledialog.cpp \ + ofileselector/ofilefactory.cpp \ + ofileselector/ofilelistview.cpp \ + ofileselector/ofileselector.cpp \ + ofileselector/ofileselectoritem.cpp \ + ofileselector/ofileselectormain.cpp \ + ofileselector/ofileview.cpp \ + ofileselector/olister.cpp \ + ofileselector/olocallister.cpp \ + ofileselector/opixmapprovider.cpp \ + xmltree.cc \ + ocheckitem.cpp tododb.cpp todoevent.cpp \ + todovcalresource.cpp colordialog.cpp \ + colorpopupmenu.cpp oclickablelabel.cpp \ + oprocctrl.cpp oprocess.cpp \ + odevice.cpp otimepicker.cpp \ + otabwidget.cpp otabbar.cpp \ + ofontselector.cpp \ + pim/otodo.cpp \ + pim/opimrecord.cpp \ + pim/otodoaccess.cpp \ + pim/otodoaccessbackend.cpp \ + pim/otodoaccessxml.cpp \ + pim/ocontact.cpp \ + pim/ocontactaccess.cpp \ + pim/otodoaccessvcal.cpp \ + pim/orecur.cpp \ + orecurrancewidget.cpp +# pim/otodoaccesssql.cpp \ + +TARGET = opie +INCLUDEPATH += $(OPIEDIR)/include +DESTDIR = $(QTDIR)/lib$(PROJMAK) +#VERSION = 1.0.0 + +# LIBS += -lopiesql + +INTERFACES = otimepickerbase.ui orecurrancebase.ui + +TRANSLATIONS = ../i18n/de/libopie.ts \ + ../i18n/en/libopie.ts \ + ../i18n/es/libopie.ts \ + ../i18n/fr/libopie.ts \ + ../i18n/hu/libopie.ts \ + ../i18n/ja/libopie.ts \ + ../i18n/ko/libopie.ts \ + ../i18n/no/libopie.ts \ + ../i18n/pl/libopie.ts \ + ../i18n/pt/libopie.ts \ + ../i18n/pt_BR/libopie.ts \ + ../i18n/sl/libopie.ts \ + ../i18n/zh_CN/libopie.ts \ + ../i18n/zh_TW/libopie.ts diff --git a/libopie/ofileselector/ofilelistview.cpp b/libopie/ofileselector/ofilelistview.cpp index 9cfdc48..fe8acf0 100644 --- a/libopie/ofileselector/ofilelistview.cpp +++ b/libopie/ofileselector/ofilelistview.cpp @@ -41,17 +41,17 @@ OFileListView::~OFileListView() { } void OFileListView::clear() { QListView::clear(); } void OFileListView::addFile( const QPixmap& pix, const QString&, QFileInfo* info, - const QString& /*extra*/, + const QString& extra, bool isSymlink ) { QString dir; QString name; bool locked = false; dir = info->dirPath( true ); if( isSymlink ) @@ -62,39 +62,39 @@ void OFileListView::addFile( const QPixmap& pix, ( selector()->mode() == OFileSelector::Save && !info->isWritable() ) ){ locked = true; } } new OFileSelectorItem( this, pix, name, info->lastModified().toString(), QString::number( info->size() ), - dir, locked ); + dir, locked, extra ); } void OFileListView::addFile( const QPixmap&, const QString& /*mime*/, const QString& /*dir*/, const QString& /*file*/, const QString& /*extra*/, bool /*isSyml*/ ) { } void OFileListView::addDir( const QPixmap& pix, const QString&, QFileInfo* info, - const QString& /*extra */, + const QString& extra , bool symlink ) { bool locked = false; QString name; name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; new OFileSelectorItem( this, pix, name, info->lastModified().toString(), QString::number( info->size() ), - info->dirPath( true ), locked, + info->dirPath( true ), locked, extra, true ); } void OFileListView::addDir( const QPixmap&, const QString& /*mime*/, const QString& /*dir*/, const QString& /*file*/, const QString& /*extra*/, bool ) { @@ -122,27 +122,34 @@ QWidget* OFileListView::widget() { } QString OFileListView::selectedName()const{ QListViewItem *item = currentItem(); if (!item ) return QString::null; return item->text( 1 ); } +QString OFileListView::selectedExtra()const{ + QListViewItem* item = currentItem(); + if (!item) return QString::null; + OFileSelectorItem* fit = (OFileSelectorItem*)fit; + + return fit->extra(); +} QStringList OFileListView::selectedNames()const { QStringList list; list << selectedName(); return list; } QString OFileListView::selectedPath()const { return QString::null; } QStringList OFileListView::selectedPaths()const { QStringList list; -b list << selectedPath(); + list << selectedPath(); return list; } int OFileListView::fileCount() { return childCount(); } void OFileListView::sort() { QListView::sort(); } @@ -156,46 +163,37 @@ void OFileListView::slotCurrentChanged( QListViewItem* item) { OFileSelectorItem* sel = (OFileSelectorItem*) item; qWarning("current changed"); if(!sel->isDir() ){ updateLine( sel->text(1) ); if (selector()->mode() == OFileSelector::Fileselector ) { QStringList str = QStringList::split("->", sel->text(1) ); - QString path =sel->directory() + "/" + str[0].stripWhiteSpace(); - DocLnk lnk( path ); - fileSelected(lnk ); - fileSelected( path ); + fileSelected(sel->directory(), str[0].stripWhiteSpace(),sel->extra() ); } } } void OFileListView::slotClicked( int button, QListViewItem* item, const QPoint&, int ) { if ( !item ) return; if( button != Qt::LeftButton ) return; OFileSelectorItem *sel = (OFileSelectorItem*)item; if(!sel->isLocked() ){ QStringList str = QStringList::split("->", sel->text(1) ); if( sel->isDir() ){ - changedDir( sel->directory() + "/" + str[0].stripWhiteSpace() ); + changedDir( sel->directory(), str[0].stripWhiteSpace(),sel->extra() ); }else{ updateLine( str[0].stripWhiteSpace() ); - QString path = sel->directory(); - path += "/"; - path += str[0].stripWhiteSpace(); - - DocLnk lnk( path ); - fileSelected( path ); - fileSelected( lnk ); + fileSelected( sel->directory(),str[0].stripWhiteSpace(), sel->extra() ); } } } void OFileListView::slotRightButton( int button, QListViewItem* item, const QPoint&, int ) { if (!item || (button != Qt::RightButton )) return; diff --git a/libopie/ofileselector/ofilelistview.h b/libopie/ofileselector/ofilelistview.h index 0f625ec..f2eac57 100644 --- a/libopie/ofileselector/ofilelistview.h +++ b/libopie/ofileselector/ofilelistview.h @@ -23,44 +23,46 @@ public: const QString& mime, const QString& dir, const QString& file, const QString& extra = QString::null, bool = false ); void addDir( const QPixmap&, const QString& mime, + QFileInfo* info, const QString& extra = QString::null, - QFileInfo* info, bool = FALSE ); + bool = FALSE ); void addDir( const QPixmap&, const QString& mime, const QString& dir, const QString& file, const QString& extra = QString::null, bool = FALSE ); void addSymlink( const QPixmap&, const QString& mime, QFileInfo* info, const QString& extra = QString::null, bool = FALSE ); void addSymlink( const QPixmap&, const QString& mine, const QString& path, const QString& file, - const QString& extra, + const QString& extra = QString::null, bool isSymlink = FALSE ); void cd( const QString& path ); QWidget* widget(); void sort(); QString selectedName()const ; QStringList selectedNames()const; QString selectedPath()const; QStringList selectedPaths()const; + QString selectedExtra()const; int fileCount(); private slots: void slotSelectionChanged(); void slotCurrentChanged(QListViewItem* ); void slotClicked( int, QListViewItem*, const QPoint&, int ); void slotRightButton(int, QListViewItem*, const QPoint&, int ); }; diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp index 0ccb3cb..255e79e 100644 --- a/libopie/ofileselector/ofileselector.cpp +++ b/libopie/ofileselector/ofileselector.cpp @@ -1031,16 +1031,18 @@ int OFileSelector::sorting() { sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed ); else sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed ); return sort; } void OFileSelector::internFileSelected( const QString& s) { emit fileSelected( s ); + DocLnk lnk( s ); + internFileSelected( lnk ); } void OFileSelector::internFileSelected( const DocLnk& d ) { emit fileSelected( d ); } void OFileSelector::internContextMenu() { emit contextMenu(); } void OFileSelector::internChangedDir( const QString& s) { diff --git a/libopie/ofileselector/ofileselectoritem.cpp b/libopie/ofileselector/ofileselectoritem.cpp index d31046b..4ef8fe3 100644 --- a/libopie/ofileselector/ofileselectoritem.cpp +++ b/libopie/ofileselector/ofileselectoritem.cpp @@ -1,18 +1,18 @@ #include "ofileselectoritem.h" OFileSelectorItem::OFileSelectorItem( QListView*view, const QPixmap& pix, const QString& path, const QString& date, const QString& size, const QString& dir, - const QString& extra, bool isLocked, + const QString& extra, bool isDir ) : QListViewItem( view ) { setPixmap( 0, pix ); setText( 1, path ); setText( 2, size ); setText( 3, date ); m_dir = isDir; @@ -48,11 +48,11 @@ QString OFileSelectorItem::key( int id, bool ) { }else if( id == 2 ){ // size return text(2); }else if( id == 3 ){ // date return text(3); } return ke; } -QString OFileSelector::extra()const { +QString OFileSelectorItem::extra()const { return m_extra; } diff --git a/libopie/ofileselector/ofileview.cpp b/libopie/ofileselector/ofileview.cpp index 72d2f60..4203ca3 100644 --- a/libopie/ofileselector/ofileview.cpp +++ b/libopie/ofileselector/ofileview.cpp @@ -1,16 +1,18 @@ #include <qlineedit.h> #include <qpe/applnk.h> #include "ofileselector.h" +#include "olister.h" #include "ofileview.h" + OFileView::OFileView( OFileSelector* sel) : m_sel( sel ) { } OFileView::~OFileView() { } void OFileView::fileSelected( const QString& dir,const QString& file,const QString& extra ) { m_sel->currentLister()->fileSelected( dir,file,extra ); diff --git a/libopie/ofileselector/ofileview.h b/libopie/ofileselector/ofileview.h index 808587f..e84a3e1 100644 --- a/libopie/ofileselector/ofileview.h +++ b/libopie/ofileselector/ofileview.h @@ -91,38 +91,38 @@ public: virtual void cd(const QString &path ) = 0; virtual QWidget* widget() = 0; virtual QString selectedName()const = 0; virtual QStringList selectedNames()const = 0; virtual QString selectedPath()const = 0; virtual QStringList selectedPaths()const = 0; + virtual QString selectedExtra()const = 0; virtual int fileCount() = 0; virtual void sort() =0; /*signals:*/ protected: /** * @param dir The dir name * @param file The file name * @param extra The extra information */ - void fileSelected(const QString &dir, const QString& file, const QString& extra = QString::nulll); + void fileSelected(const QString &dir, const QString& file, const QString& extra = QString::null); void contextMenu(); /** * * @param dir The dir name * @param file The file name * @param extra The extra informations */ void changedDir(const QString &dir, const QString& file, const QString& extra = QString::null); - void changedDir(const QDir & ); /* updates the file name line of the FileSelector */ void updateLine( const QString& ); OFileSelector* selector()const; private: OFileSelector* m_sel; }; diff --git a/libopie/ofileselector/olister.cpp b/libopie/ofileselector/olister.cpp index 378c69d..ea09940 100644 --- a/libopie/ofileselector/olister.cpp +++ b/libopie/ofileselector/olister.cpp @@ -113,44 +113,53 @@ OFileSelector* OLister::view() { return m_view; } OPixmapProvider* OLister::provider() { return m_prov; } bool OLister::compliesMime( const QString& mime ) { return view()->compliesMime( mime ); } +void OLister::internFileSelected( const QString& dir ) { + view()->internFileSelected( dir ); +} +void OLister::internChangedDir( const QString& dir ) { + view()->internChangedDir( dir ); +} OListerCmbAccess* OLister::comboBox() { if (!m_acc ) m_acc = new OListerCmbAccess( view()->m_location ); return m_acc; } -OListerCmbAccess::OListerCmbAccess(QComboBox* box ) +OListerCmbAccess::OListerCmbAccess(QComboBox* cmb ) : m_cmb( cmb ) {} OListerCmbAccess::~OListerCmbAccess() { } void OListerCmbAccess::clear() { if ( m_cmb ) m_cmb->clear(); } void OListerCmbAccess::setCurrentItem( const QString& add, bool FORCE_ADD) { if ( !m_cmb ) return; int c = m_cmb->count(); for ( int i = 0; i < m_cmb->count(); i++ ) { if ( m_cmb->text(i) == add ) { - bo->setCurrentItem( i ); + m_cmb->setCurrentItem( i ); return; } } + if (!FORCE_ADD ) return; + + m_cmb->insertItem(add ); m_cmb->setCurrentItem( c ); } void OListerCmbAccess::insert( const QString& str ) { if ( m_cmb ) m_cmb->insertItem( str ); } QString OListerCmbAccess::currentText()const { diff --git a/libopie/ofileselector/olister.h b/libopie/ofileselector/olister.h index 79d5409..cd84316 100644 --- a/libopie/ofileselector/olister.h +++ b/libopie/ofileselector/olister.h @@ -28,18 +28,18 @@ public: /** * return a list of available mimetypes */ virtual QMap<QString, QStringList> mimeTypes( const QString& dir ) = 0; void setPixmapProvider( OPixmapProvider* ); /* some way a slot */ - void fileSelected( const QString& dir, const QString& file, const QString& extra ) = 0; - void changeDir( const QString& dir, const QString& file, const QString& extra ) = 0; + virtual void fileSelected( const QString& dir, const QString& file, const QString& extra ) = 0; + virtual void changedDir( const QString& dir, const QString& file, const QString& extra ) = 0; protected: /** * I hate too big classes * this is a way to group * access to a ComboBox * which might exist or * not in a secure way */ @@ -55,16 +55,17 @@ protected: void addFile( const QString& mine, const QString& path, const QString& file, const QString& extra = QString::null, bool isSymlink = FALSE ); void addDir( const QString& mine, QFileInfo*, + const QString& extra = QString::null, bool isSymlink = FALSE ); void addDir( const QString& mine, const QString& path, const QString& dir, const QString& extra = QString::null, bool isSymlink = FALSE ); void addSymlink( const QString& mine, QFileInfo* info, @@ -72,16 +73,18 @@ protected: bool isSymlink = FALSE); void addSymlink( const QString& mine, const QString& path, const QString& name, const QString& extra = QString::null, bool isSymlink = FALSE ); OFileSelector* view(); OPixmapProvider* provider(); + void internFileSelected( const QString& file ); + void internChangedDir( const QString& dir ); private: OFileSelector* m_view; OPixmapProvider* m_prov; OListerCmbAccess* m_acc; class Private; Private *d; }; diff --git a/libopie/ofileselector/olocallister.cpp b/libopie/ofileselector/olocallister.cpp index 2306b14..5d7884d 100644 --- a/libopie/ofileselector/olocallister.cpp +++ b/libopie/ofileselector/olocallister.cpp @@ -73,34 +73,34 @@ void OLocalLister::reparse( const QString& path ) { if( fi->isSymLink() ){ QString file = fi->dirPath( true ) + "/" + fi->readLink(); /* * 5 tries to prevent dos attack */ for( int i = 0; i<=4; i++) { QFileInfo info( file ); if( !info.exists() ){ - addSymlink( currentMimeType, fi, TRUE ); + addSymlink( currentMimeType, fi, QString::null, TRUE ); break; }else if( info.isDir() ){ if (!showDirs() ) break; - addDir( currentMimeType, fi, + addDir( currentMimeType, fi, QString::null, TRUE ); break; }else if( info.isFile() ){ /* if not show files skip it */ if (!showFiles() ) break; /* check if we comply to the mimetype */ MimeType type( info.absFilePath() ); if (compliesMime( type.id() ) ) - addFile( currentMimeType, fi, TRUE ); + addFile( currentMimeType, fi, QString::null, TRUE ); break; }else if( info.isSymLink() ){ file = info.dirPath(true ) + "/" + info.readLink() ; break; }else if( i == 4){ addSymlink( currentMimeType, fi ); } @@ -111,9 +111,15 @@ void OLocalLister::reparse( const QString& path ) { addDir( currentMimeType, fi ); }else if( fi->isFile() ){ if ( showFiles() ) addFile( currentMimeType, fi ); } ++it; } // of while loop } - +/* more accepting it code */ +void OLocalLister::fileSelected( const QString& dir, const QString& file, const QString& ) { + internFileSelected( dir + "/" + file ); +} +void OLocalLister::changedDir( const QString& dir, const QString& file, const QString& ) { + internChangedDir( dir + "/" + file ); +} diff --git a/libopie/ofileselector/olocallister.h b/libopie/ofileselector/olocallister.h index 0a06102..01e6f3c 100644 --- a/libopie/ofileselector/olocallister.h +++ b/libopie/ofileselector/olocallister.h @@ -4,11 +4,13 @@ #include "olister.h" class OLocalLister : public OLister { public: OLocalLister( OFileSelector* ); ~OLocalLister(); void reparse( const QString& path ); QMap<QString, QStringList> mimeTypes(const QString& dir ); + void fileSelected( const QString& dir, const QString& file, const QString& ); + void changedDir( const QString& dir, const QString& file,const QString& ); }; #endif |