summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp10
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.h1
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp2
-rw-r--r--noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp14
-rw-r--r--noncore/graphics/opie-eye/impl/dir/dir_dirview.h2
-rw-r--r--noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp32
-rw-r--r--noncore/graphics/opie-eye/impl/dir/dir_lister.cpp53
-rw-r--r--noncore/graphics/opie-eye/impl/dir/dir_lister.h12
8 files changed, 96 insertions, 30 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index 7c8c88d..eafff1d 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -28,512 +28,518 @@
#include <qcombobox.h>
#include <qdir.h>
#include <qapplication.h>
#include <qmainwindow.h>
#include <qtimer.h>
#include <qstyle.h>
using Opie::Core::OKeyConfigItem;
/*
* The Icons, Request Cache and IconViewItem for the IconView
*/
namespace {
static QPixmap* _dirPix = 0;
static QPixmap* _unkPix = 0;
static QPixmap* _emptyPix = 0;
class IconViewItem : public QIconViewItem {
public:
IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false);
QPixmap* pixmap()const;
QString path()const { return m_path; }
bool isDir()const { return m_isDir; }
void setText( const QString& );
bool textOnly()const{return m_textOnly;}
void setTextOnly(bool how){m_textOnly=how;}
/* just for starting recalc of item rect! */
virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE );
/* just for starting recalc of item rect! */
virtual void setPixmap( const QPixmap & icon);
protected:
mutable QPixmap* m_pix;
private:
QString m_path;
bool m_isDir : 1;
bool m_noInfo :1;
bool m_textOnly:1;
bool m_NameOnly:1;
bool m_Pixset:1;
};
class TextViewItem : public IconViewItem {
TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false );
QPixmap *pixmap()const;
void setText( const QString& );
};
class ThumbViewItem : public IconViewItem {
ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false );
QPixmap *pixmap()const;
void setText( const QString& );
};
/*
* If we request an Image or String
* we add it to the map
*/
static QMap<QString, IconViewItem*> g_stringInf;
static QMap<QString, IconViewItem*> g_stringPix;
IconViewItem::IconViewItem( QIconView* view,const QString& path,
const QString& name, bool isDir )
: QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ),
m_noInfo( false ),m_textOnly(false),m_Pixset(false)
{
if ( isDir && !_dirPix )
_dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser"));
else if ( !isDir && !_unkPix )
_unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) );
}
inline void IconViewItem::setPixmap( const QPixmap & , bool, bool )
{
m_Pixset = true;
calcRect(text());
}
inline void IconViewItem::setPixmap( const QPixmap & )
{
m_Pixset = true;
calcRect(text());
}
inline QPixmap* IconViewItem::pixmap()const {
// owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y()
// << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX()
// << " " << iconView()->contentsY() << oendl;
if (textOnly()&&!m_isDir) {
if (!_emptyPix) _emptyPix = new QPixmap(0,0,1);
return _emptyPix;
}
if ( m_isDir )
return _dirPix;
else{
if (!m_noInfo && !g_stringInf.contains( m_path ) ) {
currentView()->dirLister()->imageInfo( m_path );
g_stringInf.insert( m_path, const_cast<IconViewItem*>(this));
}
m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 );
if (!m_pix && !g_stringPix.contains( m_path )) {
currentView()->dirLister()->thumbNail( m_path, 64, 64 );
g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
}
return m_pix ? m_pix : _unkPix;
}
}
inline void IconViewItem::setText( const QString& str ) {
QString text = QIconViewItem::text()+"\n"+str;
m_noInfo = true;
QIconViewItem::setText( text );
}
}
/*
* Set up the GUI.. initialize the slave set up gui
* and also load a dir
*/
PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg )
: QVBox( wid ), m_cfg( cfg ), m_updatet( false )
{
{
QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
}
m_path = QDir::homeDirPath();
m_mode = 0;
+ m_internalReset = false;
QHBox *hbox = new QHBox( this );
QLabel* lbl = new QLabel( hbox );
lbl->setText( tr("View as" ) );
m_views = new QComboBox( hbox, "View As" );
m_view= new QIconView( this );
connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
this, SLOT(slotClicked(QIconViewItem*)) );
connect(m_view, SIGNAL(returnPressed(QIconViewItem*)),
this, SLOT(slotClicked(QIconViewItem*)) );
m_view->setArrangement( QIconView::LeftToRight );
m_mode = m_cfg->readNumEntry("ListViewMode", 1);
QString lastView = m_cfg->readEntry("LastView","");
if (m_mode < 1 || m_mode>3) m_mode = 1;
m_view->setItemTextPos( QIconView::Right );
calculateGrid();
initKeys();
loadViews();
int cc=0;
for (; cc<m_views->count();++cc) {
if (m_views->text(cc)==lastView) {
break;
}
}
if (cc<m_views->count()) {
m_views->setCurrentItem(cc);
slotViewChanged(cc);
} else {
slotViewChanged(m_views->currentItem());
}
connect( m_views, SIGNAL(activated(int)),
this, SLOT(slotViewChanged(int)) );
}
/*
* Unref the slave and save the keyboard manager
*/
PIconView::~PIconView() {
{
QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
}
m_viewManager->save();
delete m_viewManager;
}
Opie::Core::OKeyConfigManager* PIconView::manager() {
return m_viewManager;
}
/*
* init the KeyBoard Shortcuts
* called from the c'tor
*/
void PIconView::initKeys() {
Opie::Core::OKeyPair::List lst;
lst.append( Opie::Core::OKeyPair::upArrowKey() );
lst.append( Opie::Core::OKeyPair::downArrowKey() );
lst.append( Opie::Core::OKeyPair::leftArrowKey() );
lst.append( Opie::Core::OKeyPair::rightArrowKey() );
lst.append( Opie::Core::OKeyPair::returnKey() );
m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config",
lst, false,this, "keyconfig name" );
m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam",
Resource::loadPixmap("beam"), BeamItem,
Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton),
this, SLOT(slotBeam())) );
m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete",
Resource::loadPixmap("trash"), DeleteItem,
Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton),
this, SLOT(slotTrash())) );
m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view",
Resource::loadPixmap("1to1"), ViewItem,
Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton),
this, SLOT(slotShowImage())));
m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info",
Resource::loadPixmap("DocumentTypeWord"), InfoItem,
Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ),
this, SLOT(slotImageInfo()) ) );
m_viewManager->addKeyConfig( OKeyConfigItem(tr("Start slideshow"), "slideshow",
Resource::loadPixmap("1to1"), SlideItem,
Opie::Core::OKeyPair(Qt::Key_S, Qt::ShiftButton),
this, SLOT(slotStartSlide())));
m_viewManager->load();
m_viewManager->handleWidget( m_view );
}
/*
* change one dir up
*/
void PIconView::slotDirUp()
{
slotChangeDir( currentView()->dirLister()->dirUp( m_path ) );
}
/*
* change the dir
*/
void PIconView::slotChangeDir(const QString& path) {
if ( !currentView() )
return;
PDirLister *lister = currentView()->dirLister();
if (!lister )
return;
/*
* Say what we want and take what we get
*/
lister->setStartPath( path );
m_path = lister->currentPath();
m_view->viewport()->setUpdatesEnabled( false );
m_view->clear();
/*
* add files and folders
*/
addFolders( lister->folders() );
addFiles( lister->files() );
m_view->viewport()->setUpdatesEnabled( true );
// Also invalidate the cache. We can't cancel the operations anyway
g_stringPix.clear();
g_stringInf.clear();
// looks ugly
static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
}
/**
* get the current file name
* @param isDir see if this is a dir or real file
*/
QString PIconView::currentFileName(bool &isDir)const {
isDir = false;
QIconViewItem* _it = m_view->currentItem();
if ( !_it )
return QString::null;
IconViewItem* it = static_cast<IconViewItem*>( _it );
isDir = it->isDir();
return it->path();
}
QString PIconView::nextFileName(bool &isDir)const
{
isDir = false;
QIconViewItem* _it1 = m_view->currentItem();
if ( !_it1 )
return QString::null;
QIconViewItem* _it = _it1->nextItem();
if ( !_it )
return QString::null;
IconViewItem* it = static_cast<IconViewItem*>( _it );
isDir = it->isDir();
return it->path();
}
QString PIconView::prevFileName(bool &isDir)const{
isDir = false;
QIconViewItem* _it = m_view->currentItem();
if ( !_it )
return QString::null;
_it = _it->prevItem();
if ( !_it )
return QString::null;
IconViewItem* it = static_cast<IconViewItem*>( _it );
isDir = it->isDir();
return it->path();
}
void PIconView::slotTrash() {
bool isDir;
QString pa = currentFileName( isDir );
if ( isDir && pa.isEmpty() )
return;
if (!QPEMessageBox::confirmDelete( this,
tr("Delete Image" ),
tr("the Image %1" ).arg(pa)))
return
currentView()->dirLister()->deleteImage( pa );
delete m_view->currentItem();
}
/*
* see what views are available
*/
void PIconView::loadViews() {
ViewMap::Iterator it;
ViewMap* map = viewMap();
for ( it = map->begin(); it != map->end(); ++it )
m_views->insertItem( it.key() );
}
void PIconView::resetView() {
+ m_internalReset = true;
slotViewChanged(m_views->currentItem());
+ m_internalReset = false;
}
/*
*swicth view reloadDir and connect signals
*/
void PIconView::slotViewChanged( int i) {
if (!m_views->count() ) {
setCurrentView( 0l);
return;
}
PDirView* cur = currentView();
if (cur) delete cur;
QString str = m_views->text(i);
ViewMap* map = viewMap();
if (!map) {
setCurrentView(0l);
return;
}
if (map->find(str) == map->end()) {
owarn << "Key not found" << oendl;
setCurrentView(0l);
return;
}
m_cfg->writeEntry("LastView",str);
m_cfg->write();
cur = (*(*map)[str])(*m_cfg);
setCurrentView( cur );
/* connect to the signals of the lister */
PDirLister* lis = cur->dirLister();
connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )),
this, SLOT( slotThumbInfo(const QString&, const QString&)));
connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
connect(lis, SIGNAL(sig_start()),
this, SLOT(slotStart()));
connect(lis, SIGNAL(sig_end()) ,
this, SLOT(slotEnd()) );
- /* reload now with default Path*/
- m_path = lis->defaultPath();
+ /* reload now with default Path
+ * but only if it isn't a reset like from setupdlg
+ */
+ if (!m_internalReset)
+ m_path = lis->defaultPath();
QTimer::singleShot( 0, this, SLOT(slotReloadDir()));
}
void PIconView::slotReloadDir() {
slotChangeDir( m_path );
}
/*
* add files and folders
*/
void PIconView::addFolders( const QStringList& lst) {
QStringList::ConstIterator it;
IconViewItem * _iv;
for(it=lst.begin(); it != lst.end(); ++it ) {
_iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true );
if (m_mode==3) _iv->setTextOnly(true);
}
}
void PIconView::addFiles( const QStringList& lst) {
QStringList::ConstIterator it;
IconViewItem * _iv;
QPixmap*m_pix = 0;
QString pre = "";
if (!m_path.isEmpty()) {
pre = m_path+"/";
}
for (it=lst.begin(); it!= lst.end(); ++it ) {
m_pix = PPixmapCache::self()->cachedImage( pre+(*it), 64, 64 );
_iv = new IconViewItem( m_view, pre+(*it), (*it) );
if (m_mode==3) {
_iv->setTextOnly(true);
_iv->setPixmap(QPixmap());
} else {
if (m_pix) _iv->setPixmap(*m_pix);
}
}
}
/*
* user clicked on the item. Change dir or view
*/
void PIconView::slotClicked(QIconViewItem* _it) {
if(!_it )
return;
IconViewItem* it = static_cast<IconViewItem*>(_it);
if( it->isDir() )
slotChangeDir( it->path() );
else // view image
slotShowImage();
}
/*
* Return was pressed. which is triggered by the keydown
* handler. The problem is that the key up will be handled
* by the ImageDisplayer and goes to the next image
*/
void PIconView::slotRetrun( QIconViewItem *_it ) {
if(!_it )
return;
IconViewItem* it = static_cast<IconViewItem*>(_it);
if( it->isDir() )
slotChangeDir( it->path() );
else
QTimer::singleShot(0, this, SLOT(slotShowImage()) );
}
/*
* got thumb info add to the cache if items is visible
* we later need update after processing of slave is done
*/
void PIconView::slotThumbInfo( const QString& _path, const QString& str ) {
IconViewItem* item = g_stringInf[_path];
if (!item )
return;
if (m_mode == 2) {
return;
}
if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
m_view->contentsWidth(), m_view->contentsHeight() ) ) )
m_updatet = true;
item->setText( str );
g_stringInf.remove( _path );
}
/*
* got thumbnail and see if it is visible so we need to update later
*/
void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) {
IconViewItem* item = g_stringPix[_path];
if (!item )
return;
if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(),
m_view->contentsWidth(), m_view->contentsHeight() ) ) )
m_updatet = true;
if (pix.width()>0) {
PPixmapCache::self()->insertImage( _path, pix, 64, 64 );
item->setPixmap(pix,true);
} else {
PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), 64, 64 );
}
g_stringPix.remove( _path );
}
/*
* FIXME rename
*/
void PIconView::slotRename() {
}
/*
* BEAM the current file
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h
index dff55ed..bea35c2 100644
--- a/noncore/graphics/opie-eye/gui/iconview.h
+++ b/noncore/graphics/opie-eye/gui/iconview.h
@@ -1,100 +1,101 @@
/*
* GPLv2 zecke@handhelds.org
* No WArranty...
*/
#ifndef PHUNK_ICON_VIEW_H
#define PHUNK_ICON_VIEW_H
#include <qvbox.h>
class QIconView;
class QIconViewItem;
class QComboBox;
class PIconViewItem;
class PDirLister;
class Ir;
namespace Opie {
namespace Core{
class OConfig;
class OKeyConfigManager;
}
}
class PIconView : public QVBox {
Q_OBJECT
friend class PIconViewItem;
enum ActionIds {
BeamItem, DeleteItem, ViewItem, InfoItem,SlideItem
};
public:
PIconView( QWidget* wid, Opie::Core::OConfig *cfg );
~PIconView();
void resetView();
Opie::Core::OKeyConfigManager* manager();
signals:
void sig_showInfo( const QString& );
void sig_display(const QString&);
void sig_startslide(int timeout);
public slots:
virtual void slotShowNext();
virtual void slotShowPrev();
virtual void slotShowLast();
virtual bool slotShowFirst();
protected:
void resizeEvent( QResizeEvent* );
private:
void initKeys();
QString currentFileName(bool &isDir)const;
QString nextFileName(bool &isDir)const;
QString prevFileName(bool &isDir)const;
void loadViews();
void calculateGrid();
private slots:
void slotDirUp();
void slotChangeDir(const QString&);
void slotTrash();
void slotViewChanged( int );
void slotReloadDir();
void slotRename();
void slotBeam();
void slotBeamDone( Ir* );
void slotShowImage();
void slotShowImage( const QString& );
void slotImageInfo();
void slotImageInfo( const QString& );
void slotStartSlide();
void slotStart();
void slotEnd();
/* for performance reasons make it inline in the future */
void addFolders( const QStringList& );
void addFiles( const QStringList& );
void slotClicked(QIconViewItem* );
void slotRetrun(QIconViewItem* );
/**/
void slotThumbInfo(const QString&, const QString&);
void slotThumbNail(const QString&, const QPixmap&);
void slotChangeMode( int );
private:
Opie::Core::OKeyConfigManager *m_viewManager;
Opie::Core::OConfig *m_cfg;
QComboBox* m_views;
QIconView* m_view;
QString m_path;
bool m_updatet : 1;
int m_mode;
+ bool m_internalReset:1;
};
#endif
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index 6660eb2..30c9bf1 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -48,263 +48,265 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
readConfig();
m_storage = new StorageInfo();
connect(m_storage, SIGNAL(disksChanged() ),
this, SLOT( dirChanged() ) );
m_stack = new Opie::Ui::OWidgetStack( this );
setCentralWidget( m_stack );
m_view = new PIconView( m_stack, m_cfg );
m_stack->addWidget( m_view, IconView );
m_stack->raiseWidget( IconView );
connect(m_view, SIGNAL(sig_display(const QString&)),
this, SLOT(slotDisplay(const QString&)));
connect(m_view, SIGNAL(sig_showInfo(const QString&)),
this, SLOT(slotShowInfo(const QString&)) );
connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int)));
m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce);
listviewMenu = 0;
/* setup menu and toolbar */
setupActions();
setupToolbar();
setupMenu();
m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true));
m_aAutoRotate->setEnabled(!m_aUnscaled->isOn());
}
PMainWindow::~PMainWindow() {
}
void PMainWindow::slotToggleZoomer()
{
m_aZoomer->setOn(!m_aZoomer->isOn());
}
void PMainWindow::slotZoomerToggled(bool how)
{
if (m_disp) {
m_disp->setShowZoomer(how);
}
if (autoSave) {
m_cfg->writeEntry("zoomeron",how);
}
}
void PMainWindow::slotToggleAutorotate()
{
if (!m_aAutoRotate->isEnabled()) return;
m_aAutoRotate->setOn(!m_aAutoRotate->isOn());
}
void PMainWindow::slotToggleAutoscale()
{
m_aUnscaled->setOn(!m_aUnscaled->isOn());
}
void PMainWindow::slotRotateToggled(bool how)
{
if (autoSave) {
m_cfg->writeEntry("autorotate",how);
}
if (m_disp) {
m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how);
}
}
void PMainWindow::slotScaleToggled(bool how)
{
if (autoSave) {
m_cfg->writeEntry("unscaled",how);
}
odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl;
odebug << "How: " << how << oendl;
if (how) {
m_aAutoRotate->setOn(false);
}
if (m_disp) {
m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),m_aAutoRotate->isOn());
}
m_aAutoRotate->setEnabled(!how);
odebug << "Autorotate: " << m_aAutoRotate->isOn() << oendl;
}
void PMainWindow::slotConfig() {
/*
* have a tab with the possible views
* a tab for globals image cache size.. scaled loading
* and one tab for the KeyConfigs
*/
QDialog dlg(this, 0, true);
dlg.setCaption( tr("Opie Eye - Config" ) );
QHBoxLayout *lay = new QHBoxLayout(&dlg);
Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg );
lay->addWidget( wid );
BaseSetup*bSetup = new BaseSetup(m_cfg,wid);
wid->addTab(bSetup,"SettingsIcon","Basics setup");
ViewMap *vM = viewMap();
ViewMap::Iterator _it = vM->begin();
QMap<PDirView*, QWidget*> lst;
for( ; _it != vM->end(); ++_it ) {
PDirView *view = (_it.data())(*m_cfg);
PInterfaceInfo *inf = view->interfaceInfo();
QWidget *_wid = inf->configWidget( *m_cfg );
if (!_wid) continue;
_wid->reparent(wid, QPoint() );
lst.insert( view, _wid );
wid->addTab( _wid, "fileopen", inf->name() );
}
/*
* Add the KeyConfigWidget
*/
Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" );
keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue );
keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() );
QWidget*w = m_stack->visibleWidget();
bool reminfo = false;
if ( !m_info ) {
reminfo = true;
initInfo();
+ m_info->hide();
}
keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() );
bool remdisp = false;
if ( !m_disp ) {
remdisp = true;
initDisp();
+ m_disp->hide();
}
keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() );
keyWid->load();
wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") );
wid->setCurrentTab(0);
bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
/*
* clean up
*apply changes
*/
QMap<PDirView*, QWidget*>::Iterator it;
for ( it = lst.begin(); it != lst.end(); ++it ) {
if ( act )
it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg);
delete it.key();
}
if ( act ) {
m_view->resetView();
keyWid->save();
m_disp->manager()->save();
m_info->manager()->save();
m_view->manager()->save();
bSetup->save_values();
readConfig();
}
delete keyWid;
m_stack->raiseWidget(w);
if (remdisp) {
m_disp->hide();
}
if (reminfo) {
m_info->hide();
}
}
/*
* create a new image info component
* and detach the current one
* we will make the other delete on exit
*/
template<class T>
void PMainWindow::initT( const char* name, T** ptr, int id) {
if ( *ptr ) {
(*ptr)->disconnect(this, SLOT(slotReturn()));
(*ptr)->setDestructiveClose();
m_stack->removeWidget( *ptr );
}
*ptr = new T(m_cfg, m_stack, name );
m_stack->addWidget( *ptr, id );
connect(*ptr, SIGNAL(sig_return()),
this,SLOT(slotReturn()));
}
void PMainWindow::initInfo() {
initT<imageinfo>( "Image Info", &m_info, ImageInfo );
connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&)));
}
void PMainWindow::initDisp() {
initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay );
if (m_disp) {
if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
m_disp->setMinimumSize(QApplication::desktop()->size()/2);
}
m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType);
m_disp->setAutoScale(!m_aUnscaled->isOn());
m_disp->setAutoRotate(m_aAutoRotate->isOn());
m_disp->setShowZoomer(m_aZoomer->isOn());
m_disp->setBackgroundColor(white);
connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&)));
connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext()));
connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev()));
connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen()));
connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView()));
connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer()));
connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale()));
connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate()));
connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int)));
slotFullScreenToggled(m_aFullScreen->isOn());
}
}
void PMainWindow::slotToggleFullScreen()
{
bool current = !m_aFullScreen->isOn();
m_aFullScreen->setOn(current);
}
void PMainWindow::slotFullScreenButton(bool current)
{
if (autoSave) {
m_cfg->writeEntry("fullscreen",current);
}
if (!m_disp) return;
if (m_disp->isVisible()) {
setupViewWindow(current, true);
}
}
void PMainWindow::setupViewWindow(bool current, bool forceDisplay)
{
if (!m_disp) return;
if (current) {
m_disp->setBackgroundColor(black);
m_disp->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0));
m_disp->setVScrollBarMode(QScrollView::AlwaysOff);
m_disp->setHScrollBarMode(QScrollView::AlwaysOff);
m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height());
} else {
setUpdatesEnabled(false);
if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
m_disp->setMinimumSize(QApplication::desktop()->size()/2);
} else {
m_disp->setMinimumSize(10,10);
}
if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
m_disp->reparent(0,QPoint(50,50));
} else {
m_disp->reparent(0,QPoint(0,0));
}
diff --git a/noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp b/noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp
index 97e3dcb..fc502d4 100644
--- a/noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp
+++ b/noncore/graphics/opie-eye/impl/dir/dir_dirview.cpp
@@ -1,29 +1,33 @@
#include "dir_lister.h"
#include "dir_ifaceinfo.h"
#include "dir_dirview.h"
PHUNK_VIEW_INTERFACE("Dir View", Dir_DirView );
Dir_DirView::Dir_DirView( const Config& cfg)
: PDirView(cfg)
{
- m_cfg = cfg.readBoolEntry( "Dir_Check_All_Files", true);
+ m_cfg = cfg.readBoolEntry( "Dir_Check_All_Files", false);
+ m_recursive = cfg.readBoolEntry( "Dir_Check_Recursive_Files", false);
+ m_recursive_depth = cfg.readNumEntry("Dir_Recursive_Files_Depth",10);
m_lister = 0;
m_info = 0;
}
Dir_DirView::~Dir_DirView() {
}
PInterfaceInfo* Dir_DirView::interfaceInfo()const{
- if (!m_info )
- m_info =new DirInterfaceInfo;
+ if (!m_info ) {
+ m_info = new DirInterfaceInfo;
+ }
return m_info;
}
PDirLister* Dir_DirView::dirLister()const{
- if (!m_lister )
- m_lister = new Dir_DirLister(m_cfg);
+ if (!m_lister ) {
+ m_lister = new Dir_DirLister(m_cfg,m_recursive,m_recursive_depth);
+ }
return m_lister;
}
diff --git a/noncore/graphics/opie-eye/impl/dir/dir_dirview.h b/noncore/graphics/opie-eye/impl/dir/dir_dirview.h
index 3b9b7a6..89cf6c9 100644
--- a/noncore/graphics/opie-eye/impl/dir/dir_dirview.h
+++ b/noncore/graphics/opie-eye/impl/dir/dir_dirview.h
@@ -1,24 +1,26 @@
/*
* GPLv2 only zecke@handhelds.org
*/
#ifndef DIR_DIR_VIEW_H
#define DIR_DIR_VIEW_H
#include <iface/dirview.h>
struct Dir_DirView : public PDirView {
Dir_DirView( const Config& );
~Dir_DirView();
PInterfaceInfo* interfaceInfo()const;
PDirLister* dirLister()const;
private:
bool m_cfg : 1;
+ bool m_recursive:1;
+ int m_recursive_depth;
mutable PDirLister* m_lister;
mutable PInterfaceInfo *m_info;
};
#endif
diff --git a/noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp b/noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp
index 9c69ce5..1e4ec40 100644
--- a/noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp
+++ b/noncore/graphics/opie-eye/impl/dir/dir_ifaceinfo.cpp
@@ -1,58 +1,82 @@
/*
* GPLv2
* zecke@handhelds.org
*/
#include "dir_ifaceinfo.h"
/* OPIE */
#include <opie2/odebug.h>
#include <qpe/config.h>
/* QT */
#include <qwidget.h>
#include <qcheckbox.h>
#include <qframe.h>
#include <qhbox.h>
#include <qlabel.h>
#include <qlayout.h>
+#include <qspinbox.h>
namespace {
class DirImageWidget : public QFrame {
public:
DirImageWidget(): QFrame() {
setFrameStyle(Box|Raised);
QVBoxLayout *m_MainLayout = new QVBoxLayout( this, 6, 2, "m_MainLayout");
+ QGridLayout*RecDepthLayout = new QGridLayout( 0, 1, 1, 0, 6, "RecDepthLayout");
+
chkbox = new QCheckBox( QObject::tr("Show all files"), this );
m_MainLayout->addWidget(chkbox);
+ recWarningLabel = new QLabel(this);
+ recWarningLabel->setText(QObject::tr("<center><b>Be carefull with the following options!</b></center>"));
+ m_MainLayout->addWidget(recWarningLabel);
+ recBox = new QCheckBox( QObject::tr("Show files recursive"),this);
+ m_MainLayout->addWidget(recBox);
+ recDepthLabel = new QLabel(this);
+ recDepthLabel->setText(QObject::tr("Recursion depth:"));
+ RecDepthLayout->addWidget(recDepthLabel,0,0);
+ recDepth = new QSpinBox(this);
+ recDepth->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed));
+ recDepth->setMaxValue(10);
+ recDepth->setMinValue(1);
+ recDepth->setSuffix(QObject::tr(" directories"));
+ RecDepthLayout->addWidget(recDepth,0,1);
+ m_MainLayout->addLayout(RecDepthLayout);
QSpacerItem *spacer1 = new QSpacerItem( 20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding );
m_MainLayout->addItem( spacer1 );
}
~DirImageWidget() {}
- QCheckBox* chkbox;
+ QCheckBox* chkbox,*recBox;
+ QSpinBox * recDepth;
+ QLabel* recDepthLabel,*recWarningLabel;
+
};
}
DirInterfaceInfo::DirInterfaceInfo() {
}
DirInterfaceInfo::~DirInterfaceInfo() {
}
QString DirInterfaceInfo::name()const {
return QObject::tr("Directory View" );
}
QWidget* DirInterfaceInfo::configWidget(const Config& cfg) {
DirImageWidget* wid = new DirImageWidget();
- wid->chkbox->setChecked( cfg.readBoolEntry("Dir_Check_All_Files", true) );
-
+ wid->chkbox->setChecked(cfg.readBoolEntry("Dir_Check_All_Files",false));
+ wid->recBox->setChecked(cfg.readBoolEntry("Dir_Check_Recursive_Files",false));
+ wid->recDepth->setValue(cfg.readNumEntry("Dir_Recursive_Files_Depth",10));
return wid;
}
void DirInterfaceInfo::writeConfig( QWidget* _wid, Config& cfg) {
owarn << "Write Config" << oendl;
DirImageWidget* wid = static_cast<DirImageWidget*>(_wid);
- cfg.writeEntry("Dir_Check_All_Files", wid->chkbox->isChecked() );
+ cfg.writeEntry("Dir_Check_All_Files", wid->chkbox->isChecked());
+ cfg.writeEntry("Dir_Check_Recursive_Files", wid->recBox->isChecked());
+ cfg.writeEntry("Dir_Recursive_Files_Depth",wid->recDepth->value());
}
diff --git a/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp b/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp
index d8b332a..ff33cf2 100644
--- a/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp
+++ b/noncore/graphics/opie-eye/impl/dir/dir_lister.cpp
@@ -1,92 +1,111 @@
/*
* GPLv2 zecke@handhelds.org
*/
#include "dir_lister.h"
#include <lib/slavemaster.h>
/* OPIE */
#include <opie2/odebug.h>
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
using namespace Opie::Core;
/* QT */
#include <qdir.h>
#include <qfileinfo.h>
-Dir_DirLister::Dir_DirLister( bool list )
+Dir_DirLister::Dir_DirLister( bool list,bool rec,int recdepth )
: PDirLister( "dir_dir_lister" )
{
m_allFiles = list;
+ m_recursive = rec;
+ m_recDepth = recdepth;
+ if (m_recDepth<1) m_recDepth = 1;
+ if (m_recDepth>10) m_recDepth = 10;
owarn << "All Files " << m_allFiles << "" << oendl;
SlaveHelper::slaveConnectSignals( this );
+ m_Filter = (m_allFiles?"*":"*.jpg;*.jpeg;*.JPG;*.PNG;*.GIF;*.BMP;*.png;*.bmp;*.gif");
}
QString Dir_DirLister::defaultPath()const {
return QPEApplication::documentDir();
}
QString Dir_DirLister::setStartPath( const QString& path ) {
m_currentDir.cd( path );
if (!m_currentDir.exists() )
m_currentDir.cd(defaultPath());
return m_currentDir.absPath();
}
QString Dir_DirLister::currentPath()const {
return m_currentDir.absPath();
}
QStringList Dir_DirLister::folders()const {
return m_currentDir.entryList( QDir::Dirs );
}
-QStringList Dir_DirLister::files()const {
- if ( m_allFiles )
- return m_currentDir.entryList( QDir::Files );
- else {
- QStringList out;
- QStringList list = m_currentDir.entryList( QDir::Files | QDir::Readable );
- for (QStringList::Iterator it = list.begin(); it != list.end();++it ) {
- QFileInfo inf( *it );
- QString ext = inf.extension(false).lower();
- if( ext == QString::fromLatin1("jpg") ||
- ext == QString::fromLatin1("jpeg" ) ||
- ext == QString::fromLatin1("png" ) ||
- ext == QString::fromLatin1("bmp" ) ||
- ext == QString::fromLatin1("gif" ) )
- out.append( *it );
+QStringList Dir_DirLister::recFiles(const QString&aPath,int currentDepth)const
+{
+ QStringList all;
+ if (currentDepth>m_recDepth) return all;
+
+ QString subPath;
+ subPath = aPath;
+ if (subPath.length()==0) {
+ subPath=".";
+ }
+ QDir checkDir(currentPath()+"/"+aPath);
+
+ QStringList p = checkDir.entryList( QDir::Dirs );
+ all+=checkDir.entryList(m_Filter,QDir::Files|QDir::Readable);
+ QStringList tmp;
+ for (unsigned i = 0; i < p.count();++i) {
+ if (p[i]=="." || p[i]=="..") continue;
+ tmp =recFiles(subPath+"/"+p[i],currentDepth+1);
+ for (unsigned j = 0; j < tmp.count();++j) {
+ all.append(p[i]+"/"+tmp[j]);
}
- return out;
}
+ return all;
+}
+
+QStringList Dir_DirLister::files()const
+{
+ if (m_recursive) {
+ odebug << "Startpfad: "<<m_currentDir.absPath()<<oendl;
+ return recFiles("",0);
+ }
+ return m_currentDir.entryList(m_Filter,QDir::Files|QDir::Readable);
}
void Dir_DirLister::deleteImage( const QString& fl) {
QFile::remove( fl );
}
void Dir_DirLister::thumbNail( const QString& str, int w, int h) {
SlaveMaster::self()->thumbNail( str, w, h );
}
QImage Dir_DirLister::image( const QString& str, Factor f, int m) {
return SlaveMaster::self()->image( str, f, m );
}
void Dir_DirLister::imageInfo( const QString& str) {
SlaveMaster::self()->thumbInfo( str );
}
void Dir_DirLister::fullImageInfo( const QString& str) {
SlaveMaster::self()->imageInfo( str );
}
QString Dir_DirLister::nameToFname(const QString&name)const
{
return name;
}
diff --git a/noncore/graphics/opie-eye/impl/dir/dir_lister.h b/noncore/graphics/opie-eye/impl/dir/dir_lister.h
index d6ca6c0..445adbf 100644
--- a/noncore/graphics/opie-eye/impl/dir/dir_lister.h
+++ b/noncore/graphics/opie-eye/impl/dir/dir_lister.h
@@ -1,37 +1,45 @@
/*
* GPLv2 zecke@handhelds.org
*/
#ifndef DIR_LISTER_INTERFACE_LISTER_H
#define DIR_LISTER_INTERFACE_LISTER_H
#include <qdir.h>
#include <iface/dirlister.h>
class Config;
class Dir_DirLister : public PDirLister {
Q_OBJECT
public:
- Dir_DirLister( bool );
+ Dir_DirLister(bool,bool,int);
virtual ~Dir_DirLister(){}
QString defaultPath()const;
QString setStartPath( const QString& );
QString currentPath()const;
QStringList folders()const;
QStringList files()const;
void deleteImage( const QString& );
void thumbNail( const QString&, int, int );
QImage image( const QString&, Factor, int );
void imageInfo( const QString& );
void fullImageInfo( const QString& );
virtual QString nameToFname(const QString&name)const;
private:
- bool m_allFiles;
+ bool m_allFiles:1;
+ bool m_recursive:1;
+ int m_recDepth;
QDir m_currentDir;
+ //! recursive listing.
+ /*!
+ * \param path this is the offset to the current path. eg. when currentDepth = 0 then it MUST empty
+ */
+ QStringList recFiles(const QString&path,int currentDepth)const;
+ QString m_Filter;
};
#endif