summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp13
-rw-r--r--noncore/graphics/opie-eye/gui/imageinfoui.cpp114
-rw-r--r--noncore/graphics/opie-eye/gui/imageinfoui.h48
-rw-r--r--noncore/graphics/opie-eye/phunk_view.pro8
4 files changed, 177 insertions, 6 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index f415d39..ac4b899 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -1,383 +1,390 @@
/*
* GPLv2 zecke@handhelds.org
* No WArranty...
*/
#include "iconview.h"
#include <lib/imagecache.h>
+#include <gui/imageinfoui.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 <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::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& );
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, name ), m_path( path ), m_isDir( isDir ),
m_noInfo( false )
{
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 );
}
}
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();
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 );
int dw = QApplication::desktop()->width();
int viewerWidth = dw-style().scrollBarExtent().width();
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() );
lst.append( Opie::Ui::OKeyPair::downArrowKey() );
lst.append( Opie::Ui::OKeyPair::leftArrowKey() );
lst.append( Opie::Ui::OKeyPair::rightArrowKey() );
lst.append( Opie::Ui::OKeyPair::returnKey() );
m_viewManager = new Opie::Ui::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::Ui::OKeyPair(Qt::Key_B, Qt::ShiftButton),
this, SLOT(slotBeam())) );
m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete",
Resource::loadPixmap("trash"), DeleteItem,
Opie::Ui::OKeyPair(Qt::Key_D, Qt::ShiftButton),
this, SLOT(slotTrash())) );
m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view",
Resource::loadPixmap("1to1"), ViewItem,
Opie::Ui::OKeyPair(Qt::Key_V, Qt::ShiftButton),
this, SLOT(slotShowImage())));
m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info",
Resource::loadPixmap("DocumentTypeWord"), InfoItem,
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->viewport()->setUpdatesEnabled( false );
m_view->clear();
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 ) );
}
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() )
return;
if (!QPEMessageBox::confirmDelete( this,
tr("Delete Image" ),
tr("the Image %1" ).arg(pa)))
return
currentView()->dirLister()->deleteImage( pa );
delete m_view->currentItem();
}
void PIconView::loadViews() {
ViewMap::Iterator it;
ViewMap* map = viewMap();
for ( it = map->begin(); it != map->end(); ++it )
m_views->insertItem( QObject::tr(it.key() ) );
}
void PIconView::resetView() {
slotViewChanged(m_views->currentItem());
}
void PIconView::slotViewChanged( int i) {
if (!m_views->count() ) {
setCurrentView( 0l);
return;
}
PDirView* cur = currentView();
delete cur;
QString str = m_views->text(i);
cur = (*(*viewMap())[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 */
QTimer::singleShot( 0, this, SLOT(slotReloadDir()));
}
void PIconView::slotReloadDir() {
slotChangeDir( m_path );
}
void PIconView::addFolders( const QStringList& lst) {
QStringList::ConstIterator it;
for(it=lst.begin(); it != lst.end(); ++it ) {
(void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), 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) );
}
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 ) {
IconViewItem* item = g_stringInf[_path];
if (!item )
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 );
}
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 );
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->viewport()->setUpdatesEnabled( false );
qWarning( "Sig Start" );
}
void PIconView::slotEnd() {
qWarning( "SLot End" );
if ( m_updatet )
m_view->arrangeItemsInGrid( );
m_view->viewport()->setUpdatesEnabled( true );
m_updatet = false;
}
void PIconView::slotShowImage() {
}
void PIconView::slotShowImage( const QString& ) {
}
void PIconView::slotImageInfo() {
-
+ qDebug("image info");
+ bool isDir = false;
+ QString name = currentFileName(isDir);
+ if (isDir) return;
+ infoDlg dlg(name);
+ QPEApplication::execDialog(&dlg);
}
-void PIconView::slotImageInfo( const QString& ) {
+void PIconView::slotImageInfo( const QString& ) {
+
}
diff --git a/noncore/graphics/opie-eye/gui/imageinfoui.cpp b/noncore/graphics/opie-eye/gui/imageinfoui.cpp
new file mode 100644
index 0000000..177df77
--- a/dev/null
+++ b/noncore/graphics/opie-eye/gui/imageinfoui.cpp
@@ -0,0 +1,114 @@
+#include "imageinfoui.h"
+
+#include <qframe.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qtextview.h>
+#include <qlayout.h>
+#include <qvariant.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+#include <qimage.h>
+#include <qpixmap.h>
+#include <qstring.h>
+
+#include <lib/slavemaster.h>
+#include <lib/imagecache.h>
+
+#include <qpe/qcopenvelope_qws.h>
+#include <qpe/resource.h>
+
+imageinfo::imageinfo(const QString&_path, QWidget* parent, const char* name, WFlags fl )
+ : QWidget( parent, name, fl ),currentFile(_path)
+{
+ {
+ QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
+ }
+ if ( !name )
+ setName( "imageinfo" );
+ resize( 289, 335 );
+ setCaption( tr( "Image info" ) );
+ imageinfoLayout = new QVBoxLayout( this );
+ imageinfoLayout->setSpacing(2);
+ imageinfoLayout->setMargin(2);
+
+ PixmapLabel1 = new QLabel( this, "PixmapLabel1" );
+ PixmapLabel1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, PixmapLabel1->sizePolicy().hasHeightForWidth() ) );
+ PixmapLabel1->setScaledContents( TRUE );
+ imageinfoLayout->addWidget( PixmapLabel1 );
+
+ Line1 = new QFrame( this, "Line1" );
+ Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken );
+ imageinfoLayout->addWidget( Line1 );
+
+ fnameLabel = new QLabel( this, "FnameLabel" );
+ imageinfoLayout->addWidget( fnameLabel);
+
+ TextView1 = new QTextView( this, "TextView1" );
+ TextView1->setFrameShadow( QTextView::Plain );
+ QToolTip::add( TextView1, tr( "Displays info of selected image" ) );
+ QWhatsThis::add( TextView1, tr( "Displays info of selected image" ) );
+ imageinfoLayout->addWidget( TextView1 );
+
+ SlaveMaster* master = SlaveMaster::self();
+ connect( master, SIGNAL(sig_fullInfo(const QString&, const QString&)),
+ this, SLOT(slot_fullInfo(const QString&, const QString&)) );
+ connect(master, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
+ this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
+ slotChangeName(_path);
+}
+
+void imageinfo::slotChangeName(const QString&_path)
+{
+ currentFile=_path;
+ fnameLabel->setText("<qt><center><b>"+currentFile+"</b></center></qt>");
+ SlaveMaster::self()->imageInfo( currentFile );
+
+ QPixmap*m_pix = PPixmapCache::self()->cachedImage( _path, 64, 64 );
+ if (!m_pix) {
+ PixmapLabel1->setPixmap(QPixmap( Resource::loadPixmap( "UnknownDocument" )));
+ } else {
+ PixmapLabel1->setPixmap(*m_pix);
+ }
+}
+
+imageinfo::~imageinfo()
+{
+ {
+ QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
+ }
+}
+
+void imageinfo::slot_fullInfo(const QString&_path, const QString&_t)
+{
+ if (_path == currentFile) {
+ qDebug(_t);
+ QString t = _t;
+ t.replace(QRegExp("\n"),"<br>");
+ TextView1->setText(t);
+ }
+}
+
+void imageinfo::slotThumbNail(const QString&_path, const QPixmap&_pix)
+{
+ if (_pix.width()>0)
+ PPixmapCache::self()->insertImage( _path, _pix, 64, 64 );
+ if (_path == currentFile) {
+ PixmapLabel1->setPixmap( _pix );
+ }
+}
+
+/* for testing */
+infoDlg::infoDlg(const QString&fname,QWidget * parent, const char * name)
+ :QDialog(parent,name,true,WStyle_ContextHelp)
+{
+ QVBoxLayout*dlglayout = new QVBoxLayout(this);
+ dlglayout->setSpacing(2);
+ dlglayout->setMargin(1);
+ imageinfo*inf = new imageinfo(fname,this);
+ dlglayout->addWidget(inf);
+}
+
+infoDlg::~infoDlg()
+{
+}
diff --git a/noncore/graphics/opie-eye/gui/imageinfoui.h b/noncore/graphics/opie-eye/gui/imageinfoui.h
new file mode 100644
index 0000000..34ec937
--- a/dev/null
+++ b/noncore/graphics/opie-eye/gui/imageinfoui.h
@@ -0,0 +1,48 @@
+#ifndef IMAGEINFO_H
+#define IMAGEINFO_H
+
+#include <qvariant.h>
+#include <qwidget.h>
+#include <qdialog.h>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QFrame;
+class QLabel;
+class QTextView;
+
+class imageinfo : public QWidget
+{
+ Q_OBJECT
+
+public:
+ imageinfo(const QString&_path, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
+ ~imageinfo();
+
+ QLabel* PixmapLabel1;
+ QLabel* fnameLabel;
+ QFrame* Line1;
+ QTextView* TextView1;
+
+protected:
+ QVBoxLayout* imageinfoLayout;
+ QString currentFile;
+
+protected slots:
+ virtual void slot_fullInfo(const QString&, const QString&);
+ virtual void slotThumbNail(const QString&, const QPixmap&);
+
+ virtual void slotChangeName(const QString&);
+};
+
+/* for testing purpose */
+class infoDlg:public QDialog
+{
+ Q_OBJECT
+public:
+ infoDlg(const QString&,QWidget * parent=0, const char * name=0);
+ virtual ~infoDlg();
+};
+
+#endif // IMAGEINFO_H
diff --git a/noncore/graphics/opie-eye/phunk_view.pro b/noncore/graphics/opie-eye/phunk_view.pro
index 3547af0..17fa22c 100644
--- a/noncore/graphics/opie-eye/phunk_view.pro
+++ b/noncore/graphics/opie-eye/phunk_view.pro
@@ -1,34 +1,36 @@
CONFIG += qt warn_on quick-app
DESTDIR = $(OPIEDIR)/bin
TEMPLATE = app
TARGET = opie-eye
# the name of the resulting object
HEADERS = gui/iconview.h gui/filesystem.h gui/mainwindow.h \
lib/imagecache.h impl/dir/dir_dirview.h \
iface/dirview.h iface/dirlister.h iface/ifaceinfo.h \
impl/dir/dir_lister.h impl/dir/dir_ifaceinfo.h \
lib/slavemaster.h \
- iface/slaveiface.h
+ iface/slaveiface.h \
+ gui/imageinfoui.h
# A list header files
SOURCES = gui/iconview.cpp gui/filesystem.cpp gui/mainwindow.cpp \
lib/imagecache.cpp lib/viewmap.cpp \
impl/dir/dir_dirview.cpp iface/dirlister.cpp \
iface/dirview.cpp impl/dir/dir_lister.cpp \
- impl/dir/dir_ifaceinfo.cpp lib/slavemaster.cpp
+ impl/dir/dir_ifaceinfo.cpp lib/slavemaster.cpp \
+ gui/imageinfoui.cpp
# A list of source files
-INTERFACES =
+INTERFACES =
# list of ui files
INCLUDEPATH += . $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopieui2
include ( $(OPIEDIR)/include.pro )