summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/applnk.cpp84
1 files changed, 43 insertions, 41 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp
index 80f2c62..c82d3b9 100644
--- a/library/applnk.cpp
+++ b/library/applnk.cpp
@@ -439,70 +439,72 @@ AppLnk& AppLnk::operator=(const AppLnk &copy)
mExec = copy.mExec;
mType = copy.mType;
mRotation = copy.mRotation;
mComment = copy.mComment;
mFile = copy.mFile;
mLinkFile = copy.mLinkFile;
mIconFile = copy.mIconFile;
mMimeTypes = copy.mMimeTypes;
mMimeTypeIcons = copy.mMimeTypeIcons;
mId = 0;
d = new AppLnkPrivate();
d->mCat = copy.d->mCat;
d->mCatList = copy.d->mCatList;
d->mPixmaps = copy.d->mPixmaps;
return *this;
}
/*!
protected internally to share code
should I document that at all?
I don't know the TT style for that
*/
const QPixmap& AppLnk::pixmap( int pos, int size ) const {
if ( d->mPixmaps[pos].isNull() ) {
- AppLnk* that = (AppLnk*)this;
- if ( mIconFile.isEmpty() ) {
- MimeType mt(type());
- that->d->mPixmaps[pos] = pos ? mt.bigPixmap() : mt.pixmap();
- if ( that->d->mPixmaps[pos].isNull() )
- that->d->mPixmaps[pos].convertFromImage(
- Resource::loadImage("UnknownDocument")
- .smoothScale( size, size ) );
- return that->d->mPixmaps[pos];
- }
- QImage unscaledIcon = Resource::loadImage( that->mIconFile );
- if ( unscaledIcon.isNull() ) {
- // qDebug( "Cannot find icon: %s", that->mIconFile.latin1() );
- that->d->mPixmaps[pos].convertFromImage(
- Resource::loadImage("UnknownDocument")
- .smoothScale( size, size ) );
- } else {
- that->d->mPixmaps[0].convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) );
- that->d->mPixmaps[1].convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) );
- }
- return that->d->mPixmaps[pos];
+ AppLnk* that = (AppLnk*)this;
+ if ( mIconFile.isEmpty() ) {
+ MimeType mt(type());
+ that->d->mPixmaps[pos] = pos ? mt.bigPixmap() : mt.pixmap();
+ if ( that->d->mPixmaps[pos].isNull() )
+ that->d->mPixmaps[pos].convertFromImage(
+ Resource::loadImage("UnknownDocument")
+ .smoothScale( size, size ) );
+ return that->d->mPixmaps[pos];
+ }
+
+ QImage unscaledIcon = Resource::loadImage( that->mIconFile );
+ if ( unscaledIcon.isNull() ) {
+ // qDebug( "Cannot find icon: %s", that->mIconFile.latin1() );
+ that->d->mPixmaps[pos].convertFromImage(
+ Resource::loadImage("UnknownDocument")
+ .smoothScale( size, size ) );
+ } else {
+ that->d->mPixmaps[0].convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) );
+ that->d->mPixmaps[1].convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) );
+ }
+ return that->d->mPixmaps[pos];
}
+
return d->mPixmaps[pos];
}
/*!
Returns a small pixmap associated with the application.
\sa bigPixmap() setIcon()
*/
const QPixmap& AppLnk::pixmap() const
{
if ( d->mPixmaps[0].isNull() ) {
return pixmap(AppLnkPrivate::Normal, smallSize );
}
return d->mPixmaps[0];
}
/*!
Returns a large pixmap associated with the application.
\sa pixmap() setIcon()
*/
const QPixmap& AppLnk::bigPixmap() const
{
if ( d->mPixmaps[1].isNull() ) {
@@ -963,75 +965,75 @@ void AppLnk::removeFiles()
// restore link
writeLink();
}
}
}
/*!
Deletes the linkFile(), leaving any file() untouched.
\sa removeFiles()
*/
void AppLnk::removeLinkFile()
{
if ( isValid() && linkFileKnown() && QFile::remove(linkFile()) ) {
#ifndef QT_NO_COP
QCopEnvelope e("QPE/System", "linkChanged(QString)");
e << linkFile();
#endif
}
}
class AppLnkImagePrivate {
public :
AppLnkImagePrivate( const QString & ImageName ) {
- IconName = ImageName;
- Small = 0;
- Big = 0;
+ IconName = ImageName;
+ Small = 0;
+ Big = 0;
}
~AppLnkImagePrivate( ) {
- if ( Small ) delete Small;
- if ( Big ) delete Big;
+ if ( Small ) delete Small;
+ if ( Big ) delete Big;
}
inline QPixmap * small( void ) {
- if( ! Small ) {
- QImage unscaledIcon = Resource::loadImage( IconName );
- // works as long as smallSize remains static
- Small = new QPixmap();
- Small->convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) );
- }
- return Small;
+ if( ! Small ) {
+ QImage unscaledIcon = Resource::loadImage( IconName );
+ // works as long as smallSize remains static
+ Small = new QPixmap();
+ Small->convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) );
+ }
+ return Small;
}
inline QPixmap * big( void ) {
- if( ! Big ) {
- QImage unscaledIcon = Resource::loadImage( IconName );
- // works as long as bigSize remains static
- Big = new QPixmap();
- Big->convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) );
- }
- return Big;
+ if( ! Big ) {
+ QImage unscaledIcon = Resource::loadImage( IconName );
+ // works as long as bigSize remains static
+ Big = new QPixmap();
+ Big->convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) );
+ }
+ return Big;
}
QString IconName;
QPixmap * Small;
QPixmap * Big;
};
class AppLnkSetPrivate {
public:
AppLnkSetPrivate()
{
typPix.setAutoDelete(TRUE);
typName.setAutoDelete(TRUE);
}
QDict<AppLnkImagePrivate> typPix;
QDict<QString> typName;
};
/*!
\class AppLnkSet applnk.h
\brief The AppLnkSet class is a set of AppLnk objects.
*/
@@ -1104,49 +1106,49 @@ AppLnkSet::~AppLnkSet()
QListIterator<AppLnk> it( mApps );
for ( ; it.current(); ) {
AppLnk* a = *it;
++it;
a->mId = 0;
delete a;
}
delete d;
}
void AppLnkSet::findChildren(const QString &dr, const QString& typ, const QString& typName, int depth)
{
depth++;
if ( depth > 10 )
return;
QDir dir( dr );
QString typNameLocal = typName;
if ( dir.exists( ".directory" ) ) {
Config config( dr + "/.directory", Config::File );
config.setGroup( "Desktop Entry" );
typNameLocal = config.readEntry( "Name", typNameLocal );
if ( !typ.isEmpty() ) {
- d->typPix.insert( typ,
+ d->typPix.insert( typ,
new AppLnkImagePrivate( config.readEntry( "Icon", "AppsIcon" ) )
);
d->typName.insert(typ, new QString(typNameLocal));
}
}
const QFileInfoList *list = dir.entryInfoList();
if ( list ) {
QFileInfo* fi;
bool cadded=FALSE;
for ( QFileInfoListIterator it(*list); (fi=*it); ++it ) {
QString bn = fi->fileName();
// qDebug("findChildren "+bn);
if ( bn[0] != '.' && bn != "CVS" ) {
if ( fi->isDir() ) {
QString c = typ.isNull() ? bn : typ+"/"+bn;
QString d = typNameLocal.isNull() ? bn : typNameLocal+"/"+bn;
findChildren(fi->filePath(), c, d, depth );
} else {
if ( fi->extension(FALSE) == "desktop" ) {
AppLnk* app = new AppLnk( fi->filePath() );
#ifdef QT_NO_QWS_MULTIPROCESS
if ( !Global::isBuiltinCommand( app->exec() ) )