-rw-r--r-- | core/launcher/documentlist.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp index 1a7de33..ece6931 100644 --- a/core/launcher/documentlist.cpp +++ b/core/launcher/documentlist.cpp | |||
@@ -18,257 +18,257 @@ | |||
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "documentlist.h" | 20 | #include "documentlist.h" |
21 | #include "serverinterface.h" | 21 | #include "serverinterface.h" |
22 | #include "launcherglobal.h" | 22 | #include "launcherglobal.h" |
23 | 23 | ||
24 | #include <qtopia/config.h> | 24 | #include <qtopia/config.h> |
25 | #include <qtopia/mimetype.h> | 25 | #include <qtopia/mimetype.h> |
26 | #include <qtopia/resource.h> | 26 | #include <qtopia/resource.h> |
27 | #include <qtopia/global.h> | 27 | #include <qtopia/global.h> |
28 | #include <qtopia/private/categories.h> | 28 | #include <qtopia/private/categories.h> |
29 | #include <qtopia/qpeapplication.h> | 29 | #include <qtopia/qpeapplication.h> |
30 | #include <qtopia/applnk.h> | 30 | #include <qtopia/applnk.h> |
31 | #include <qtopia/storage.h> | 31 | #include <qtopia/storage.h> |
32 | #ifdef Q_WS_QWS | 32 | #ifdef Q_WS_QWS |
33 | #include <qtopia/qcopenvelope_qws.h> | 33 | #include <qtopia/qcopenvelope_qws.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #include <qfileinfo.h> | 37 | #include <qfileinfo.h> |
38 | #include <qtextstream.h> | 38 | #include <qtextstream.h> |
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qdir.h> | 40 | #include <qdir.h> |
41 | #include <qpainter.h> | 41 | #include <qpainter.h> |
42 | #include <qimage.h> | 42 | #include <qimage.h> |
43 | #include <qcopchannel_qws.h> | 43 | #include <qcopchannel_qws.h> |
44 | #include <qlistview.h> | 44 | #include <qlistview.h> |
45 | #include <qlist.h> | 45 | #include <qlist.h> |
46 | #include <qpixmap.h> | 46 | #include <qpixmap.h> |
47 | 47 | ||
48 | 48 | ||
49 | AppLnkSet *DocumentList::appLnkSet = 0; | 49 | AppLnkSet *DocumentList::appLnkSet = 0; |
50 | 50 | ||
51 | static const int MAX_SEARCH_DEPTH = 10; | 51 | static const int MAX_SEARCH_DEPTH = 10; |
52 | 52 | ||
53 | 53 | ||
54 | class DocumentListPrivate : public QObject { | 54 | class DocumentListPrivate : public QObject { |
55 | Q_OBJECT | 55 | Q_OBJECT |
56 | public: | 56 | public: |
57 | DocumentListPrivate( ServerInterface *gui ); | 57 | DocumentListPrivate( ServerInterface *gui ); |
58 | ~DocumentListPrivate(); | 58 | ~DocumentListPrivate(); |
59 | 59 | ||
60 | void initialize(); | 60 | void initialize(); |
61 | 61 | ||
62 | const QString nextFile(); | 62 | const QString nextFile(); |
63 | const DocLnk *iterate(); | 63 | const DocLnk *iterate(); |
64 | bool store( DocLnk* dl ); | 64 | bool store( DocLnk* dl ); |
65 | void estimatedPercentScanned(); | 65 | void estimatedPercentScanned(); |
66 | 66 | ||
67 | DocLnkSet dls; | 67 | DocLnkSet dls; |
68 | QDict<void> reference; | 68 | QDict<void> reference; |
69 | QDictIterator<void> *dit; | 69 | QDictIterator<void> *dit; |
70 | enum { Find, RemoveKnownFiles, MakeUnknownFiles, Done } state; | 70 | enum { Find, RemoveKnownFiles, MakeUnknownFiles, Done } state; |
71 | 71 | ||
72 | QStringList docPaths; | 72 | QStringList docPaths; |
73 | unsigned int docPathsSearched; | 73 | unsigned int docPathsSearched; |
74 | 74 | ||
75 | int searchDepth; | 75 | int searchDepth; |
76 | QDir *listDirs[MAX_SEARCH_DEPTH]; | 76 | QDir *listDirs[MAX_SEARCH_DEPTH]; |
77 | const QFileInfoList *lists[MAX_SEARCH_DEPTH]; | 77 | const QFileInfoList *lists[MAX_SEARCH_DEPTH]; |
78 | unsigned int listPositions[MAX_SEARCH_DEPTH]; | 78 | unsigned int listPositions[MAX_SEARCH_DEPTH]; |
79 | 79 | ||
80 | StorageInfo *storage; | 80 | StorageInfo *storage; |
81 | 81 | ||
82 | int tid; | 82 | int tid; |
83 | 83 | ||
84 | ServerInterface *serverGui; | 84 | ServerInterface *serverGui; |
85 | 85 | ||
86 | bool needToSendAllDocLinks; | 86 | bool needToSendAllDocLinks; |
87 | bool sendAppLnks; | 87 | bool sendAppLnks; |
88 | bool sendDocLnks; | 88 | bool sendDocLnks; |
89 | bool scanDocs; | 89 | bool scanDocs; |
90 | }; | 90 | }; |
91 | 91 | ||
92 | 92 | ||
93 | DocumentList::DocumentList( ServerInterface *serverGui, bool scanDocs, | 93 | DocumentList::DocumentList( ServerInterface *serverGui, bool scanDocs, |
94 | QObject *parent, const char *name ) | 94 | QObject *parent, const char *name ) |
95 | : QObject( parent, name ) | 95 | : QObject( parent, name ) |
96 | { | 96 | { |
97 | appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); | 97 | appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); |
98 | d = new DocumentListPrivate( serverGui ); | 98 | d = new DocumentListPrivate( serverGui ); |
99 | d->needToSendAllDocLinks = false; | 99 | d->needToSendAllDocLinks = false; |
100 | 100 | ||
101 | Config cfg( "Launcher" ); | 101 | Config cfg( "Launcher" ); |
102 | cfg.setGroup( "DocTab" ); | 102 | cfg.setGroup( "DocTab" ); |
103 | d->scanDocs = cfg.readBoolEntry( "Enable", true ); | 103 | d->scanDocs = cfg.readBoolEntry( "Enable", true ); |
104 | qDebug( "DocumentList::DocumentList() : scanDocs = %d", d->scanDocs ); | 104 | qDebug( "DocumentList::DocumentList() : scanDocs = %d", d->scanDocs ); |
105 | 105 | ||
106 | QTimer::singleShot( 10, this, SLOT( startInitialScan() ) ); | 106 | QTimer::singleShot( 10, this, SLOT( startInitialScan() ) ); |
107 | } | 107 | } |
108 | 108 | ||
109 | void DocumentList::startInitialScan() | 109 | void DocumentList::startInitialScan() |
110 | { | 110 | { |
111 | reloadAppLnks(); | 111 | reloadAppLnks(); |
112 | reloadDocLnks(); | 112 | reloadDocLnks(); |
113 | } | 113 | } |
114 | 114 | ||
115 | DocumentList::~DocumentList() | 115 | DocumentList::~DocumentList() |
116 | { | 116 | { |
117 | delete appLnkSet; | 117 | delete appLnkSet; |
118 | delete d; | 118 | delete d; |
119 | } | 119 | } |
120 | 120 | ||
121 | 121 | ||
122 | void DocumentList::add( const DocLnk& doc ) | 122 | void DocumentList::add( const DocLnk& doc ) |
123 | { | 123 | { |
124 | if ( d->serverGui && QFile::exists( doc.file() ) ) | 124 | if ( d->serverGui && QFile::exists( doc.file() ) ) |
125 | d->serverGui->documentAdded( doc ); | 125 | d->serverGui->documentAdded( doc ); |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | void DocumentList::start() | 129 | void DocumentList::start() |
130 | { | 130 | { |
131 | resume(); | 131 | resume(); |
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
135 | void DocumentList::pause() | 135 | void DocumentList::pause() |
136 | { | 136 | { |
137 | //qDebug("pause %i", d->tid); | 137 | //qDebug("pause %i", d->tid); |
138 | killTimer( d->tid ); | 138 | killTimer( d->tid ); |
139 | d->tid = 0; | 139 | d->tid = 0; |
140 | } | 140 | } |
141 | 141 | ||
142 | 142 | ||
143 | void DocumentList::resume() | 143 | void DocumentList::resume() |
144 | { | 144 | { |
145 | if ( d->tid == 0 ) { | 145 | if ( d->tid == 0 ) { |
146 | d->tid = startTimer( 0 ); | 146 | d->tid = startTimer( 20 ); |
147 | //qDebug("resumed %i", d->tid); | 147 | //qDebug("resumed %i", d->tid); |
148 | } | 148 | } |
149 | } | 149 | } |
150 | 150 | ||
151 | /* | 151 | /* |
152 | void DocumentList::resend() | 152 | void DocumentList::resend() |
153 | { | 153 | { |
154 | // Re-emits all the added items to the list (firstly letting everyone know to | 154 | // Re-emits all the added items to the list (firstly letting everyone know to |
155 | // clear what they have as it is being sent again) | 155 | // clear what they have as it is being sent again) |
156 | pause(); | 156 | pause(); |
157 | emit allRemoved(); | 157 | emit allRemoved(); |
158 | QTimer::singleShot( 5, this, SLOT( resendWorker() ) ); | 158 | QTimer::singleShot( 5, this, SLOT( resendWorker() ) ); |
159 | } | 159 | } |
160 | 160 | ||
161 | 161 | ||
162 | void DocumentList::resendWorker() | 162 | void DocumentList::resendWorker() |
163 | { | 163 | { |
164 | const QList<DocLnk> &list = d->dls.children(); | 164 | const QList<DocLnk> &list = d->dls.children(); |
165 | for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) | 165 | for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) |
166 | add( *(*it) ); | 166 | add( *(*it) ); |
167 | resume(); | 167 | resume(); |
168 | } | 168 | } |
169 | */ | 169 | */ |
170 | 170 | ||
171 | void DocumentList::rescan() | 171 | void DocumentList::rescan() |
172 | { | 172 | { |
173 | //qDebug("rescan"); | 173 | //qDebug("rescan"); |
174 | pause(); | 174 | pause(); |
175 | d->initialize(); | 175 | d->initialize(); |
176 | resume(); | 176 | resume(); |
177 | } | 177 | } |
178 | 178 | ||
179 | 179 | ||
180 | void DocumentList::timerEvent( QTimerEvent *te ) | 180 | void DocumentList::timerEvent( QTimerEvent *te ) |
181 | { | 181 | { |
182 | if ( te->timerId() == d->tid ) { | 182 | if ( te->timerId() == d->tid ) { |
183 | // Do 3 at a time | 183 | // Do 3 at a time |
184 | for (int i = 0; i < 3; i++ ) { | 184 | for (int i = 0; i < 3; i++ ) { |
185 | const DocLnk *lnk = d->iterate(); | 185 | const DocLnk *lnk = d->iterate(); |
186 | if ( lnk ) { | 186 | if ( lnk ) { |
187 | add( *lnk ); | 187 | add( *lnk ); |
188 | } else { | 188 | } else { |
189 | // stop when done | 189 | // stop when done |
190 | pause(); | 190 | pause(); |
191 | if ( d->serverGui ) | 191 | if ( d->serverGui ) |
192 | d->serverGui->documentScanningProgress( 100 ); | 192 | d->serverGui->documentScanningProgress( 100 ); |
193 | if ( d->needToSendAllDocLinks ) | 193 | if ( d->needToSendAllDocLinks ) |
194 | sendAllDocLinks(); | 194 | sendAllDocLinks(); |
195 | break; | 195 | break; |
196 | } | 196 | } |
197 | } | 197 | } |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | 201 | ||
202 | void DocumentList::reloadAppLnks() | 202 | void DocumentList::reloadAppLnks() |
203 | { | 203 | { |
204 | if ( d->sendAppLnks && d->serverGui ) { | 204 | if ( d->sendAppLnks && d->serverGui ) { |
205 | d->serverGui->applicationScanningProgress( 0 ); | 205 | d->serverGui->applicationScanningProgress( 0 ); |
206 | d->serverGui->allApplicationsRemoved(); | 206 | d->serverGui->allApplicationsRemoved(); |
207 | } | 207 | } |
208 | 208 | ||
209 | delete appLnkSet; | 209 | delete appLnkSet; |
210 | appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); | 210 | appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); |
211 | 211 | ||
212 | if ( d->sendAppLnks && d->serverGui ) { | 212 | if ( d->sendAppLnks && d->serverGui ) { |
213 | static QStringList prevTypeList; | 213 | static QStringList prevTypeList; |
214 | QStringList types = appLnkSet->types(); | 214 | QStringList types = appLnkSet->types(); |
215 | for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { | 215 | for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { |
216 | if ( !(*ittypes).isEmpty() ) { | 216 | if ( !(*ittypes).isEmpty() ) { |
217 | if ( !prevTypeList.contains(*ittypes) ) { | 217 | if ( !prevTypeList.contains(*ittypes) ) { |
218 | QString name = appLnkSet->typeName(*ittypes); | 218 | QString name = appLnkSet->typeName(*ittypes); |
219 | QPixmap pm = appLnkSet->typePixmap(*ittypes); | 219 | QPixmap pm = appLnkSet->typePixmap(*ittypes); |
220 | QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes); | 220 | QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes); |
221 | 221 | ||
222 | if (pm.isNull()) { | 222 | if (pm.isNull()) { |
223 | QImage img( Resource::loadImage( "UnknownDocument" ) ); | 223 | QImage img( Resource::loadImage( "UnknownDocument" ) ); |
224 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 224 | pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
225 | bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); | 225 | bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); |
226 | } | 226 | } |
227 | 227 | ||
228 | //qDebug("adding type %s", (*ittypes).latin1()); | 228 | //qDebug("adding type %s", (*ittypes).latin1()); |
229 | 229 | ||
230 | // ### our current launcher expects docs tab to be last | 230 | // ### our current launcher expects docs tab to be last |
231 | d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); | 231 | d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); |
232 | } | 232 | } |
233 | prevTypeList.remove(*ittypes); | 233 | prevTypeList.remove(*ittypes); |
234 | } | 234 | } |
235 | } | 235 | } |
236 | for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { | 236 | for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { |
237 | //qDebug("removing type %s", (*ittypes).latin1()); | 237 | //qDebug("removing type %s", (*ittypes).latin1()); |
238 | d->serverGui->typeRemoved(*ittypes); | 238 | d->serverGui->typeRemoved(*ittypes); |
239 | } | 239 | } |
240 | prevTypeList = types; | 240 | prevTypeList = types; |
241 | } | 241 | } |
242 | 242 | ||
243 | QListIterator<AppLnk> itapp( appLnkSet->children() ); | 243 | QListIterator<AppLnk> itapp( appLnkSet->children() ); |
244 | AppLnk* l; | 244 | AppLnk* l; |
245 | while ( (l=itapp.current()) ) { | 245 | while ( (l=itapp.current()) ) { |
246 | ++itapp; | 246 | ++itapp; |
247 | if ( d->sendAppLnks && d->serverGui ) | 247 | if ( d->sendAppLnks && d->serverGui ) |
248 | d->serverGui->applicationAdded( l->type(), *l ); | 248 | d->serverGui->applicationAdded( l->type(), *l ); |
249 | } | 249 | } |
250 | 250 | ||
251 | if ( d->sendAppLnks && d->serverGui ) | 251 | if ( d->sendAppLnks && d->serverGui ) |
252 | d->serverGui->applicationScanningProgress( 100 ); | 252 | d->serverGui->applicationScanningProgress( 100 ); |
253 | } | 253 | } |
254 | 254 | ||
255 | void DocumentList::reloadDocLnks() | 255 | void DocumentList::reloadDocLnks() |
256 | { | 256 | { |
257 | if ( !d->scanDocs ) | 257 | if ( !d->scanDocs ) |
258 | return; | 258 | return; |
259 | 259 | ||
260 | if ( d->sendDocLnks && d->serverGui ) { | 260 | if ( d->sendDocLnks && d->serverGui ) { |
261 | d->serverGui->documentScanningProgress( 0 ); | 261 | d->serverGui->documentScanningProgress( 0 ); |
262 | d->serverGui->allDocumentsRemoved(); | 262 | d->serverGui->allDocumentsRemoved(); |
263 | } | 263 | } |
264 | 264 | ||
265 | rescan(); | 265 | rescan(); |
266 | } | 266 | } |
267 | 267 | ||
268 | void DocumentList::linkChanged( QString arg ) | 268 | void DocumentList::linkChanged( QString arg ) |
269 | { | 269 | { |
270 | //qDebug( "linkchanged( %s )", arg.latin1() ); | 270 | //qDebug( "linkchanged( %s )", arg.latin1() ); |
271 | 271 | ||
272 | if ( arg.isNull() || Opie::Global::isAppLnkFileName( arg ) ) { | 272 | if ( arg.isNull() || Opie::Global::isAppLnkFileName( arg ) ) { |
273 | reloadAppLnks(); | 273 | reloadAppLnks(); |
274 | } else { | 274 | } else { |