summaryrefslogtreecommitdiff
path: root/libopie
Side-by-side diff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector/ofilefactory.cpp40
-rw-r--r--libopie/ofileselector/ofilefactory.h32
-rw-r--r--libopie/ofileselector/ofilelistview.cpp41
-rw-r--r--libopie/ofileselector/ofilelistview.h20
-rw-r--r--libopie/ofileselector/ofileview.h22
-rw-r--r--libopie/ofileselector/olister.cpp48
-rw-r--r--libopie/ofileselector/olister.h4
-rw-r--r--libopie/ofileselector/opixmapprovider.cpp83
-rw-r--r--libopie/ofileselector/opixmapprovider.h41
9 files changed, 284 insertions, 47 deletions
diff --git a/libopie/ofileselector/ofilefactory.cpp b/libopie/ofileselector/ofilefactory.cpp
new file mode 100644
index 0000000..f752149
--- a/dev/null
+++ b/libopie/ofileselector/ofilefactory.cpp
@@ -0,0 +1,40 @@
+#include "ofilefactory.h"
+
+OFileFactory::OFileFactory() {
+}
+OFileFactory::~OFileFactory() {
+}
+QStringList OFileFactory::lister()const {
+ QStringList list;
+ QMap<QString, listerFact>::ConstIterator it;
+ for ( it = m_lister.begin(); it != m_lister.end(); ++it ) {
+ list << (*it);
+ }
+ return list;
+}
+QStringList OFileFactory::views()const {
+ QStringList list;
+
+
+ return list;
+}
+OFileView* OFileFactory::view( const QString& name,
+ OFileSelector*, QWidget* ) {
+
+}
+OLister* OFileFactory::lister(const QString&, OFileSelector*) {
+
+}
+void OFileFactory::addLister( const QString&, listerFact fact ) {
+
+}
+void OFileFactory::addView( const QString&, viewFact fact ) {
+
+
+}
+void OFileFactory::removeLister( const QString& ) {
+
+}
+void OFileFactory::removeView( const QString& ) {
+
+}
diff --git a/libopie/ofileselector/ofilefactory.h b/libopie/ofileselector/ofilefactory.h
new file mode 100644
index 0000000..96fb00d
--- a/dev/null
+++ b/libopie/ofileselector/ofilefactory.h
@@ -0,0 +1,32 @@
+#ifndef OFILE_FACTORY_H
+#define OFILE_FACTORY_H
+
+#include "olister.h"
+#include "ofileview.h"
+class OFileFactory {
+public:
+ typedef OLister* (*listerFact)(OFileSelector*);
+ typedef OFileView* (*viewFact)(OFileSelector*, QWidget*);
+ OFileFactory();
+ ~OFileFactory();
+
+ QStringList lister()const;
+ QStringList views()const;
+
+ OFileView* view( const QString& name, OFileSelector*, QWidget* );
+ OLister* lister( const QString& name, OFileSelector* );
+
+ void addLister( const QString&, listerFact fact );
+ void addView( const QString&, viewFact );
+
+ void removeLister( const QString& );
+ void removeView( const QString& );
+
+private:
+ QMap<QString, listerFact> m_lister;
+ QMap<QString, viewFact> m_view;
+
+};
+
+
+#endif
diff --git a/libopie/ofileselector/ofilelistview.cpp b/libopie/ofileselector/ofilelistview.cpp
index bb15764..691bf42 100644
--- a/libopie/ofileselector/ofilelistview.cpp
+++ b/libopie/ofileselector/ofilelistview.cpp
@@ -22,122 +22,107 @@ OFileListView::OFileListView( QWidget* parent, OFileSelector* sel)
addColumn(tr("Mime Type"), -1 );
QHeader *head = header();
head->hide();
setSorting( 1 );
setAllColumnsShowFocus( TRUE );
connect(this, SIGNAL(selectionChanged() ),
this, SLOT(slotSelectionChanged() ) );
connect(this, SIGNAL(currentChanged(QListViewItem *) ),
this, SLOT(slotCurrentChanged(QListViewItem * ) ) );
connect(this, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ),
this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) );
connect(this, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )),
this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) );
}
OFileListView::~OFileListView() {
}
void OFileListView::clear() {
QListView::clear();
}
-void OFileListView::addFile( const QString&,
+void OFileListView::addFile( const QPixmap& pix,
+ const QString&,
QFileInfo* info,
bool isSymlink ) {
- MimeType type( info->absFilePath() );
- QPixmap pix = type.pixmap();
QString dir;
QString name;
bool locked = false;
- if( pix.isNull() )
- pix = Resource::loadPixmap( "UnknownDocument-14");
-
dir = info->dirPath( true );
if( isSymlink )
name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink();
else {
name = info->fileName();
if( ( selector()->mode() == OFileSelector::Open && !info->isReadable() ) ||
( selector()->mode() == OFileSelector::Save && !info->isWritable() ) ){
- locked = true; pix = Resource::loadPixmap("locked");
+ locked = true;
}
}
new OFileSelectorItem( this, pix, name,
info->lastModified().toString(),
QString::number( info->size() ),
dir, locked );
}
-void OFileListView::addFile( const QString& /*mime*/, const QString& /*dir*/,
+void OFileListView::addFile( const QPixmap&,
+ const QString& /*mime*/, const QString& /*dir*/,
const QString& /*file*/, bool /*isSyml*/ ) {
}
-void OFileListView::addDir( const QString&,
+void OFileListView::addDir( const QPixmap& pix, const QString&,
QFileInfo* info, bool symlink ) {
bool locked = false;
QString name;
- QPixmap pix;
-
- if( ( selector()->mode() == OFileSelector::Open && !info->isReadable() ) ||
- ( selector()->mode() == OFileSelector::Save && !info->isWritable() ) ){
-
- locked = true;
-
- if( symlink )
- pix = selector()->pixmap("symlinkedlocked");
- else
- pix = Resource::loadPixmap("lockedfolder");
-
- }else { // readable
- pix = symlink ? selector()->pixmap("dirsymlink") : Resource::loadPixmap("folder") ;
- }
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 QString& /*mime*/, const QString& /*dir*/,
+void OFileListView::addDir( const QPixmap&,
+ const QString& /*mime*/, const QString& /*dir*/,
const QString& /*file*/, bool ) {
}
-void OFileListView::addSymlink( const QString& /*mime*/,
+void OFileListView::addSymlink( const QPixmap&,
+ const QString& /*mime*/,
QFileInfo* /*info*/,
bool /*isSym*/ ) {
}
-void OFileListView::addSymlink( const QString& /*mime*/, const QString& /*path*/,
- const QString& /*file*/, bool /*isSym*/ ) {
+void OFileListView::addSymlink(const QPixmap&,
+ const QString& /*m*/, const QString& /*path*/,
+ const QString& /*file*/, bool /*isSym*/ ) {
}
void OFileListView::cd( const QString& ) {
}
QWidget* OFileListView::widget() {
return this;
}
QString OFileListView::selectedName()const{
QListViewItem *item = currentItem();
if (!item )
return QString::null;
return item->text( 1 );
}
QStringList OFileListView::selectedNames()const {
QStringList list;
list << selectedName();
return list;
}
QString OFileListView::selectedPath()const {
return QString::null;
}
QStringList OFileListView::selectedPaths()const {
diff --git a/libopie/ofileselector/ofilelistview.h b/libopie/ofileselector/ofilelistview.h
index a83d70d..c8cdfd1 100644
--- a/libopie/ofileselector/ofilelistview.h
+++ b/libopie/ofileselector/ofilelistview.h
@@ -1,50 +1,58 @@
#ifndef OPIE_FILE_LIST_VIEW_H
#define OPIE_FILE_LIST_VIEW_H
#include <qlistview.h>
+#include <qpixmap.h>
#include "ofileview.h"
class OFileListView : public QListView, public OFileView {
Q_OBJECT
public:
OFileListView( QWidget* parent, OFileSelector* );
~OFileListView();
void clear();
- void addFile( const QString& mine,
+ void addFile( const QPixmap&,
+ const QString& mine,
QFileInfo* info,
bool isSymlink = FALSE );
- void addFile( const QString& mime,
+ void addFile( const QPixmap&,
+ const QString& mime,
const QString& dir,
const QString& file,
bool = false );
- void addDir( const QString& mime,
+ void addDir( const QPixmap&,
+ const QString& mime,
QFileInfo* info, bool = FALSE );
- void addDir( const QString& mime, const QString& dir,
+
+ void addDir( const QPixmap&,
+ const QString& mime, const QString& dir,
const QString& file, bool = FALSE );
- void addSymlink( const QString& mime,
+ void addSymlink( const QPixmap&,
+ const QString& mime,
QFileInfo* info, bool = FALSE );
- void addSymlink( const QString& mine, const QString& path,
+ void addSymlink( const QPixmap&,
+ const QString& mine, const QString& path,
const QString& file, bool isSymlink = FALSE );
void cd( const QString& path );
QWidget* widget();
void sort();
QString selectedName()const ;
QStringList selectedNames()const;
QString selectedPath()const;
QStringList selectedPaths()const;
int fileCount();
private slots:
void slotSelectionChanged();
void slotCurrentChanged(QListViewItem* );
void slotClicked( int, QListViewItem*, const QPoint&, int );
void slotRightButton(int, QListViewItem*, const QPoint&, int );
};
#endif
diff --git a/libopie/ofileselector/ofileview.h b/libopie/ofileselector/ofileview.h
index a4b1748..d7ea4a2 100644
--- a/libopie/ofileselector/ofileview.h
+++ b/libopie/ofileselector/ofileview.h
@@ -32,80 +32,90 @@
#include <qobject.h>
#include <qwidget.h>
#include <qpopupmenu.h>
class QFileInfo;
class QDir;
class DocLnk;
/**
* A OFileView is a specialised View for the
* OFileSelector
* With a View you can chage the user visible
* representation of a OFileLister
* OFileView is just a basic interface which helps you to
* write new views
*/
class OFileSelector;
class OFileView {
public:
OFileView( OFileSelector* );
OFileView();
virtual ~OFileView();
virtual void clear() = 0;
- virtual void addFile(const QString &mine,
+ virtual void addFile(const QPixmap&,
+ const QString &mine,
QFileInfo *info,
bool isSymlink = FALSE ) = 0;
- virtual void addFile(const QString& mine, const QString& dir,
+
+ virtual void addFile(const QPixmap&,
+ const QString& mine, const QString& dir,
const QString& file, bool = FALSE ) = 0;
- virtual void addDir (const QString &mine,
+ virtual void addDir (const QPixmap&,
+ const QString &mine,
QFileInfo *info,
bool isSymlink = FALSE ) = 0;
- virtual void addDir (const QString& mine, const QString& dir,
+ virtual void addDir (const QPixmap&,
+ const QString& mine, const QString& dir,
const QString& file, bool = FALSE) = 0;
- virtual void addSymlink(const QString &mime,
+ virtual void addSymlink(const QPixmap&,
+ const QString &mime,
QFileInfo *info,
bool isSymlink = FALSE ) = 0;
- virtual void addSymlink(const QString& mine,
+
+ virtual void addSymlink(const QPixmap&,
+ const QString& mine,
const QString& path,
const QString& file,
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 & );
+
+ /* updates the file name line of the FileSelector */
void updateLine( const QString& );
OFileSelector* selector()const;
private:
OFileSelector* m_sel;
};
class OFileViewFactory {
public:
OFileViewFactory() {} ;
virtual ~OFileViewFactory() = 0;
OFileView* newView(QWidget *parent, const char *name );
QString name()const;
};
#endif
diff --git a/libopie/ofileselector/olister.cpp b/libopie/ofileselector/olister.cpp
index 6c43043..b6b03cd 100644
--- a/libopie/ofileselector/olister.cpp
+++ b/libopie/ofileselector/olister.cpp
@@ -1,72 +1,106 @@
#include "olister.h"
#include "ofileview.h"
+#include "opixmapprovider.h"
#include "ofileselector.h"
OLister::OLister( OFileSelector* view)
: m_view( view )
{
+ m_prov = new OPixmapProvider( view );
}
OLister::~OLister() {
+ delete m_prov;
+}
+void OLister::setPixmapProvider( OPixmapProvider* prov ) {
+ delete m_prov;
+ m_prov = 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,
bool isSymlink ) {
- view()->currentView()->addFile( mine,
+ int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink :
+ OPixmapProvider::File;
+ QPixmap pix = provider()->pixmap(t, mine,
+ info);
+ view()->currentView()->addFile( pix,
+ mine,
info,
isSymlink );
}
void OLister::addFile( const QString& mine,
const QString& path,
const QString& file,
bool isSymlink ) {
- view()->currentView()->addFile( mine,
+ int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink :
+ OPixmapProvider::File;
+
+ QPixmap pix = provider()->pixmap(t, mine, path, file );
+ view()->currentView()->addFile( pix,
+ mine,
path,
file,
isSymlink );
}
void OLister::addDir( const QString& mine,
QFileInfo* info,
bool isSymlink ) {
-
- view()->currentView()->addDir( mine,
+ int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink :
+ OPixmapProvider::Dir;
+ QPixmap pix = provider()->pixmap(t, mine, info );
+ view()->currentView()->addDir( pix,
+ mine,
info,
isSymlink );
}
void OLister::addDir( const QString& mine,
const QString& path,
const QString& dir,
bool isSymlink ) {
- view()->currentView()->addDir( mine,
+
+ int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink :
+ OPixmapProvider::Dir;
+ QPixmap pix = provider()->pixmap(t, mine, path, dir );
+
+ view()->currentView()->addDir( pix,
+ mine,
path,
dir,
isSymlink );
}
void OLister::addSymlink( const QString& mine,
QFileInfo* info,
bool isSymlink ) {
- view()->currentView()->addSymlink( mine,
+ QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, info );
+ view()->currentView()->addSymlink( pix,
+ mine,
info,
isSymlink );
}
void OLister::addSymlink( const QString& mine,
const QString& path,
const QString& name,
bool isSymlink ) {
- view()->currentView()->addSymlink( mine,
+ QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine,
+ path, name );
+ view()->currentView()->addSymlink( pix,
+ mine,
path,
name,
isSymlink );
}
OFileSelector* OLister::view() {
return m_view;
}
+OPixmapProvider* OLister::provider() {
+ return m_prov;
+}
bool OLister::compliesMime( const QString& mime ) {
return view()->compliesMime( mime );
}
diff --git a/libopie/ofileselector/olister.h b/libopie/ofileselector/olister.h
index ef61cab..0885525 100644
--- a/libopie/ofileselector/olister.h
+++ b/libopie/ofileselector/olister.h
@@ -1,60 +1,64 @@
#ifndef OPIE_FILE_LISTER_H
#define OPIE_FILE_LISTER_H
#include <qfileinfo.h>
#include <qmap.h>
#include <qstring.h>
#include <qstringlist.h>
+class OPixmapProvider;
class OFileSelector;
/**
* 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* );
protected:
bool showFiles()const;
bool showDirs()const;
bool compliesMime( const QString& mime );
void addFile( const QString& mine,
QFileInfo*,
bool isSymlink = FALSE );
void addFile( const QString& mine,
const QString& path,
const QString& file,
bool isSymlink = FALSE );
void addDir( const QString& mine,
QFileInfo*,
bool isSymlink = FALSE );
void addDir( const QString& mine,
const QString& path,
const QString& dir,
bool isSymlink = FALSE );
void addSymlink( const QString& mine,
QFileInfo* info,
bool isSymlink = FALSE);
void addSymlink( const QString& mine,
const QString& path,
const QString& name,
bool isSymlink = FALSE );
OFileSelector* view();
+ OPixmapProvider* provider();
private:
OFileSelector* m_view;
+ OPixmapProvider* m_prov;
};
#endif
diff --git a/libopie/ofileselector/opixmapprovider.cpp b/libopie/ofileselector/opixmapprovider.cpp
new file mode 100644
index 0000000..b363e01
--- a/dev/null
+++ b/libopie/ofileselector/opixmapprovider.cpp
@@ -0,0 +1,83 @@
+#include <qfileinfo.h>
+
+#include <qpe/mimetype.h>
+#include <qpe/resource.h>
+
+#include "opixmapprovider.h"
+
+
+
+OPixmapProvider::OPixmapProvider( OFileSelector* sel )
+ : m_sel( sel ){
+}
+OPixmapProvider::~OPixmapProvider() {
+}
+QPixmap OPixmapProvider::pixmap( int t, const QString& ,
+ QFileInfo* info, bool isL ) {
+ QPixmap pix;
+ bool sy = t & Symlink ? true : false;
+ switch (t ) {
+ case File:
+ pix = file( info, sy, isL );
+ break;
+ case Dir:
+ pix = dir( info, sy, isL );
+ break;
+ case Symlink:
+ pix = sym( info, isL );
+ break;
+ }
+ return pix;
+
+}
+QPixmap OPixmapProvider::pixmap( int t, const QString& mime,
+ const QString& dir, const QString& file,
+ bool isL) {
+ QFileInfo *inf = new QFileInfo( dir + "/" + file );
+ QPixmap pix = pixmap( t, mime, inf, isL );
+ delete inf;
+ return pix;
+}
+OFileSelector* OPixmapProvider::selector() {
+ return m_sel;
+}
+QPixmap OPixmapProvider::file( QFileInfo* inf, bool , bool ) {
+ MimeType type( inf->absFilePath() );
+ QPixmap pix = type.pixmap();
+
+ if ( pix.isNull() )
+ pix = Resource::loadPixmap( "UnknownDocument-14");
+
+ if ( (selector()->mode() == OFileSelector::Open &&
+ !inf->isReadable() ) ||
+ (selector()->mode() == OFileSelector::Save &&
+ !inf->isWritable() ) ) {
+ pix = Resource::loadPixmap( "locked" );
+ }
+ return pix;
+
+}
+QPixmap OPixmapProvider::dir( QFileInfo* inf, bool sym, bool ) {
+ QPixmap pix;
+ /*
+ * look at selector()->mode() and determine
+ * if a dir is locked
+ */
+ if ( (selector()->mode() == OFileSelector::Open &&
+ !inf->isReadable() ) ||
+ (selector()->mode() == OFileSelector::Save &&
+ !inf->isWritable() ) ) {
+ if ( sym )
+ pix = selector()->pixmap("symlinkedlocked");
+ else
+ pix = Resource::loadPixmap("lockedfolder");
+ }else {
+ pix = sym ? selector()->pixmap("lockedfolder") :
+ Resource::loadPixmap("folder");
+
+ }
+ return pix;
+}
+QPixmap OPixmapProvider::sym( QFileInfo* , bool ) {
+ return Resource::loadPixmap("opie/symlink");
+}
diff --git a/libopie/ofileselector/opixmapprovider.h b/libopie/ofileselector/opixmapprovider.h
new file mode 100644
index 0000000..2165fdb
--- a/dev/null
+++ b/libopie/ofileselector/opixmapprovider.h
@@ -0,0 +1,41 @@
+#ifndef OPIE_PIXMPAP_PROVIDER
+#define OPIE_PIXMPAP_PROVIDER
+
+#include <qpixmap.h>
+
+#include "ofileselector.h"
+
+/**
+ * This is a basic interface for a Pixmap provider
+ * it provides pixmaps for a URL
+ * So the OLocalLister provides mimetype icons
+ */
+class QFileInfo;
+class OPixmapProvider {
+public:
+ /* you can or these
+ * but File | Dir would be insane ;)
+ */
+ enum Type { File = 0, Dir = 1, Symlink = 2 };
+ OPixmapProvider( OFileSelector* sel );
+ virtual ~OPixmapProvider();
+
+ virtual QPixmap pixmap( int t, const QString& mime, QFileInfo*,
+ bool isLocked = FALSE );
+ virtual QPixmap pixmap( int t, const QString& mime,
+ const QString& dir, const QString& file,
+ bool isLocked = FALSE );
+
+protected:
+ OFileSelector* selector();
+private:
+ QPixmap file( QFileInfo*,
+ bool sym, bool is );
+ QPixmap dir ( QFileInfo*,
+ bool sym, bool is );
+ QPixmap sym ( QFileInfo*,
+ bool is );
+ OFileSelector* m_sel;
+};
+
+#endif