Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/plugin/actionlist.cpp
Show First 20 Lines • Show All 180 Lines • ▼ Show 20 Line(s) | 180 | if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::TaskManager, service->entryPath())) { | |||
---|---|---|---|---|---|
181 | ContainmentInterface::addLauncher(appletInterface, ContainmentInterface::TaskManager, service->entryPath()); | 181 | ContainmentInterface::addLauncher(appletInterface, ContainmentInterface::TaskManager, service->entryPath()); | ||
182 | } | 182 | } | ||
183 | return true; | 183 | return true; | ||
184 | } | 184 | } | ||
185 | 185 | | |||
186 | return false; | 186 | return false; | ||
187 | } | 187 | } | ||
188 | 188 | | |||
189 | // HACK TEMP FIXME TODO IVAN | 189 | QString storageIdFromService(KService::Ptr service, bool &storageIdWasCut, QString &uncutStorageId) | ||
190 | QString storageIdFromService(KService::Ptr service) | | |||
191 | { | 190 | { | ||
192 | QString storageId = service->storageId(); | 191 | QString storageId = service->storageId(); | ||
193 | 192 | | |||
194 | if (storageId.startsWith("org.kde.")) { | | |||
195 | storageId = storageId.right(storageId.length() - 8); | | |||
196 | } | | |||
197 | | ||||
198 | if (storageId.endsWith(".desktop")) { | 193 | if (storageId.endsWith(".desktop")) { | ||
199 | storageId = storageId.left(storageId.length() - 8); | 194 | storageId = storageId.left(storageId.length() - 8); | ||
200 | } | 195 | } | ||
201 | 196 | | |||
197 | /* | ||||
198 | * HACK This is a temporary hack to make sure nothing breaks | ||||
199 | * after D10863 is landed. | ||||
200 | * | ||||
201 | * TODO Remove it when we depend on the Frameworks version | ||||
202 | * which contains the above revision. | ||||
203 | */ | ||||
204 | storageIdWasCut = false; | ||||
205 | uncutStorageId = storageId; | ||||
206 | | ||||
207 | if (storageId.startsWith("org.kde.")) { | ||||
208 | storageId = storageId.right(storageId.length() - 8); | ||||
209 | storageIdWasCut = true; | ||||
210 | } | ||||
211 | | ||||
202 | return storageId; | 212 | return storageId; | ||
203 | } | 213 | } | ||
204 | 214 | | |||
205 | QVariantList jumpListActions(KService::Ptr service) | 215 | QVariantList jumpListActions(KService::Ptr service) | ||
206 | { | 216 | { | ||
207 | QVariantList list; | 217 | QVariantList list; | ||
208 | 218 | | |||
209 | if (!service) { | 219 | if (!service) { | ||
Show All 18 Lines | |||||
228 | QVariantList recentDocumentActions(KService::Ptr service) | 238 | QVariantList recentDocumentActions(KService::Ptr service) | ||
229 | { | 239 | { | ||
230 | QVariantList list; | 240 | QVariantList list; | ||
231 | 241 | | |||
232 | if (!service) { | 242 | if (!service) { | ||
233 | return list; | 243 | return list; | ||
234 | } | 244 | } | ||
235 | 245 | | |||
236 | const QString storageId = storageIdFromService(service); | 246 | /* | ||
247 | * HACK This is a temporary hack to make sure nothing breaks | ||||
248 | * after D10863 is landed. | ||||
249 | * | ||||
250 | * TODO Remove it when we depend on the Frameworks version | ||||
251 | * which contains the above revision. | ||||
252 | */ | ||||
253 | bool storageIdWasCut; | ||||
254 | QString uncutStorageId; | ||||
255 | | ||||
256 | const QString storageId = storageIdFromService(service, storageIdWasCut, uncutStorageId); | ||||
237 | 257 | | |||
238 | if (storageId.isEmpty()) { | 258 | if (storageId.isEmpty()) { | ||
239 | return list; | 259 | return list; | ||
240 | } | 260 | } | ||
241 | 261 | | |||
242 | auto query = UsedResources | 262 | auto query = UsedResources | ||
243 | | RecentlyUsedFirst | 263 | | RecentlyUsedFirst | ||
244 | | Agent(storageId) | 264 | | Agent(storageId) | ||
245 | | Type::any() | 265 | | Type::any() | ||
246 | | Activity::current() | 266 | | Activity::current() | ||
247 | | Url::file(); | 267 | | Url::file(); | ||
248 | 268 | | |||
269 | if (storageIdWasCut) { | ||||
270 | query = query | Agent(uncutStorageId); | ||||
271 | } | ||||
272 | | ||||
249 | ResultSet results(query); | 273 | ResultSet results(query); | ||
250 | 274 | | |||
251 | ResultSet::const_iterator resultIt; | 275 | ResultSet::const_iterator resultIt; | ||
252 | resultIt = results.begin(); | 276 | resultIt = results.begin(); | ||
253 | 277 | | |||
254 | while (list.count() < 6 && resultIt != results.end()) { | 278 | while (list.count() < 6 && resultIt != results.end()) { | ||
255 | const QString resource = (*resultIt).resource(); | 279 | const QString resource = (*resultIt).resource(); | ||
256 | const QUrl url(resource); | 280 | const QUrl url(resource); | ||
Show All 29 Lines | |||||
286 | 310 | | |||
287 | bool handleRecentDocumentAction(KService::Ptr service, const QString &actionId, const QVariant &_argument) | 311 | bool handleRecentDocumentAction(KService::Ptr service, const QString &actionId, const QVariant &_argument) | ||
288 | { | 312 | { | ||
289 | if (!service) { | 313 | if (!service) { | ||
290 | return false; | 314 | return false; | ||
291 | } | 315 | } | ||
292 | 316 | | |||
293 | if (actionId == "_kicker_forgetRecentDocuments") { | 317 | if (actionId == "_kicker_forgetRecentDocuments") { | ||
294 | const QString storageId = storageIdFromService(service); | 318 | /* | ||
319 | * HACK This is a temporary hack to make sure nothing breaks | ||||
320 | * after D10863 is landed. | ||||
321 | * | ||||
322 | * TODO Remove it when we depend on the Frameworks version | ||||
323 | * which contains the above revision. | ||||
324 | */ | ||||
325 | bool storageIdWasCut; | ||||
326 | QString uncutStorageId; | ||||
327 | | ||||
328 | const QString storageId = storageIdFromService(service, storageIdWasCut, uncutStorageId); | ||||
295 | 329 | | |||
296 | if (storageId.isEmpty()) { | 330 | if (storageId.isEmpty()) { | ||
297 | return false; | 331 | return false; | ||
298 | } | 332 | } | ||
299 | 333 | | |||
300 | auto query = UsedResources | 334 | auto query = UsedResources | ||
301 | | Agent(storageId) | 335 | | Agent(storageId) | ||
302 | | Type::any() | 336 | | Type::any() | ||
303 | | Activity::current() | 337 | | Activity::current() | ||
304 | | Url::file(); | 338 | | Url::file(); | ||
305 | 339 | | |||
340 | if (storageIdWasCut) { | ||||
341 | query = query | Agent(uncutStorageId); | ||||
342 | } | ||||
343 | | ||||
306 | KAStats::forgetResources(query); | 344 | KAStats::forgetResources(query); | ||
broulik: I would prefer `mid(8)` | |||||
307 | 345 | | |||
308 | return false; | 346 | return false; | ||
309 | } | 347 | } | ||
310 | 348 | | |||
311 | QString argument = _argument.toString(); | 349 | QString argument = _argument.toString(); | ||
312 | 350 | | |||
313 | if (argument.isEmpty()) { | 351 | if (argument.isEmpty()) { | ||
314 | return false; | 352 | return false; | ||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |
I would prefer mid(8)