summaryrefslogtreecommitdiff
path: root/core
Side-by-side diff
Diffstat (limited to 'core') (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/launcher.cpp4
-rw-r--r--core/launcher/launcherview.cpp27
-rw-r--r--core/launcher/launcherview.h1
3 files changed, 13 insertions, 19 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 010a2e9..5ec1cf8 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -582,49 +582,51 @@ void Launcher::select( const AppLnk *appLnk )
int i = QMessageBox::information(this,tr("No application"),
tr("<p>No application is defined for this document."
"<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1);
/* ### Fixme */
if ( i == 1 )
Global::execute("textedit",appLnk->file());
return;
}
tabs->setBusy(TRUE);
emit executing( appLnk );
appLnk->execute();
}
}
void Launcher::properties( AppLnk *appLnk )
{
if ( appLnk->type() == "Folder" ) { // No tr
// Not supported: flat is simpler for the user
} else {
/* ### libqtopia FIXME also moving docLnks... */
LnkProperties prop(appLnk,0 );
- QPEApplication::execDialog( &prop );
+ if (QPEApplication::execDialog( &prop )==QDialog::Accepted && tabs->currentView()==tabs->docView()) {
+ tabs->docView()->updateTools();
+ }
}
}
void Launcher::storageChanged( const QList<FileSystem> & )
{
// ### update combo boxes if we had a combo box for the storage type
}
void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
{
QDataStream stream( data, IO_ReadOnly );
if ( msg == "busy()" ) {
tb->startWait();
} else if ( msg == "notBusy(QString)" ) {
QString app;
stream >> app;
tabs->setBusy(FALSE);
tb->stopWait(app);
} else if (msg == "applyStyle()") {
tabs->currentView()->relayout();
}
}
// These are the update functions from the server
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 72313e3..ff26133 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -255,48 +255,49 @@ void LauncherItem::resetIcon()
void LauncherItem::setEyePixmap(const QPixmap&aIcon)
{
if (!isEyeImage()) return;
m_iPixmap = aIcon;
setPixmap(aIcon);
m_EyeImageSet = EYE_ICON;
}
//===========================================================================
// Implemantation of LauncherIconview start
//===========================================================================
LauncherIconView::LauncherIconView( QWidget* parent, const char* name )
: QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white)
{
m_EyeCallBack = 0;
sortmeth = Name;
hidden.setAutoDelete(TRUE);
ike = FALSE;
calculateGrid( Bottom );
connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer()));
}
LauncherIconView::~LauncherIconView()
{
+ odebug << "LauncherIconView::~LauncherIconView()" << oendl;
#if 0 // debuggery
QListIterator<AppLnk> it(hidden);
AppLnk* l;
while ((l=it.current())) {
++it;
//odebug << "" << l << ": hidden (should remove)" << oendl;
}
#endif
}
int LauncherIconView::compare(const AppLnk* a, const AppLnk* b)
{
switch (sortmeth) {
case Name:
return a->name().lower().compare(b->name().lower());
case Date: {
QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file());
QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file());
return fa.lastModified().secsTo(fb.lastModified());
}
case Type:
return a->type().compare(b->type());
}
return 0;
@@ -408,96 +409,87 @@ QStringList LauncherIconView::mimeTypes() const
while (it.current()) {
r.append(it.currentKey());
++it;
}
r.sort();
return r;
}
LauncherItem*LauncherIconView::findDocItem(const QString&fname)
{
LauncherItem* item = (LauncherItem*)firstItem();
while (item) {
if (item->appLnk()->file()==fname) {
break;
}
item = (LauncherItem*)item->nextItem();
}
return item;
}
void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width)
{
int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
if (s!=width) return;
- LauncherItem*item = 0;
- QMap<QString,LauncherItem*>::Iterator it;
- if ( ( it = m_itemCache.find(aFile))!=m_itemCache.end()) {
- item = it.data();
- m_itemCache.remove(it);
- } else {
- item = findDocItem(aFile);
- }
+ LauncherItem*item = findDocItem(aFile);
if (!item||!item->isEyeImage()) return;
item->setEyePixmap(aPixmap);
}
void LauncherIconView::checkCallback()
{
if (!m_EyeCallBack) {
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);
}
}
void LauncherIconView::addCheckItem(AppLnk* app)
{
LauncherItem*item = new LauncherItem( this, app, bigIcns );
if (item->isEyeImage()) {
checkCallback();
}
}
void LauncherIconView::requestEyePix(const LauncherItem*item)
{
if (!item) return;
if (item->isEyeImage()) {
checkCallback();
int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
- m_itemCache[item->appLnk()->file()]=(LauncherItem*)item;
m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s);
}
}
void LauncherIconView::stopEyeTimer()
{
if (m_EyeCallBack) {
delete m_EyeCallBack;
m_EyeCallBack=0;
}
- m_itemCache.clear();
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();
cats.clear();
LauncherItem* item = (LauncherItem*)firstItem();
while (item) {
@@ -683,152 +675,152 @@ LauncherView::~LauncherView()
bool LauncherView::bsy=FALSE;
void LauncherView::setBusy(bool on)
{
icons->setBusy(on);
}
void LauncherView::setBusyIndicatorType( const QString& type ) {
if ( type. lower ( ) == "animated" )
icons->setBusyIndicatorType( BIT_Animated ) ;
else
icons->setBusyIndicatorType( BIT_Normal ) ;
}
void LauncherView::hideIcons()
{
icons->hide();
}
void LauncherView::setToolsEnabled(bool y)
{
if ( !y != !tools ) {
if ( y ) {
tools = new QHBox(this);
-
// Type filter
typemb = new QComboBox(tools);
QSizePolicy p = typemb->sizePolicy();
p.setHorData(QSizePolicy::Expanding);
typemb->setSizePolicy(p);
-
// Category filter
updateTools();
tools->show();
-
} else {
delete tools;
tools = 0;
}
}
}
void LauncherView::updateTools()
{
disconnect( typemb, SIGNAL(activated(int)),
this, SLOT(showType(int)) );
- if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)),
- this, SLOT(showCategory(int)) );
+ if ( catmb ) {
+ disconnect( catmb, SIGNAL(signalSelected(int)),this,SLOT(showCategory(int)));
+ }
// ### I want to remove this
icons->updateCategoriesAndMimeTypes();
QString prev;
// Type filter
QStringList types;
typelist = icons->mimeTypes();
for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) {
QString t = *it;
if ( t.left(12) == "application/" ) {
MimeType mt(t);
const AppLnk* app = mt.application();
if ( app )
t = app->name();
else
t = t.mid(12);
} else {
t[0] = t[0].upper();
}
types += t;
}
types << tr("All types");
prev = typemb->currentText();
typemb->clear();
typemb->insertStringList(types);
for (int i=0; i<typemb->count(); i++) {
if ( typemb->text(i) == prev ) {
typemb->setCurrentItem(i);
break;
}
}
- if ( prev.isNull() )
+ if ( prev.isNull() ) {
typemb->setCurrentItem(typemb->count()-1);
+ }
int pcat = catmb ? catmb->currentCategory() : -2;
if ( !catmb )
catmb = new CategorySelect(tools);
Categories cats( 0 );
cats.load( categoryFileName() );
QArray<int> vl( 0 );
catmb->setCategories( vl, "Document View", // No tr
tr("Document View") );
catmb->setRemoveCategoryEdit( TRUE );
catmb->setAllCategories( TRUE );
catmb->setCurrentCategory(pcat);
// if type has changed we need to redisplay
if ( typemb->currentText() != prev )
showType( typemb->currentItem() );
connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int)));
connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
}
void LauncherView::sortBy(int s)
{
icons->setSortMethod((LauncherIconView::SortMethod)s);
}
void LauncherView::showType(int t)
{
if ( t >= (int)typelist.count() ) {
icons->setTypeFilter("",TRUE);
} else {
QString ty = typelist[t];
if ( !ty.contains('/') )
ty += "/*";
icons->setTypeFilter(ty,TRUE);
}
}
void LauncherView::showCategory( int c )
{
icons->setCategoryFilter( c, TRUE );
}
void LauncherView::setViewMode( ViewMode m )
{
+ odebug << "LauncherView::setViewMode( ViewMode m )" << oendl;
if ( vmode != m ) {
bool bigIcons = m == Icon;
icons->viewport()->setUpdatesEnabled( FALSE );
icons->setBigIcons( bigIcons );
switch ( m ) {
case List:
icons->setItemTextPos( QIconView::Right );
break;
case Icon:
icons->setItemTextPos( QIconView::Bottom );
break;
}
icons->hideOrShowItems( FALSE );
icons->viewport()->setUpdatesEnabled( TRUE );
vmode = m;
}
}
//
// User images may require scaling.
//
QImage LauncherView::loadBackgroundImage(QString &bgName)
{
QImageIO imgio;
@@ -1025,48 +1017,49 @@ void LauncherView::itemClicked( int btn, QIconViewItem *item )
AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
if ( btn == LeftButton ) {
// Make sure it's the item we execute that gets highlighted
icons->setCurrentItem( item );
emit clicked( appLnk );
}
item->setSelected(FALSE);
}
}
void LauncherView::itemPressed( int btn, QIconViewItem *item )
{
if ( item ) {
AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
if ( btn == RightButton )
emit rightPressed( appLnk );
else if ( btn == ShiftButton )
emit rightPressed( appLnk );
item->setSelected(FALSE);
}
}
void LauncherView::removeAllItems()
{
+ odebug << "LauncherView::removeAllItems()" << oendl;
icons->clear();
}
bool LauncherView::removeLink(const QString& linkfile)
{
return icons->removeLink(linkfile);
}
void LauncherView::setSortEnabled( bool v )
{
icons->setSorting( v );
if ( v )
sort();
}
void LauncherView::setUpdatesEnabled( bool u )
{
icons->setUpdatesEnabled( u );
}
void LauncherView::sort()
{
icons->sort();
}
@@ -1147,35 +1140,35 @@ LauncherThumbReceiver::~LauncherThumbReceiver()
}
}
void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at )
{
PixmapInfos pixinfos;
QDataStream stream( at, IO_ReadOnly );
/* we are just interested in thumbmails */
if ( str == "pixmapsHandled(PixmapList)" )
stream >> pixinfos;
for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) {
emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width);
}
}
void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height)
{
PixmapInfo rItem;
rItem.file = file;
rItem.width = width;
rItem.height = height;
m_inThumbNail.append(rItem);
- QTimer::singleShot(0, this, SLOT(sendRequest()));
+ QTimer::singleShot(2, this, SLOT(sendRequest()));
}
void LauncherThumbReceiver::sendRequest()
{
if (m_inThumbNail.count()>0) {
QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" );
env << m_inThumbNail;
m_inThumbNail.clear();
}
}
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h
index 94c367c..6d94539 100644
--- a/core/launcher/launcherview.h
+++ b/core/launcher/launcherview.h
@@ -219,28 +219,27 @@ protected:
protected slots:
void setEyePixmap(const QPixmap&,const QString&,int width);
void stopEyeTimer();
private:
QList<AppLnk> hidden;
QDict<void> mimes;
QDict<void> cats;
SortMethod sortmeth;
QRegExp tf;
int cf;
LauncherItem* bsy;
int busyTimer;
bool ike;
bool bigIcns;
QPixmap bgPixmap;
QColor bgColor;
LauncherThumbReceiver*m_EyeCallBack;
#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
QPixmap busyPix;
#endif
BusyIndicatorType busyType;
QTimer m_eyeTimer;
- QMap<QString,LauncherItem*> m_itemCache;
};
#endif // LAUNCHERVIEW_H