From 98d46aa752026d53b4cf4ea8572fdf7c89f4c6c0 Mon Sep 17 00:00:00 2001 From: zecke Date: Mon, 28 Oct 2002 21:47:58 +0000 Subject: 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 --- 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/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 <> $N + if [ -n "$SED" ] + then + sed -e "$SED" $M >> $N + else + cat $M >> $N + fi + + cat >> $N <> $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 @@ -46,7 +46,7 @@ void OFileListView::clear() { void OFileListView::addFile( const QPixmap& pix, const QString&, QFileInfo* info, - const QString& /*extra*/, + const QString& extra, bool isSymlink ) { QString dir; QString name; @@ -67,7 +67,7 @@ void OFileListView::addFile( const QPixmap& pix, 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*/, @@ -78,7 +78,7 @@ void OFileListView::addFile( const QPixmap&, } void OFileListView::addDir( const QPixmap& pix, const QString&, QFileInfo* info, - const QString& /*extra */, + const QString& extra , bool symlink ) { bool locked = false; @@ -89,7 +89,7 @@ void OFileListView::addDir( const QPixmap& pix, const QString&, new OFileSelectorItem( this, pix, name, info->lastModified().toString(), QString::number( info->size() ), - info->dirPath( true ), locked, + info->dirPath( true ), locked, extra, true ); } @@ -127,6 +127,13 @@ QString OFileListView::selectedName()const{ 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(); @@ -137,7 +144,7 @@ QString OFileListView::selectedPath()const { } QStringList OFileListView::selectedPaths()const { QStringList list; -b list << selectedPath(); + list << selectedPath(); return list; } int OFileListView::fileCount() { @@ -161,10 +168,7 @@ void OFileListView::slotCurrentChanged( QListViewItem* item) { 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() ); } } } @@ -181,16 +185,10 @@ void OFileListView::slotClicked( int button, QListViewItem* 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() ); } } } 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 @@ -28,8 +28,9 @@ public: 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, @@ -45,7 +46,7 @@ public: 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(); @@ -56,6 +57,7 @@ public: QString selectedPath()const; QStringList selectedPaths()const; + QString selectedExtra()const; int fileCount(); private slots: void slotSelectionChanged(); 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 @@ -1036,6 +1036,8 @@ int OFileSelector::sorting() { } void OFileSelector::internFileSelected( const QString& s) { emit fileSelected( s ); + DocLnk lnk( s ); + internFileSelected( lnk ); } void OFileSelector::internFileSelected( const DocLnk& d ) { emit fileSelected( d ); 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 @@ -6,8 +6,8 @@ OFileSelectorItem::OFileSelectorItem( QListView*view, const QString& date, const QString& size, const QString& dir, - const QString& extra, bool isLocked, + const QString& extra, bool isDir ) : QListViewItem( view ) { @@ -53,6 +53,6 @@ QString OFileSelectorItem::key( int id, bool ) { 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 @@ -3,9 +3,11 @@ #include #include "ofileselector.h" +#include "olister.h" #include "ofileview.h" + OFileView::OFileView( OFileSelector* sel) : m_sel( sel ) { 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 @@ -96,6 +96,7 @@ public: 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; @@ -107,7 +108,7 @@ protected: * @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(); /** @@ -117,7 +118,6 @@ protected: * @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& ); 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 @@ -118,6 +118,12 @@ OPixmapProvider* OLister::provider() { 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 ); @@ -126,7 +132,7 @@ OListerCmbAccess* OLister::comboBox() { } -OListerCmbAccess::OListerCmbAccess(QComboBox* box ) +OListerCmbAccess::OListerCmbAccess(QComboBox* cmb ) : m_cmb( cmb ) {} OListerCmbAccess::~OListerCmbAccess() { @@ -142,10 +148,13 @@ void OListerCmbAccess::setCurrentItem( const QString& add, bool FORCE_ADD) { 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 ); } 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 @@ -33,8 +33,8 @@ public: /* 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 @@ -60,6 +60,7 @@ protected: 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, @@ -77,6 +78,8 @@ protected: bool isSymlink = FALSE ); OFileSelector* view(); OPixmapProvider* provider(); + void internFileSelected( const QString& file ); + void internChangedDir( const QString& dir ); private: OFileSelector* m_view; OPixmapProvider* m_prov; 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 @@ -78,13 +78,13 @@ void OLocalLister::reparse( const QString& path ) { 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() ){ @@ -95,7 +95,7 @@ void OLocalLister::reparse( const QString& path ) { /* 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() ){ @@ -116,4 +116,10 @@ void OLocalLister::reparse( const QString& path ) { ++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 @@ -9,6 +9,8 @@ public: ~OLocalLister(); void reparse( const QString& path ); QMap 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 -- cgit v0.9.0.2