-rw-r--r-- | library/applnk.h | 169 |
1 files changed, 169 insertions, 0 deletions
diff --git a/library/applnk.h b/library/applnk.h new file mode 100644 index 0000000..c6f92a3 --- a/dev/null +++ b/library/applnk.h | |||
@@ -0,0 +1,169 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #ifndef __APPLNK_H__ | ||
21 | #define __APPLNK_H__ | ||
22 | |||
23 | #include <qobject.h> | ||
24 | #include <qiconset.h> | ||
25 | #include <qlist.h> | ||
26 | #include <qdict.h> | ||
27 | #include <qstringlist.h> | ||
28 | |||
29 | class AppLnkSetPrivate; | ||
30 | class AppLnkPrivate; | ||
31 | |||
32 | class AppLnk | ||
33 | { | ||
34 | public: | ||
35 | AppLnk(); | ||
36 | AppLnk( const QString &file ); | ||
37 | AppLnk( const AppLnk © ); // copy constructor | ||
38 | virtual ~AppLnk(); | ||
39 | |||
40 | bool isValid() const { return !mLinkFile.isNull(); } | ||
41 | |||
42 | static void setSmallIconSize(int); | ||
43 | static void setBigIconSize(int); | ||
44 | static int smallIconSize(); | ||
45 | static int bigIconSize(); | ||
46 | |||
47 | QString name() const { return mName; } | ||
48 | const QPixmap& pixmap() const; | ||
49 | const QPixmap& bigPixmap() const; | ||
50 | virtual QString exec() const { return mExec; } | ||
51 | QString type() const; | ||
52 | QString rotation() const { return mRotation; } | ||
53 | QString comment() const { return mComment; } | ||
54 | QString file() const; | ||
55 | QString linkFile() const; | ||
56 | QStringList mimeTypes() const { return mMimeTypes; } | ||
57 | QStringList mimeTypeIcons() const { return mMimeTypeIcons; } | ||
58 | const QArray<int> &categories() const; | ||
59 | int id() const { return mId; } | ||
60 | |||
61 | void execute() const; | ||
62 | void execute(const QStringList& args) const; | ||
63 | void removeFiles(); | ||
64 | void removeLinkFile(); | ||
65 | |||
66 | void setName( const QString& docname ); | ||
67 | void setExec( const QString& exec ); | ||
68 | void setFile( const QString& filename ); | ||
69 | void setLinkFile( const QString& filename ); | ||
70 | void setComment( const QString& comment ); | ||
71 | void setType( const QString& mimetype ); | ||
72 | void setIcon( const QString& iconname ); | ||
73 | void setCategories( const QArray<int> &v ); | ||
74 | bool writeLink() const; | ||
75 | |||
76 | void setProperty(const QString& key, const QString& value); | ||
77 | QString property(const QString& key) const; | ||
78 | |||
79 | protected: | ||
80 | QString mName; | ||
81 | QPixmap mPixmap; | ||
82 | QPixmap mBigPixmap; | ||
83 | QString mExec; | ||
84 | QString mType; | ||
85 | QString mRotation; | ||
86 | QString mComment; | ||
87 | QString mFile; | ||
88 | QString mLinkFile; | ||
89 | QString mIconFile; | ||
90 | QStringList mMimeTypes; | ||
91 | QStringList mMimeTypeIcons; | ||
92 | int mId; | ||
93 | static int lastId; | ||
94 | AppLnkPrivate *d; | ||
95 | friend class AppLnkSet; | ||
96 | |||
97 | virtual void invoke(const QStringList& args) const; | ||
98 | bool ensureLinkExists() const; | ||
99 | }; | ||
100 | |||
101 | class DocLnk : public AppLnk | ||
102 | { | ||
103 | public: | ||
104 | DocLnk(); | ||
105 | DocLnk( const DocLnk &o ) : AppLnk(o) { } | ||
106 | DocLnk( const QString &file ); | ||
107 | DocLnk( const QString &file, bool may_be_desktopfile ); | ||
108 | virtual ~DocLnk(); | ||
109 | |||
110 | QString exec() const; | ||
111 | |||
112 | protected: | ||
113 | void invoke(const QStringList& args) const; | ||
114 | |||
115 | private: | ||
116 | void init(const QString &file); | ||
117 | }; | ||
118 | |||
119 | class AppLnkSet | ||
120 | { | ||
121 | public: | ||
122 | AppLnkSet(); | ||
123 | AppLnkSet( const QString &dir ); | ||
124 | ~AppLnkSet(); | ||
125 | |||
126 | const AppLnk *find( int id ) const; | ||
127 | const AppLnk *findExec( const QString& execname ) const; | ||
128 | |||
129 | QStringList types() const { return typs; } | ||
130 | QString typeName( const QString& ) const; | ||
131 | QPixmap typePixmap( const QString& ) const; | ||
132 | QPixmap typeBigPixmap( const QString& ) const; | ||
133 | |||
134 | void add(AppLnk*); | ||
135 | bool remove(AppLnk*); | ||
136 | |||
137 | const QList<AppLnk> &children() const { return mApps; } | ||
138 | void detachChildren(); | ||
139 | |||
140 | protected: | ||
141 | friend class AppLnk; | ||
142 | QList<AppLnk> mApps; | ||
143 | QString mFile; | ||
144 | QStringList typs; | ||
145 | AppLnkSetPrivate *d; | ||
146 | |||
147 | private: | ||
148 | AppLnkSet( const AppLnkSet & ); // no copying! | ||
149 | void findChildren(const QString &, const QString& t, const QString& lt, int depth = 0); | ||
150 | }; | ||
151 | |||
152 | class DocLnkSet : public AppLnkSet | ||
153 | { | ||
154 | public: | ||
155 | DocLnkSet(); | ||
156 | DocLnkSet( const QString &dir, const QString &mimefilter=QString::null ); | ||
157 | |||
158 | const QList<DocLnk> &children() const { return (const QList<DocLnk> &)mApps; } | ||
159 | |||
160 | void appendFrom( DocLnkSet& other ); | ||
161 | |||
162 | private: | ||
163 | DocLnkSet( const DocLnkSet & ); // no copying! | ||
164 | void findChildren(const QString &dr, const QValueList<QRegExp> &mimeFilters, QDict<void> &reference, int depth=0); | ||
165 | }; | ||
166 | |||
167 | |||
168 | #endif // __APPLNK_H__ | ||
169 | |||