summaryrefslogtreecommitdiff
path: root/library/applnk.h
Unidiff
Diffstat (limited to 'library/applnk.h') (more/less context) (ignore whitespace changes)
-rw-r--r--library/applnk.h38
1 files changed, 34 insertions, 4 deletions
diff --git a/library/applnk.h b/library/applnk.h
index 9b5523e..71b62ef 100644
--- a/library/applnk.h
+++ b/library/applnk.h
@@ -1,177 +1,207 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef __APPLNK_H__ 20#ifndef __APPLNK_H__
21#define __APPLNK_H__ 21#define __APPLNK_H__
22 22
23#include <qobject.h> 23#include <qobject.h>
24#include <qiconset.h> 24#include <qiconset.h>
25#include <qlist.h> 25#include <qlist.h>
26#include <qdict.h> 26#include <qdict.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28 28
29class AppLnkSetPrivate; 29class AppLnkSetPrivate;
30class AppLnkPrivate; 30class AppLnkPrivate;
31 31
32class AppLnk 32class AppLnk
33{ 33{
34public: 34public:
35 AppLnk(); 35 AppLnk();
36 AppLnk( const QString &file ); 36 AppLnk( const QString &file );
37 AppLnk( const AppLnk &copy ); // copy constructor 37 AppLnk( const AppLnk &copy ); // copy constructor
38 virtual ~AppLnk(); 38 virtual ~AppLnk();
39 39
40 bool isValid() const { return !mLinkFile.isNull(); } 40 bool isValid() const { return !mLinkFile.isNull(); }
41 41
42 static void setSmallIconSize(int); 42 static void setSmallIconSize(int);
43 static void setBigIconSize(int); 43 static void setBigIconSize(int);
44 static int smallIconSize(); 44 static int smallIconSize();
45 static int bigIconSize(); 45 static int bigIconSize();
46 46
47 QString name() const { return mName; } 47 QString name() const { return mName; }
48 const QPixmap& pixmap() const; 48 const QPixmap& pixmap() const;
49 const QPixmap& bigPixmap() const; 49 const QPixmap& bigPixmap() const;
50 QString icon() const { return mIconFile; }
50 virtual QString exec() const { return mExec; } 51 virtual QString exec() const { return mExec; }
51 QString type() const; 52 QString type() const;
52 QString rotation() const { return mRotation; } 53 QString rotation() const { return mRotation; }
53 QString comment() const { return mComment; } 54 QString comment() const { return mComment; }
54 QString file() const; 55 QString file() const;
55 QString linkFile() const; 56 QString linkFile() const;
56 QStringList mimeTypes() const { return mMimeTypes; } 57 QStringList mimeTypes() const { return mMimeTypes; }
57 QStringList mimeTypeIcons() const { return mMimeTypeIcons; } 58 QStringList mimeTypeIcons() const { return mMimeTypeIcons; }
58 const QArray<int> &categories() const; 59 const QArray<int> &categories() const;
59 int id() const { return mId; } 60 int id() const { return mId; }
60 61
62 bool fileKnown() const { return !mFile.isNull(); }
61 bool linkFileKnown() const { return !mLinkFile.isNull(); } 63 bool linkFileKnown() const { return !mLinkFile.isNull(); }
62 64
63 void execute() const; 65 void execute() const;
64 void execute(const QStringList& args) const; 66 void execute(const QStringList& args) const;
65 void removeFiles(); 67 void removeFiles();
66 void removeLinkFile(); 68 void removeLinkFile();
67 69
68 void setName( const QString& docname ); 70 void setName( const QString& docname );
69 void setExec( const QString& exec ); 71 void setExec( const QString& exec );
70 void setFile( const QString& filename ); 72 void setFile( const QString& filename );
71 void setLinkFile( const QString& filename ); 73 void setLinkFile( const QString& filename );
72 void setComment( const QString& comment ); 74 void setComment( const QString& comment );
73 void setType( const QString& mimetype ); 75 void setType( const QString& mimetype );
74 void setIcon( const QString& iconname ); 76 void setIcon( const QString& iconname );
75 void setCategories( const QArray<int> &v ); 77 void setCategories( const QArray<int> &v );
76 bool writeLink() const; 78 bool writeLink() const;
77 79
78 void setProperty(const QString& key, const QString& value); 80 void setProperty(const QString& key, const QString& value);
79 QString property(const QString& key) const; 81 QString property(const QString& key) const;
80 82
81//#ifdef QTOPIA_INTERNAL_PRELOADACCESS 83#ifdef QTOPIA_INTERNAL_PRELOADACCESS
82 bool isPreloaded() const; 84 bool isPreloaded() const;
83 void setPreloaded(bool yesNo); 85 void setPreloaded(bool yesNo);
84//#endif 86#endif
87
88#ifdef QTOPIA_INTERNAL_APPLNKASSIGN
89 AppLnk &operator=(const AppLnk &other);
90#endif
85 91
86protected: 92protected:
87 QString mName; 93 QString mName;
94
95 /* remove for Qtopia 3.0 -zecke */
88 QPixmap mPixmap; 96 QPixmap mPixmap;
97
98 /* remove for Qtopia 3.0 -zecke */
89 QPixmap mBigPixmap; 99 QPixmap mBigPixmap;
100
90 QString mExec; 101 QString mExec;
91 QString mType; 102 QString mType;
92 QString mRotation; 103 QString mRotation;
93 QString mComment; 104 QString mComment;
94 QString mFile; 105 QString mFile;
95 QString mLinkFile; 106 QString mLinkFile;
96 QString mIconFile; 107 QString mIconFile;
97 QStringList mMimeTypes; 108 QStringList mMimeTypes;
98 QStringList mMimeTypeIcons; 109 QStringList mMimeTypeIcons;
99 int mId; 110 int mId;
100 static int lastId; 111 static int lastId;
101 AppLnkPrivate *d; 112 AppLnkPrivate *d;
102 friend class AppLnkSet; 113 friend class AppLnkSet;
103 114
104 virtual void invoke(const QStringList& args) const; 115 virtual void invoke(const QStringList& args) const;
105 bool ensureLinkExists() const; 116 bool ensureLinkExists() const;
106 void storeLink() const; 117 void storeLink() const;
118
119private:
120 const QPixmap& pixmap(int pos, int size) const;
107}; 121};
108 122
109class DocLnk : public AppLnk 123class DocLnk : public AppLnk
110{ 124{
111public: 125public:
112 DocLnk(); 126 DocLnk();
113 DocLnk( const DocLnk &o ) : AppLnk(o) { } 127 DocLnk( const DocLnk &o ) : AppLnk(o) { }
114 DocLnk( const QString &file ); 128 DocLnk( const QString &file );
115 DocLnk( const QString &file, bool may_be_desktopfile ); 129 DocLnk( const QString &file, bool may_be_desktopfile );
116 virtual ~DocLnk(); 130 virtual ~DocLnk();
117 131
132
133#ifdef QTOPIA_INTERNAL_APPLNKASSIGN
134 DocLnk &operator=(const DocLnk &other) { AppLnk::operator=(other); return *this; }
135#endif
136
118 QString exec() const; 137 QString exec() const;
119 138
120protected: 139protected:
121 void invoke(const QStringList& args) const; 140 void invoke(const QStringList& args) const;
122 141
123private: 142private:
124 void init(const QString &file); 143 void init(const QString &file);
125}; 144};
126 145
127class AppLnkSet 146class AppLnkSet
128{ 147{
129public: 148public:
130 AppLnkSet(); 149 AppLnkSet();
131 AppLnkSet( const QString &dir ); 150 AppLnkSet( const QString &dir );
132 ~AppLnkSet(); 151 ~AppLnkSet();
133 152
134 const AppLnk *find( int id ) const; 153 const AppLnk *find( int id ) const;
135 const AppLnk *findExec( const QString& execname ) const; 154 const AppLnk *findExec( const QString& execname ) const;
136 155
137 QStringList types() const { return typs; } 156 QStringList types() const { return typs; }
138 QString typeName( const QString& ) const; 157 QString typeName( const QString& ) const;
139 QPixmap typePixmap( const QString& ) const; 158 QPixmap typePixmap( const QString& ) const;
140 QPixmap typeBigPixmap( const QString& ) const; 159 QPixmap typeBigPixmap( const QString& ) const;
141 160
142 void add(AppLnk*); 161 void add(AppLnk*);
143 bool remove(AppLnk*); 162 bool remove(AppLnk*);
163 void clear() {
164 QListIterator<AppLnk> it( mApps );
165 for ( ; it.current(); ) {
166 AppLnk* a = *it;
167 ++it;
168 a->mId = 0;
169 delete a;
170 }
171 mApps.clear();
172 typs.clear();
173 }
144 174
145 const QList<AppLnk> &children() const { return mApps; } 175 const QList<AppLnk> &children() const { return mApps; }
146 void detachChildren(); 176 void detachChildren();
147 177
148protected: 178protected:
149 friend class AppLnk; 179 friend class AppLnk;
150 QList<AppLnk> mApps; 180 QList<AppLnk> mApps;
151 QString mFile; 181 QString mFile;
152 QStringList typs; 182 QStringList typs;
153 AppLnkSetPrivate *d; 183 AppLnkSetPrivate *d;
154 184
155private: 185private:
156 AppLnkSet( const AppLnkSet & ); // no copying! 186 AppLnkSet( const AppLnkSet & ); // no copying!
157 void findChildren(const QString &, const QString& t, const QString& lt, int depth = 0); 187 void findChildren(const QString &, const QString& t, const QString& lt, int depth = 0);
158}; 188};
159 189
160class DocLnkSet : public AppLnkSet 190class DocLnkSet : public AppLnkSet
161{ 191{
162public: 192public:
163 DocLnkSet(); 193 DocLnkSet();
164 DocLnkSet( const QString &dir, const QString &mimefilter=QString::null ); 194 DocLnkSet( const QString &dir, const QString &mimefilter=QString::null );
165 195
166 const QList<DocLnk> &children() const { return (const QList<DocLnk> &)mApps; } 196 const QList<DocLnk> &children() const { return (const QList<DocLnk> &)mApps; }
167 197
168 void appendFrom( DocLnkSet& other ); 198 void appendFrom( DocLnkSet& other );
169 199
170private: 200private:
171 DocLnkSet( const DocLnkSet & ); // no copying! 201 DocLnkSet( const DocLnkSet & ); // no copying!
172 void findChildren(const QString &dr, const QValueList<QRegExp> &mimeFilters, QDict<void> &reference, int depth=0); 202 void findChildren(const QString &dr, const QValueList<QRegExp> &mimeFilters, QDict<void> &reference, int depth=0);
173}; 203};
174 204
175 205
176#endif // __APPLNK_H__ 206#endif // __APPLNK_H__
177 207