author | zecke <zecke> | 2002-10-28 19:55:18 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-28 19:55:18 (UTC) |
commit | 3ba494eb02e72e1f9a732c46ec8085e843f01eca (patch) (side-by-side diff) | |
tree | cdc0e7af342cd0e205ed4ae1c1da92ced3fd5774 | |
parent | e9d8023028b7c996d8ff2a68b87dfde19fcfa892 (diff) | |
download | opie-3ba494eb02e72e1f9a732c46ec8085e843f01eca.zip opie-3ba494eb02e72e1f9a732c46ec8085e843f01eca.tar.gz opie-3ba494eb02e72e1f9a732c46ec8085e843f01eca.tar.bz2 |
This will probably not compile.. i did not even try to compile it
on my machine
I changed the data flow to be more extandable the Olister class
is now playing a bigger role it's dependant on
doing some assembly of the filepath and changedirs.
It now has also to take care of the location bar
-rw-r--r-- | libopie/ofileselector/ofilelistview.cpp | 20 | ||||
-rw-r--r-- | libopie/ofileselector/ofilelistview.h | 15 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselector.cpp | 25 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselectoritem.cpp | 5 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselectoritem.h | 5 | ||||
-rw-r--r-- | libopie/ofileselector/ofileview.cpp | 14 | ||||
-rw-r--r-- | libopie/ofileselector/ofileview.h | 33 | ||||
-rw-r--r-- | libopie/ofileselector/olister.cpp | 58 | ||||
-rw-r--r-- | libopie/ofileselector/olister.h | 61 | ||||
-rw-r--r-- | libopie/ofileselector/olocallister.cpp | 3 |
10 files changed, 199 insertions, 40 deletions
diff --git a/libopie/ofileselector/ofilelistview.cpp b/libopie/ofileselector/ofilelistview.cpp index 691bf42..9cfdc48 100644 --- a/libopie/ofileselector/ofilelistview.cpp +++ b/libopie/ofileselector/ofilelistview.cpp @@ -41,16 +41,17 @@ OFileListView::~OFileListView() { } void OFileListView::clear() { QListView::clear(); } void OFileListView::addFile( const QPixmap& pix, const QString&, QFileInfo* info, + const QString& /*extra*/, bool isSymlink ) { QString dir; QString name; bool locked = false; dir = info->dirPath( true ); if( isSymlink ) @@ -65,48 +66,57 @@ void OFileListView::addFile( const QPixmap& pix, } new OFileSelectorItem( this, pix, name, info->lastModified().toString(), QString::number( info->size() ), dir, locked ); } void OFileListView::addFile( const QPixmap&, const QString& /*mime*/, const QString& /*dir*/, - const QString& /*file*/, bool /*isSyml*/ ) { + const QString& /*file*/, + const QString& /*extra*/, + bool /*isSyml*/ ) { } void OFileListView::addDir( const QPixmap& pix, const QString&, - QFileInfo* info, bool symlink ) { + QFileInfo* info, + 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, true ); } void OFileListView::addDir( const QPixmap&, const QString& /*mime*/, const QString& /*dir*/, - const QString& /*file*/, bool ) { + const QString& /*file*/, + const QString& /*extra*/, + bool ) { } void OFileListView::addSymlink( const QPixmap&, const QString& /*mime*/, QFileInfo* /*info*/, + const QString& /*extra*/, bool /*isSym*/ ) { } void OFileListView::addSymlink(const QPixmap&, const QString& /*m*/, const QString& /*path*/, - const QString& /*file*/, bool /*isSym*/ ) { + const QString& /*file*/, + const QString& /*extra*/, + bool /*isSym*/ ) { } void OFileListView::cd( const QString& ) { } QWidget* OFileListView::widget() { return this; } @@ -122,17 +132,17 @@ QStringList OFileListView::selectedNames()const { list << selectedName(); return list; } QString OFileListView::selectedPath()const { return QString::null; } QStringList OFileListView::selectedPaths()const { QStringList list; - list << selectedPath(); +b list << selectedPath(); return list; } int OFileListView::fileCount() { return childCount(); } void OFileListView::sort() { QListView::sort(); } diff --git a/libopie/ofileselector/ofilelistview.h b/libopie/ofileselector/ofilelistview.h index c8cdfd1..0f625ec 100644 --- a/libopie/ofileselector/ofilelistview.h +++ b/libopie/ofileselector/ofilelistview.h @@ -11,38 +11,47 @@ class OFileListView : public QListView, public OFileView { public: OFileListView( QWidget* parent, OFileSelector* ); ~OFileListView(); void clear(); void addFile( const QPixmap&, const QString& mine, QFileInfo* info, + const QString& extra = QString::null, bool isSymlink = FALSE ); void addFile( const QPixmap&, const QString& mime, const QString& dir, const QString& file, + const QString& extra = QString::null, bool = false ); void addDir( const QPixmap&, const QString& mime, + const QString& extra = QString::null, QFileInfo* info, bool = FALSE ); void addDir( const QPixmap&, const QString& mime, const QString& dir, - const QString& file, bool = FALSE ); + const QString& file, + const QString& extra = QString::null, + bool = FALSE ); void addSymlink( const QPixmap&, const QString& mime, - QFileInfo* info, bool = FALSE ); + QFileInfo* info, + const QString& extra = QString::null, + bool = FALSE ); void addSymlink( const QPixmap&, const QString& mine, const QString& path, - const QString& file, bool isSymlink = FALSE ); + const QString& file, + const QString& extra, + bool isSymlink = FALSE ); void cd( const QString& path ); QWidget* widget(); void sort(); QString selectedName()const ; QStringList selectedNames()const; QString selectedPath()const; diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp index 4ab744c..0ccb3cb 100644 --- a/libopie/ofileselector/ofileselector.cpp +++ b/libopie/ofileselector/ofileselector.cpp @@ -388,31 +388,30 @@ QString OFileSelector::currentMimeType() const{ }else{ mime = currentText; } } return mime; } void OFileSelector::slotMimeCheck(const QString &mime) { - if( m_selector == Normal ){ - initializeOldSelector(); + if( m_selector == Normal ){ + initializeOldSelector(); - updateMimes(); - updateMimeCheck(); - m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); - }else{ // others - qWarning("Mime %s", mime.latin1() ); - if(m_shChooser ){ - qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); - //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); + updateMimes(); + updateMimeCheck(); + m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); + }else{ // others + qWarning("Mime %s", mime.latin1() ); + if(m_shChooser ){ + qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); + //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); + } + reparse(); } - reparse(); - } - } /* * Ok if a non dir gets inserted into this combobox * we need to change it * QFileInfo and dirPath will give us the right Dir */ void OFileSelector::slotLocationActivated(const QString &file) { diff --git a/libopie/ofileselector/ofileselectoritem.cpp b/libopie/ofileselector/ofileselectoritem.cpp index 1e745a1..d31046b 100644 --- a/libopie/ofileselector/ofileselectoritem.cpp +++ b/libopie/ofileselector/ofileselectoritem.cpp @@ -1,27 +1,29 @@ #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, bool isDir ) : QListViewItem( view ) { setPixmap( 0, pix ); setText( 1, path ); setText( 2, size ); setText( 3, date ); m_dir = isDir; m_locked = isLocked; m_dirStr = dir; + m_extra = extra; } OFileSelectorItem::~OFileSelectorItem() { } bool OFileSelectorItem::isLocked()const { return m_locked; } QString OFileSelectorItem::directory()const { return m_dirStr; @@ -46,8 +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 { + return m_extra; +} diff --git a/libopie/ofileselector/ofileselectoritem.h b/libopie/ofileselector/ofileselectoritem.h index 21460c4..81966ae 100644 --- a/libopie/ofileselector/ofileselectoritem.h +++ b/libopie/ofileselector/ofileselectoritem.h @@ -7,24 +7,29 @@ class OFileSelectorItem : public QListViewItem { public: OFileSelectorItem( QListView* view, const QPixmap&, const QString& path, const QString& date, const QString& size, const QString& dir, bool isLocked, + const QString& extra, bool isDir = false); ~OFileSelectorItem(); bool isLocked() const; QString directory()const; bool isDir()const; QString path()const; QString key(int id, bool ); + QString extra()const; private: bool m_locked : 1; bool m_dir : 1; QString m_dirStr; + QString m_extra; + class Private; + Private* d; }; #endif diff --git a/libopie/ofileselector/ofileview.cpp b/libopie/ofileselector/ofileview.cpp index 38f722c..72d2f60 100644 --- a/libopie/ofileselector/ofileview.cpp +++ b/libopie/ofileselector/ofileview.cpp @@ -7,30 +7,24 @@ OFileView::OFileView( OFileSelector* sel) : m_sel( sel ) { } OFileView::~OFileView() { } -void OFileView::fileSelected( const QString& s ) { - m_sel->internFileSelected( s ); -} -void OFileView::fileSelected( const DocLnk& s) { - m_sel->internFileSelected( s ); +void OFileView::fileSelected( const QString& dir,const QString& file,const QString& extra ) { + m_sel->currentLister()->fileSelected( dir,file,extra ); } void OFileView::contextMenu() { m_sel->internContextMenu(); } -void OFileView::changedDir( const QString& s) { - m_sel->internChangedDir( s ); -} -void OFileView::changedDir( const QDir& d ) { - m_sel->internChangedDir( d ); +void OFileView::changedDir( const QString& s, const QString& file, const QString& extra) { + m_sel->currentLister()->changedDir( s, file,extra ); } OFileSelector* OFileView::selector() const { return m_sel; } void OFileView::updateLine( const QString& str ) { if (m_sel->m_shLne ) m_sel->m_edit->setText( str ); } diff --git a/libopie/ofileselector/ofileview.h b/libopie/ofileselector/ofileview.h index d7ea4a2..808587f 100644 --- a/libopie/ofileselector/ofileview.h +++ b/libopie/ofileselector/ofileview.h @@ -51,59 +51,78 @@ public: OFileView( OFileSelector* ); OFileView(); virtual ~OFileView(); virtual void clear() = 0; virtual void addFile(const QPixmap&, const QString &mine, QFileInfo *info, + const QString& extra = QString::null, bool isSymlink = FALSE ) = 0; virtual void addFile(const QPixmap&, const QString& mine, const QString& dir, - const QString& file, bool = FALSE ) = 0; + const QString& file, + const QString& extra = QString::null, + bool = FALSE ) = 0; virtual void addDir (const QPixmap&, const QString &mine, QFileInfo *info, + const QString& extra = QString::null, bool isSymlink = FALSE ) = 0; virtual void addDir (const QPixmap&, const QString& mine, const QString& dir, - const QString& file, bool = FALSE) = 0; + const QString& file, + const QString& extra = QString::null, + bool = FALSE) = 0; virtual void addSymlink(const QPixmap&, const QString &mime, QFileInfo *info, + const QString& extra = QString::null, bool isSymlink = FALSE ) = 0; virtual void addSymlink(const QPixmap&, const QString& mine, const QString& path, const QString& file, + const QString& extra = QString::null, bool isSymlink = FALSE ) = 0; 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 int fileCount() = 0; virtual void sort() =0; /*signals:*/ protected: - void fileSelected(const QString &); - void fileSelected(const DocLnk & ); - void contextMenu(); - void changedDir(const QString &); - void changedDir(const QDir & ); + /** + * @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 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 b6b03cd..378c69d 100644 --- a/libopie/ofileselector/olister.cpp +++ b/libopie/ofileselector/olister.cpp @@ -1,16 +1,18 @@ +#include <qcombobox.h> + #include "olister.h" #include "ofileview.h" #include "opixmapprovider.h" #include "ofileselector.h" OLister::OLister( OFileSelector* view) - : m_view( view ) + : m_view( view ), m_acc( 0l ) { m_prov = new OPixmapProvider( view ); } OLister::~OLister() { delete m_prov; } void OLister::setPixmapProvider( OPixmapProvider* prov ) { delete m_prov; @@ -19,88 +21,142 @@ void OLister::setPixmapProvider( OPixmapProvider* prov ) { bool OLister::showFiles()const { return m_view->showFiles(); } bool OLister::showDirs()const { return m_view->showDirs(); } void OLister::addFile( const QString& mine, QFileInfo* info, + const QString& extra, bool isSymlink ) { int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink : OPixmapProvider::File; QPixmap pix = provider()->pixmap(t, mine, info); view()->currentView()->addFile( pix, mine, info, + extra, isSymlink ); } void OLister::addFile( const QString& mine, const QString& path, const QString& file, + const QString& extra, bool isSymlink ) { int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink : OPixmapProvider::File; QPixmap pix = provider()->pixmap(t, mine, path, file ); view()->currentView()->addFile( pix, mine, path, file, + extra, isSymlink ); } void OLister::addDir( const QString& mine, QFileInfo* info, + const QString& extra, bool isSymlink ) { int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink : OPixmapProvider::Dir; QPixmap pix = provider()->pixmap(t, mine, info ); view()->currentView()->addDir( pix, mine, info, + extra, isSymlink ); } void OLister::addDir( const QString& mine, const QString& path, const QString& dir, + const QString& extra, bool isSymlink ) { int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink : OPixmapProvider::Dir; QPixmap pix = provider()->pixmap(t, mine, path, dir ); view()->currentView()->addDir( pix, mine, path, dir, + extra, isSymlink ); } void OLister::addSymlink( const QString& mine, QFileInfo* info, + const QString& extra, bool isSymlink ) { QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, info ); view()->currentView()->addSymlink( pix, mine, info, + extra, isSymlink ); } void OLister::addSymlink( const QString& mine, const QString& path, const QString& name, + const QString& extra, bool isSymlink ) { QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, path, name ); view()->currentView()->addSymlink( pix, mine, path, name, + extra, isSymlink ); } OFileSelector* OLister::view() { return m_view; } OPixmapProvider* OLister::provider() { return m_prov; } bool OLister::compliesMime( const QString& mime ) { return view()->compliesMime( mime ); } +OListerCmbAccess* OLister::comboBox() { + if (!m_acc ) + m_acc = new OListerCmbAccess( view()->m_location ); + + return m_acc; +} + + +OListerCmbAccess::OListerCmbAccess(QComboBox* box ) + : 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 ); + 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 { + QString str; + if (m_cmb ) + str = m_cmb->currentText(); + + return str; +} diff --git a/libopie/ofileselector/olister.h b/libopie/ofileselector/olister.h index 0885525..79d5409 100644 --- a/libopie/ofileselector/olister.h +++ b/libopie/ofileselector/olister.h @@ -1,64 +1,125 @@ #ifndef OPIE_FILE_LISTER_H #define OPIE_FILE_LISTER_H #include <qfileinfo.h> #include <qmap.h> #include <qstring.h> #include <qstringlist.h> +class QComboBox; class OPixmapProvider; class OFileSelector; + +class OListerCmbAccess; /** * lister is something like KIO but very * very basic and currently only for * populating our views. * This is a base class which needs to be implemented. * @see OLocalLister for a filesystem based implementation */ + class OLister { public: OLister( OFileSelector* ); virtual ~OLister(); virtual void reparse(const QString& path) = 0; /** * 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; 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 + */ + OListerCmbAccess* comboBox(); + bool showFiles()const; bool showDirs()const; bool compliesMime( const QString& mime ); void addFile( const QString& mine, QFileInfo*, + const QString& extra = QString::null, bool isSymlink = FALSE ); + 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*, 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, + const QString& extra = QString::null, 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(); private: OFileSelector* m_view; OPixmapProvider* m_prov; + OListerCmbAccess* m_acc; + + class Private; + Private *d; +}; + +class OListerCmbAccess { + friend class OLister; +public: + OListerCmbAccess( QComboBox* = 0l); + ~OListerCmbAccess(); + + /** + * clears the combobox + */ + void clear(); + + /** + * set's @param add to be the current Item + * if the item is not present it'll be removed + */ + void setCurrentItem( const QString& add, bool FORECE_ADD = TRUE ); + + /** + * inserts the the String at + * a non predictable position... The position is determined + * by the QComboBox code + */ + void insert( const QString& ); + + /** + * + */ + QString currentText()const; +private: + class Private; + Private* d; + QComboBox* m_cmb; }; #endif diff --git a/libopie/ofileselector/olocallister.cpp b/libopie/ofileselector/olocallister.cpp index 6ffcf1e..2306b14 100644 --- a/libopie/ofileselector/olocallister.cpp +++ b/libopie/ofileselector/olocallister.cpp @@ -38,17 +38,18 @@ QMap<QString, QStringList> OLocalLister::mimeTypes( const QString& curDir ) { mimes.insert( type.id(), type.id() ); } ++it; } return mimes; } -/* FIXME mimecheck +/** + * FIXME mimecheck * use mime check for that * filter dirs * filter filters * filter files * filter mimetypes */ void OLocalLister::reparse( const QString& path ) { QString currentMimeType; |