summaryrefslogtreecommitdiff
path: root/noncore/applets/keyhelper/keyhelperapplet/anylnk/AppLnkManager.h
blob: 844657813c98e37c94e63e81ff93c0d49f89e198 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef _APPLNK_MANAGER_H_
#define _APPLNK_MANAGER_H_

#include <qsize.h>

#include <qpe/applnk.h>
#include <qpe/mimetype.h>

class AppLnkManager
{
public:
	AppLnkManager(){
	}
	~AppLnkManager(){
		if(m_pLnkSet) delete m_pLnkSet;
	}
	static void init(bool force=false){
		if(m_notfound || force){
			if(m_pLnkSet){
				delete m_pLnkSet;
			}
			qDebug("AppLnkManager::init()");
			m_pLnkSet = new AppLnkSet(MimeType::appsFolderName());
			m_notfound = false;
		}
	}
	static AppLnkSet* getInstance(){
		if(m_pLnkSet == NULL){
			init(true);
		}
		return(m_pLnkSet);
	}
	static const QSize& getIconSize(){
		if(m_oIconSize.isValid()){
			return(m_oIconSize);
		}
		const QList<AppLnk>& lnkList = getInstance()->children();
		QListIterator<AppLnk> it(lnkList);
		for(; it.current(); ++it){
			if((*it)->pixmap().isNull() == false){
				m_oIconSize = (*it)->pixmap().size();
				break;
			}
		}
		return(m_oIconSize);
	}
	static void notfound(){
		m_notfound = true;
	}
private:
	static bool m_notfound;
	static AppLnkSet* m_pLnkSet;
	static QSize m_oIconSize;
};

#endif /* _APPLNK_MANAGER_H_ */