-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 29 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 2 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/slave/gif_slave.cpp | 3 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/slave/jpeg_slave.cpp | 5 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/slave/png_slave.cpp | 3 |
5 files changed, 20 insertions, 22 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index b3f0006..ed9fc9c 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp @@ -1,153 +1,152 @@ /* * GPLv2 zecke@handhelds.org * No WArranty... */ #include "iconview.h" #include <lib/imagecache.h> #include <iface/dirview.h> #include <iface/dirlister.h> #include <opie2/oconfig.h> #include <opie2/okeyconfigwidget.h> +#include <opie2/odebug.h> #include <qpe/resource.h> #include <qpe/qpemessagebox.h> #include <qpe/ir.h> #include <qpe/qcopenvelope_qws.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::Ui::OKeyConfigItem; namespace { QPixmap* _dirPix = 0; QPixmap* _unkPix = 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& ); - void reCalc(); + + private: mutable QPixmap* m_pix; QString m_path; bool m_isDir : 1; bool m_noInfo :1; }; /* * If we request an Image or String * we add it to the map */ QMap<QString, IconViewItem*> g_stringInf; QMap<QString, IconViewItem*> g_stringPix; IconViewItem::IconViewItem( QIconView* view,const QString& path, const QString& name, bool isDir ) : QIconViewItem( view ), m_path( path ), m_isDir( isDir ), m_noInfo( false ) { QIconViewItem::setText( name ); if ( isDir && !_dirPix ) _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); else if ( !isDir && !_unkPix ) _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); } 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 ( 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 ); - reCalc(); - } - - inline void IconViewItem::reCalc() - { - calcRect(); } } PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) : QVBox( wid ), m_cfg( cfg ) { { QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); } m_path = QDir::homeDirPath(); QHBox *hbox = new QHBox( this ); QLabel* lbl = new QLabel( hbox ); lbl->setText( tr("View as" ) ); m_views = new QComboBox( hbox, "View As" ); connect( m_views, SIGNAL(activated(int)), this, SLOT(slotViewChanged(int)) ); m_view= new QIconView( this ); connect(m_view, SIGNAL(clicked(QIconViewItem*) ), this, SLOT(slotClicked(QIconViewItem*)) ); m_view->setArrangement( QIconView::LeftToRight ); m_view->setItemTextPos( QIconView::Right ); - m_view->setResizeMode(QIconView::Adjust); int dw = QApplication::desktop()->width(); int viewerWidth = dw-style().scrollBarExtent().width(); - m_view->setGridX( viewerWidth-2*m_view->spacing() ); + m_view->setGridX( viewerWidth-3*m_view->spacing()); m_view->setGridY( fontMetrics().height()*2+40 ); initKeys(); loadViews(); slotViewChanged( m_views->currentItem() ); } PIconView::~PIconView() { { QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); } m_viewManager->save(); delete m_viewManager; } Opie::Ui::OKeyConfigManager* PIconView::manager() { return m_viewManager; } void PIconView::initKeys() { Opie::Ui::OKeyPair::List lst; lst.append( Opie::Ui::OKeyPair::upArrowKey() ); @@ -175,53 +174,53 @@ void PIconView::initKeys() { Opie::Ui::OKeyPair(Qt::Key_I, Qt::ShiftButton ), this, SLOT(slotImageInfo()) ) ); m_viewManager->load(); m_viewManager->handleWidget( m_view ); } void PIconView::slotDirUp() { QDir dir( m_path ); dir.cdUp(); slotChangeDir( dir.absPath() ); } void PIconView::slotChangeDir(const QString& path) { if ( !currentView() ) return; PDirLister *lister = currentView()->dirLister(); if (!lister ) return; lister->setStartPath( path ); m_path = lister->currentPath(); - m_view->setUpdatesEnabled( false ); + m_view->viewport()->setUpdatesEnabled( false ); m_view->clear(); addFolders( lister->folders() ); addFiles( lister->files() ); - m_view->setUpdatesEnabled( true ); + 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 ) ); } 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(); } void PIconView::slotTrash() { bool isDir; QString pa = currentFileName( isDir ); if ( isDir && pa.isEmpty() ) @@ -293,86 +292,84 @@ void PIconView::addFolders( const QStringList& lst) { 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) ); } void PIconView::slotClicked(QIconViewItem* _it) { if(!_it ) return; IconViewItem* it = static_cast<IconViewItem*>(_it); if( it->isDir() ) slotChangeDir( it->path() ); else // view image ; } void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { if ( g_stringInf.contains( _path ) ) { IconViewItem* item = g_stringInf[_path]; /* if set the view shows nonsens! I dont know how to fix the format of displayed text :(*/ item->setText( str ); - item->repaint(); g_stringInf.remove( _path ); } } void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { if ( g_stringPix.contains( _path ) ) { IconViewItem* item = g_stringPix[_path]; if (pix.width()>0) { PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); /* required for a recalculated rectangle. otherwise the view show nonsense! */ - item->reCalc(); } else { PPixmapCache::self()->insertImage(_path,Resource::loadPixmap( "UnknownDocument" ),64,64 ); } - item->repaint(); g_stringPix.remove( _path ); } } void PIconView::slotRename() { } 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*))); ir->send(pa, tr( "Image" ) ); } void PIconView::slotBeamDone( Ir* ir) { delete ir; } void PIconView::slotStart() { - m_view->setUpdatesEnabled( false ); + m_view->viewport()->setUpdatesEnabled( false ); } void PIconView::slotEnd() { - m_view->setUpdatesEnabled( true ); + m_view->arrangeItemsInGrid( ); + m_view->viewport()->setUpdatesEnabled( true ); } void PIconView::slotShowImage() { } void PIconView::slotShowImage( const QString& ) { } void PIconView::slotImageInfo() { } void PIconView::slotImageInfo( const QString& ) { } diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 0314659..83ff4f1 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp @@ -88,49 +88,49 @@ PMainWindow::~PMainWindow() { 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("Phunk View - Config" ) ); QHBoxLayout *lay = new QHBoxLayout(&dlg); Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); lay->addWidget( wid ); 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 ); _wid->reparent(wid, QPoint() ); lst.insert( view, _wid ); - wid->addTab( _wid, QString::null, inf->name() ); + 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() ); keyWid->load(); wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); 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(); diff --git a/noncore/graphics/opie-eye/slave/gif_slave.cpp b/noncore/graphics/opie-eye/slave/gif_slave.cpp index feb69b6..f0dc86e 100644 --- a/noncore/graphics/opie-eye/slave/gif_slave.cpp +++ b/noncore/graphics/opie-eye/slave/gif_slave.cpp @@ -265,41 +265,42 @@ FILE * infile; debug = FALSE; skipcomment = FALSE; giftrans( infile, NULL, str, full ); fclose( infile ); } } GifSlave::GifSlave() : SlaveInterface(QStringList("gif")) {} GifSlave::~GifSlave() { } QString GifSlave::iconViewName(const QString& str) { QString st; get_gif_info(QFile::encodeName( str ).data(), st ); return st; } QString GifSlave::fullImageInfo( const QString& str) { - QString st; + QString st = "<qt>"; get_gif_info(QFile::encodeName( str ).data(), st, true ); + st.append( "</qt>" ); return st; } QPixmap GifSlave::pixmap(const QString& path, int width, int height ) { static QImage img; img.load( path ); if ( img.isNull() ) { QPixmap pix; return pix; } return ThumbNailTool::scaleImage( img, width,height ); } diff --git a/noncore/graphics/opie-eye/slave/jpeg_slave.cpp b/noncore/graphics/opie-eye/slave/jpeg_slave.cpp index 95055fd..086b47f 100644 --- a/noncore/graphics/opie-eye/slave/jpeg_slave.cpp +++ b/noncore/graphics/opie-eye/slave/jpeg_slave.cpp @@ -1279,76 +1279,75 @@ static QString exposure_program( int i ) { exp = QObject::tr( "Portrait mode\n(for closeup photos with the background out of focus)" ); break; case 8: exp = QObject::tr( "Landscape mode\n(for landscape photos with the background in focus)" ); break; default: exp = QObject::tr( "Unknown" ); } return QObject::tr( "Exposure Program: %1\n" ).arg( exp ); } JpegSlave::JpegSlave() : SlaveInterface( QStringList::split( " ", "jpeg jpg" ) ) {} JpegSlave::~JpegSlave() {} QString JpegSlave::iconViewName( const QString& path) { ExifData ImageInfo; if ( !ImageInfo.scan( path ) ) return QString::null; QString tag; - tag = QObject::tr( "<qt>Comment: %1\n" ).arg( ImageInfo.getComment() ); + tag = QObject::tr( "Comment: %1\n" ).arg( ImageInfo.getComment() ); { // ODP fixme QString timestring = TimeString::dateString( parseDateTime( ImageInfo.getDateTime() ), FALSE ); tag += QObject::tr( "Date/Time: %1\n" ).arg( timestring ); } tag += QObject::tr( "Dimensions: %1x%2\n" ).arg(ImageInfo.getWidth()) .arg(ImageInfo.getHeight() ); tag += color_mode_to_string( ImageInfo.getIsColor() ); tag += compression_to_string( ImageInfo.getCompressionLevel() ); - tag += QObject::tr( "</qt>" ); return tag; } /* * messy messy string creation */ QString JpegSlave::fullImageInfo( const QString& path) { ExifData ImageInfo; if ( !ImageInfo.scan( path ) ) return QString::null; QString tag, tmp; - tag = QObject::tr( "Comment: %1\n" ).arg( ImageInfo.getComment() ); + tag = QObject::tr( "<qt>Comment: %1\n" ).arg( ImageInfo.getComment() ); tmp = ImageInfo.getCameraMake(); if ( tmp.length() ) tag += QObject::tr( "Manufacturer: %1\n" ).arg( tmp ); tmp = ImageInfo.getCameraModel(); if ( tmp.length() ) tag += QObject::tr( "Model: %1\n" ).arg( tmp ); { // ODP fixme tmp = TimeString::dateString( parseDateTime( ImageInfo.getDateTime() ), FALSE ); tag += QObject::tr( "Date/Time: %1\n" ).arg( tmp ); } tag += QObject::tr( "Dimensions: %1x%2\n" ).arg(ImageInfo.getWidth()) .arg(ImageInfo.getHeight() ); tag += color_mode_to_string( ImageInfo.getIsColor() ); tag += compression_to_string( ImageInfo.getCompressionLevel() ); if ( ImageInfo.getOrientation() ) tag += QObject::tr( "Orientation: %1\n" ).arg(ImageInfo.getOrientation() ); { int flash_used = ImageInfo.getFlashUsed(); diff --git a/noncore/graphics/opie-eye/slave/png_slave.cpp b/noncore/graphics/opie-eye/slave/png_slave.cpp index 72b93cc..86e1cdc 100644 --- a/noncore/graphics/opie-eye/slave/png_slave.cpp +++ b/noncore/graphics/opie-eye/slave/png_slave.cpp @@ -174,37 +174,38 @@ static void read_comment( const QString& inf, index += CHUNK_SIZE(data, index) + CHUNK_HEADER_SIZE; } } } } end: delete[] data; } PNGSlave::PNGSlave() : SlaveInterface("png") { } PNGSlave::~PNGSlave() { } QString PNGSlave::iconViewName( const QString& path) { QString str; read_comment( path, false, str ); return str; } QString PNGSlave::fullImageInfo( const QString& path) { - QString str; + QString str = "<qt>"; read_comment( path, true, str ); + str += "</qt>"; return str; } QPixmap PNGSlave::pixmap( const QString& path, int width, int height) { QImage img; img.load( path ); if ( img.isNull() ) return QPixmap(); else return ThumbNailTool::scaleImage( img, width,height ); } |