summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp78
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp11
2 files changed, 75 insertions, 14 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index 7231bfb..039f53f 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -21,111 +21,138 @@
#include <qpe/ir.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include <qiconview.h>
#include <qlabel.h>
#include <qhbox.h>
#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* _picPix = 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;}
+ virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE );
+ 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_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 & icon, bool recalc, bool redraw)
+ {
+ m_Pixset = true;
+ QIconViewItem::setPixmap(icon,recalc,redraw);
+ }
+ inline void IconViewItem::setPixmap( const QPixmap & icon)
+ {
+ m_Pixset = true;
+ QIconViewItem::setPixmap(icon);
+ }
+
inline QPixmap* IconViewItem::pixmap()const {
// qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d",
// rect().x(),rect().y(),rect().width(),rect().height(),
// iconView()->contentsX(), iconView()->contentsY());
+ 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 )) {
+ if (!m_pix && !g_stringPix.contains( m_path )&&!m_Pixset) {
currentView()->dirLister()->thumbNail( m_path, 64, 64 );
g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
}
+ if (m_Pixset) {
+ return QIconViewItem::pixmap();
+ }
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;
@@ -346,109 +373,121 @@ void PIconView::slotViewChanged( int i) {
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 */
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 )
- (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true );
-
-
+ 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;
- for (it=lst.begin(); it!= lst.end(); ++it )
- (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) );
+ IconViewItem * _iv;
+ QPixmap*m_pix = 0;
+ for (it=lst.begin(); it!= lst.end(); ++it ) {
+ m_pix = PPixmapCache::self()->cachedImage( m_path+"/"+(*it), 64, 64 );
+ _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it) );
+ if (m_mode==3) _iv->setTextOnly(true);
+ 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();
}
/*
* 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)
+ 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
*/
void PIconView::slotBeam() {
bool isDir;
QString pa = currentFileName( isDir );
if ( isDir && pa.isEmpty() )
return;
Ir* ir = new Ir( this );
connect( ir, SIGNAL(done(Ir*)),
this, SLOT(slotBeamDone(Ir*)));
@@ -527,26 +566,43 @@ void PIconView::slotChangeMode( int mode ) {
switch( m_mode ) {
case 2:
pos = QIconView::Bottom;
break;
case 3:
case 1:
default:
pos = QIconView::Right;
break;
}
m_view->setItemTextPos( pos );
calculateGrid();
slotReloadDir();
}
void PIconView::resizeEvent( QResizeEvent* re ) {
QVBox::resizeEvent( re );
calculateGrid();
}
void PIconView::calculateGrid() {
+ odebug << "Calc grid: x=" << m_view->gridX() << " y=" << m_view->gridY() << oendl;
+ odebug << "Size of view: " << m_view->size() << oendl;
+ switch (m_mode) {
+ case 2:
+ m_view->setGridX(80);
+ m_view->setGridY(80);
+ break;
+ case 3:
+ m_view->setGridX(m_view->width());
+ m_view->setGridY(8);
+ break;
+ case 1:
+ default:
+ m_view->setGridX(m_view->width());
+ m_view->setGridY(80);
+ break;
+ }
}
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index 5ba4c8e..4852bf6 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -84,63 +84,62 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
connect( btn, SIGNAL(clicked()),
m_view, SLOT(slotBeam()) );
}
btn = new QToolButton( bar );
btn->setIconSet( Resource::loadIconSet( "trash" ) );
connect( btn, SIGNAL(clicked() ),
m_view, SLOT(slotTrash() ) );
viewModeButton = new ViewModeButton( bar );
connect( viewModeButton, SIGNAL(changeMode(int)),
m_view, SLOT(slotChangeMode(int)));
btn = new QToolButton( bar );
btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) );
connect( btn, SIGNAL(clicked() ),
this, SLOT(slotConfig() ) );
prevButton = new QToolButton(bar);
prevButton->setIconSet( Resource::loadIconSet( "back" ) );
connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev()));
- prevButton->hide();
nextButton = new QToolButton(bar);
nextButton->setIconSet( Resource::loadIconSet( "forward" ) );
connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext()));
- nextButton->hide();
rotateButton = new QToolButton(bar);
rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) );
rotateButton->setToggleButton(true);
- odebug << "Mode = " << m_stack->mode() << oendl;
if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
rotateButton->setOn(true);
autoRotate = true;
+ prevButton->hide();
+ nextButton->hide();
} else {
rotateButton->setOn(false);
autoRotate = false;
}
connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool)));
btn = new QToolButton(bar);
btn->setIconSet( Resource::loadIconSet( "1to1" ) );
btn->setToggleButton(true);
btn->setOn(false);
connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool)));
autoScale = true;
btn = new QToolButton(bar);
btn->setIconSet( Resource::loadIconSet( "mag" ) );
btn->setToggleButton(true);
btn->setOn(true);
connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool)));
zoomerOn = true;
}
PMainWindow::~PMainWindow() {
odebug << "Shutting down" << oendl;
@@ -278,82 +277,88 @@ void PMainWindow::initDisp() {
m_disp->setMinimumSize(QApplication::desktop()->size()/2);
}
m_disp->setAutoScale(autoScale);
m_disp->setAutoRotate(autoRotate);
m_disp->setShowZoomer(zoomerOn);
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()));
}
}
/**
* With big Screen the plan could be to 'detach' the image
* window if visible and to create a ne wone
* init* already supports it but I make no use of it for
* now. We set filename and raise
*
* ### FIXME and talk to alwin
*/
void PMainWindow::slotShowInfo( const QString& inf ) {
if ( !m_info ) {
initInfo();
}
m_info->setPath( inf );
+ if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
prevButton->hide();
nextButton->hide();
upButton->hide();
fsButton->hide();
viewModeButton->hide();
+ }
m_stack->raiseWidget( ImageInfo );
}
void PMainWindow::slotDisplay( const QString& inf ) {
if ( !m_disp ) {
initDisp();
}
m_disp->setImage( inf );
+ if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
prevButton->show();
nextButton->show();
upButton->hide();
fsButton->hide();
viewModeButton->hide();
+ }
m_stack->raiseWidget( ImageDisplay );
}
void PMainWindow::slotReturn() {
raiseIconView();
}
void PMainWindow::closeEvent( QCloseEvent* ev ) {
/*
* return from view
* or properly quit
*/
if ( m_stack->visibleWidget() == m_info ||
m_stack->visibleWidget() == m_disp ) {
raiseIconView();
ev->ignore();
return;
}
ev->accept();
QTimer::singleShot(0, qApp, SLOT(closeAllWindows()));
}
void PMainWindow::raiseIconView() {
+ if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
prevButton->hide();
nextButton->hide();
upButton->show();
fsButton->show();
viewModeButton->show();
+ }
m_stack->raiseWidget( IconView );
}
void PMainWindow::setDocument( const QString& showImg ) {
QString file = showImg;
DocLnk lnk(showImg);
if (lnk.isValid() )
file = lnk.file();
slotDisplay( file );
}