summaryrefslogtreecommitdiff
path: root/core/launcher
authoralwin <alwin>2004-11-10 21:18:37 (UTC)
committer alwin <alwin>2004-11-10 21:18:37 (UTC)
commit660b61a7f8b9fb885226507d7f6716ab2dcedbb8 (patch) (side-by-side diff)
tree5ebbfc6ca71b1a2205d5f2516b919c9c2dd4fced /core/launcher
parentd2f3b6f525be4d652fbac7c87ab0ad40e21af184 (diff)
downloadopie-660b61a7f8b9fb885226507d7f6716ab2dcedbb8.zip
opie-660b61a7f8b9fb885226507d7f6716ab2dcedbb8.tar.gz
opie-660b61a7f8b9fb885226507d7f6716ab2dcedbb8.tar.bz2
implemented icon cache so it will not scan every time when changing the
doctab categorie ToDo: implement a cache flush
Diffstat (limited to 'core/launcher') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp43
-rw-r--r--core/launcher/launcher.h4
-rw-r--r--core/launcher/launcherview.cpp109
-rw-r--r--core/launcher/launcherview.h7
4 files changed, 113 insertions, 50 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 5ec1cf8..ccc2114 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -77,7 +77,7 @@ static bool isVisibleWindow( int );
//===========================================================================
LauncherTabWidget::LauncherTabWidget( Launcher* parent ) :
- QVBox( parent ), docview( 0 )
+ QVBox( parent ), docview( 0 ),docTabEnabled(true),m_DocumentTabId(0)
{
docLoadingWidgetEnabled = false;
docLoadingWidget = 0;
@@ -128,7 +128,7 @@ void LauncherTabWidget::createDocLoadingWidget()
Config cfg( "Launcher" );
cfg.setGroup( "DocTab" );
- bool docTabEnabled = cfg.readBoolEntry( "Enable", true );
+ docTabEnabled = cfg.readBoolEntry( "Enable", true );
QLabel *textLabel = new QLabel( docLoadingVBox );
textLabel->setAlignment( int( QLabel::AlignCenter ) );
@@ -169,17 +169,17 @@ void LauncherTabWidget::initLayout()
void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&)
{
if ( message == "nextView()" )
- categoryBar->nextTab();
+ categoryBar->nextTab();
}
void LauncherTabWidget::raiseTabWidget()
{
if ( categoryBar->currentView() == docView()
- && docLoadingWidgetEnabled ) {
- stack->raiseWidget( docLoadingWidget );
- docLoadingWidget->updateGeometry();
+ && docLoadingWidgetEnabled ) {
+ stack->raiseWidget( docLoadingWidget );
+ docLoadingWidget->updateGeometry();
} else {
- stack->raiseWidget( categoryBar->currentView() );
+ stack->raiseWidget( categoryBar->currentView() );
}
}
@@ -192,7 +192,7 @@ void LauncherTabWidget::tabProperties()
m->setItemChecked( (int)view->viewMode(), TRUE );
int rv = m->exec( QCursor::pos() );
if ( rv >= 0 && rv != view->viewMode() ) {
- view->setViewMode( (LauncherView::ViewMode)rv );
+ view->setViewMode( (LauncherView::ViewMode)rv );
}
delete m;
@@ -202,9 +202,9 @@ void LauncherTabWidget::deleteView( const QString& id )
{
LauncherTab *t = categoryBar->launcherTab(id);
if ( t ) {
- stack->removeWidget( t->view );
- delete t->view;
- categoryBar->removeTab( t );
+ stack->removeWidget( t->view );
+ delete t->view;
+ categoryBar->removeTab( t );
}
}
@@ -216,14 +216,17 @@ LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm,
connect( view, SIGNAL(rightPressed(AppLnk*)),
this, SIGNAL(rightPressed(AppLnk*)));
+
int n = categoryBar->count();
+
stack->addWidget( view, n );
LauncherTab *tab = new LauncherTab( id, view, pm, label );
categoryBar->insertTab( tab, n-1 );
-
- if ( id == "Documents" )
- docview = view;
+ if ( id == "Documents" ) {
+ docview = view;
+ m_DocumentTabId = n;
+ }
odebug << "inserting " << id << " at " << n-1 << "" << oendl;
@@ -240,7 +243,7 @@ LauncherView *LauncherTabWidget::view( const QString &id )
{
LauncherTab *t = categoryBar->launcherTab(id);
if ( !t )
- return 0;
+ return 0;
return t->view;
}
@@ -252,8 +255,8 @@ LauncherView *LauncherTabWidget::docView()
void LauncherTabWidget::setLoadingWidgetEnabled( bool v )
{
if ( v != docLoadingWidgetEnabled && docLoadingWidget ) {
- docLoadingWidgetEnabled = v;
- raiseTabWidget();
+ docLoadingWidgetEnabled = v;
+ raiseTabWidget();
}
}
@@ -604,7 +607,6 @@ void Launcher::properties( AppLnk *appLnk )
LnkProperties prop(appLnk,0 );
if (QPEApplication::execDialog( &prop )==QDialog::Accepted && tabs->currentView()==tabs->docView()) {
- tabs->docView()->updateTools();
}
}
}
@@ -721,8 +723,13 @@ void Launcher::documentRemoved( const DocLnk& doc )
void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc )
{
+#if 0
documentRemoved( oldDoc );
documentAdded( newDoc );
+// tabs->docView()->updateTools();
+#else
+ tabs->docView()->changeItem(oldDoc,new DocLnk(newDoc));
+#endif
}
void Launcher::allDocumentsRemoved()
diff --git a/core/launcher/launcher.h b/core/launcher/launcher.h
index 2eaf77c..db6ac54 100644
--- a/core/launcher/launcher.h
+++ b/core/launcher/launcher.h
@@ -90,6 +90,8 @@ private:
LauncherView *docLoadingWidget;
QProgressBar *docLoadingWidgetProgress;
bool docLoadingWidgetEnabled;
+ bool docTabEnabled;
+ int m_DocumentTabId;
};
class Launcher : public QMainWindow, public ServerInterface
@@ -135,7 +137,7 @@ signals:
void executing( const AppLnk * );
private slots:
- void systemMessage( const QCString &, const QByteArray &);
+ void systemMessage( const QCString &, const QByteArray &);
protected:
bool eventFilter( QObject *o, QEvent *ev );
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index ff26133..c9efacb 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -44,6 +44,7 @@ using namespace Opie::Core;
//#define USE_ANIMATED_BUSY_ICON_OVERLAY
#define BOUNCE_BUSY_ICON
+typedef QMap<QString,QPixmap>::Iterator pixiter;
class BgPixmap
{
@@ -105,7 +106,6 @@ private:
void paintAnimatedIcon( QPainter *p );
BusyIndicatorType busyType;
int psize;
- QPixmap m_iPixmap;
bool m_EyeImage;
iconstate_t m_EyeImageSet;
};
@@ -117,13 +117,16 @@ LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon )
iteration(0),
app(applnk), // Takes ownership
psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ),
- m_iPixmap(),
m_EyeImage(false),
m_EyeImageSet(BASE_ICON)
{
if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) {
m_EyeImage = true;
- m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap());
+ QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(applnk->file());
+ if (it != LauncherIconView::sm_EyeCache->end()) {
+ m_EyeImageSet = EYE_ICON;
+ setPixmap(*it);
+ }
}
}
@@ -213,7 +216,13 @@ void LauncherItem::animateIcon()
// Highlight the icon
if ( iteration == 0 ) {
- QPixmap src = (isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()));
+ QPixmap src;
+ pixiter it;
+ if (isEyeImage() && (it=LauncherIconView::sm_EyeCache->find(appLnk()->file()))!=LauncherIconView::sm_EyeCache->end()) {
+ src = (*it);
+ } else {
+ src = ((isBigIcon ? app->bigPixmap() : app->pixmap()));
+ }
QImage img = src.convertToImage();
QRgb *rgb;
int count;
@@ -249,13 +258,19 @@ void LauncherItem::animateIcon()
void LauncherItem::resetIcon()
{
iteration = 0;
- setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap())));
+ if (isEyeImage()) {
+ QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(appLnk()->file());
+ if (it != LauncherIconView::sm_EyeCache->end()) {
+ setPixmap(*it);
+ return;
+ }
+ }
+ setPixmap(isBigIcon ? app->bigPixmap() : app->pixmap());
}
void LauncherItem::setEyePixmap(const QPixmap&aIcon)
{
if (!isEyeImage()) return;
- m_iPixmap = aIcon;
setPixmap(aIcon);
m_EyeImageSet = EYE_ICON;
}
@@ -263,10 +278,14 @@ void LauncherItem::setEyePixmap(const QPixmap&aIcon)
//===========================================================================
// Implemantation of LauncherIconview start
//===========================================================================
+
+QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0;
+
LauncherIconView::LauncherIconView( QWidget* parent, const char* name )
: QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white)
{
m_EyeCallBack = 0;
+ if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>();
sortmeth = Name;
hidden.setAutoDelete(TRUE);
ike = FALSE;
@@ -432,6 +451,7 @@ void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,in
if (s!=width) return;
LauncherItem*item = findDocItem(aFile);
if (!item||!item->isEyeImage()) return;
+ (*sm_EyeCache)[aFile]=aPixmap;
item->setEyePixmap(aPixmap);
}
@@ -441,8 +461,8 @@ void LauncherIconView::checkCallback()
m_EyeCallBack = new LauncherThumbReceiver();
connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
- m_eyeTimer.changeInterval(600000);
}
+ m_eyeTimer.changeInterval(600000);
}
void LauncherIconView::addCheckItem(AppLnk* app)
@@ -466,27 +486,14 @@ void LauncherIconView::requestEyePix(const LauncherItem*item)
void LauncherIconView::stopEyeTimer()
{
if (m_EyeCallBack) {
+ disconnect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
+ this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
delete m_EyeCallBack;
m_EyeCallBack=0;
}
m_eyeTimer.stop();
}
-void LauncherIconView::addItem(AppLnk* app, bool resort)
-{
- addCatsAndMimes(app);
- if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
- && (cf == 0 || app->categories().contains(cf)
- || cf == -1 && app->categories().count() == 0 ) ) {
- addCheckItem(app);
- } else {
- hidden.append(app);
- }
- if ( resort ){
- sort();
- }
-}
-
void LauncherIconView::updateCategoriesAndMimeTypes()
{
mimes.clear();
@@ -528,7 +535,7 @@ void LauncherIconView::hideOrShowItems(bool resort)
viewport()->setUpdatesEnabled( TRUE );
}
-bool LauncherIconView::removeLink(const QString& linkfile)
+bool LauncherIconView::removeLink(const QString& linkfile,bool removeCache)
{
LauncherItem* item = (LauncherItem*)firstItem();
AppLnk* l;
@@ -539,6 +546,7 @@ bool LauncherIconView::removeLink(const QString& linkfile)
LauncherItem *nextItem = (LauncherItem *)item->nextItem();
if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() &&
( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) {
+ if (removeCache) sm_EyeCache->remove(l->file());
delete item;
did = TRUE;
}
@@ -557,6 +565,38 @@ bool LauncherIconView::removeLink(const QString& linkfile)
return did;
}
+void LauncherIconView::addItem(AppLnk* app, bool resort)
+{
+ addCatsAndMimes(app);
+ if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
+ && (cf == 0 || app->categories().contains(cf)
+ || cf == -1 && app->categories().count() == 0 ) ) {
+ addCheckItem(app);
+ } else {
+ hidden.append(app);
+ }
+ if ( resort ){
+ sort();
+ }
+}
+
+void LauncherIconView::changeItem(const AppLnk&old,AppLnk*nlink)
+{
+ QString oldfile = old.file();
+ QString newfile = nlink->file();
+
+ if (newfile != oldfile) {
+ QMap<QString,QPixmap>::Iterator it = sm_EyeCache->find(oldfile);
+ if (it != sm_EyeCache->end()) {
+ (*sm_EyeCache)[newfile]=(*it);
+ }
+ removeLink(old.linkFile());
+ } else {
+ removeLink(old.linkFile(),false);
+ }
+ addItem(nlink,false);
+}
+
void LauncherIconView::timerEvent( QTimerEvent *te )
{
if ( te->timerId() == busyTimer ) {
@@ -569,6 +609,7 @@ void LauncherIconView::timerEvent( QTimerEvent *te )
void LauncherIconView::setBigIcons( bool bi )
{
+ sm_EyeCache->clear();
bigIcns = bi;
#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
busyPix.resize(0,0);
@@ -756,8 +797,11 @@ void LauncherView::updateTools()
}
int pcat = catmb ? catmb->currentCategory() : -2;
- if ( !catmb )
+ if ( !catmb ) {
catmb = new CategorySelect(tools);
+ } else if (pcat!=-2) {
+
+ }
Categories cats( 0 );
cats.load( categoryFileName() );
QArray<int> vl( 0 );
@@ -1020,7 +1064,7 @@ void LauncherView::itemClicked( int btn, QIconViewItem *item )
icons->setCurrentItem( item );
emit clicked( appLnk );
}
- item->setSelected(FALSE);
+ item->setSelected(FALSE);
}
}
@@ -1047,6 +1091,16 @@ bool LauncherView::removeLink(const QString& linkfile)
return icons->removeLink(linkfile);
}
+void LauncherView::addItem(AppLnk* app, bool resort)
+{
+ icons->addItem(app,resort);
+}
+
+void LauncherView::changeItem(const AppLnk&old,AppLnk*nlink)
+{
+ icons->changeItem(old,nlink);
+}
+
void LauncherView::setSortEnabled( bool v )
{
icons->setSorting( v );
@@ -1064,11 +1118,6 @@ void LauncherView::sort()
icons->sort();
}
-void LauncherView::addItem(AppLnk* app, bool resort)
-{
- icons->addItem(app,resort);
-}
-
void LauncherView::paletteChange( const QPalette &p )
{
icons->unsetPalette();
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h
index 6d94539..05073ab 100644
--- a/core/launcher/launcherview.h
+++ b/core/launcher/launcherview.h
@@ -56,6 +56,8 @@ public:
bool removeLink(const QString& linkfile);
void addItem(AppLnk* app, bool resort=TRUE);
+ void changeItem(const AppLnk&old,AppLnk*nlink);
+
void removeAllItems();
void setSortEnabled(bool);
void setUpdatesEnabled(bool);
@@ -176,7 +178,8 @@ public:
bool inKeyEvent() const { return ike; }
void addItem(AppLnk* app, bool resort=TRUE);
- bool removeLink(const QString& linkfile);
+ bool removeLink(const QString& linkfile,bool removeCache = true);
+ void changeItem(const AppLnk&old,AppLnk*nlink);
QStringList mimeTypes() const;
QStringList categories() const;
@@ -206,6 +209,8 @@ public:
int compare(const AppLnk* a, const AppLnk* b);
void requestEyePix(const LauncherItem*which);
+ static QMap<QString,QPixmap>* sm_EyeCache;
+
protected:
virtual void timerEvent( QTimerEvent *te );
void styleChange( QStyle &old );