[Kde-pim] Re: Review Request: Akonadi Trashhandling

Christian Mollekopf chrigi_1 at fastmail.fm
Fri Apr 8 12:19:05 BST 2011


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/100836/
-----------------------------------------------------------

(Updated April 8, 2011, 11:19 a.m.)


Review request for KDEPIM, KDEPIM-Libraries and Volker Krause.


Changes
-------

updated the @author and @since info


Summary
-------

So, I think I have finally a first version of the Trashhandling classes ready.
It's basically all new classes except for some new standardactions. 
Can I commit it like this in a single commit to master?


I didn't write any unittests so far, but I plan to do that once I can be sure that there are no major changes to the api anymore.

The following writeup could probably go into the wiki somewhere.


The trashhandling consists of the following parts:

TrashJob:
Mark entity as trash with the EntityDeletedAttribute and moves it to a configured trash collection (if configured).

The default behaviour is to move the item to the trash collection which is configured in TrashSettings. If this trash collection is not available, the entity is kept in place.

All sub entites of a collection which is marked as trash are also marked as trash, and get the parent collection of the collection which was marked as trash as restore collection. This ensures that it is possible to restore items from trash, which were originally moved to trash together with the parent collection.

The job has also an option to automatically delete items which are already marked as trash.

RestoreJob:
Restore the entity from the trash collection to the original collection and remove the EntityDeletedAttribute.

By default the RestoreJob tries to move the entity back to the original location, which is saved in the EntityDeletedAttribute.
If this collection is not available anymore, it tries the original resource root as fallback, if also not available it aborts.

For this case it is possible to configure a special restore collection on the job, to which the item is restored.

If the move was successful the EntityDeletedAttribute is removed from the entity (and from all subentities).

EntityDeletedAttribute:
Marks the entity as deleted and stores the restore collection/resource.
Resources could map this flag to an appropriate flag as the MarkAsDeleted flag in IMAP.

TrashSettings:
Store a trashcollection for a resource.

In the future further trash related settings, as the time before the janitor agent deletes items could be stored here.

TODO: atm. the settings are never removed. Even if the configured resource or trash collection is removed.

TrashFilterProxyModel:
Either shows all items with the EntityDeletedAttribute or hides all entities with the EntityDeletedAttribute.
It is using a KRecursiveProxyModel, so also trash items which are in a non trash collection are shown in the trash.

StandardActions:
Provides 6 standard actions:
-MoveItemToTrash
-MoveCollectionToTrash
-RestoreItemFromTrash
-RestoreCollectionFromTrash
-MoveToTrashRestoreCollection
-MoveToTrashRestoreItem

While the first 4 are trivial, the last two provide a single action, which changes its behaviour depending if the EntityDeletedAttribute is set or not. As it doesn't make sense to restore entites which are not in trash or move entities to trash which are in trash, I believe it is the most common usecase and is what I use myself.
All new actions need the EntityDeletedAttribute fetched in order to work properly.
I had to add some bits to the internal structure of the standardactionmanager to make it possible to change description/icon/etc. for a single action, everything existing should continue to work as expected though.


Trash Janitor Agent (TODO):
Goes trough all collections, and deletes items after a configured period of time, if they are marked as trash.
This configuration is in TrashSettings on a per resource basis, but could be overridden by a configuration in the EntityDeletedAttribute

This is not work in progress atm. but more a concept. I also don't plan to add this anytime soon, so feel free to do it if you need it now.


Diffs (updated)
-----

  akonadi/CMakeLists.txt d65100d36c7062d075b7f550769386f8a58fcbaf 
  akonadi/actionstatemanager.cpp f3b15fa84bcf26d106314a6e0929e0e2a73471cd 
  akonadi/actionstatemanager_p.h e21857b4d63bc626785587c1482991fa2be61638 
  akonadi/attributefactory.cpp 05ce60ca1f1ea8792fc2f73d7889b4df6ad20080 
  akonadi/entitydeletedattribute.h PRE-CREATION 
  akonadi/entitydeletedattribute.cpp PRE-CREATION 
  akonadi/standardactionmanager.h fca3f9e76c7e83c9e50a7c5a0616d0a7f5d9dec7 
  akonadi/standardactionmanager.cpp 511e741cca5260f91c3ca5f1ea1ba3c3a3337fa8 
  akonadi/trashfilterproxymodel.h PRE-CREATION 
  akonadi/trashfilterproxymodel.cpp PRE-CREATION 
  akonadi/trashjob.h PRE-CREATION 
  akonadi/trashjob.cpp PRE-CREATION 
  akonadi/trashrestorejob.h PRE-CREATION 
  akonadi/trashrestorejob.cpp PRE-CREATION 
  akonadi/trashsettings.h PRE-CREATION 
  akonadi/trashsettings.cpp PRE-CREATION 

Diff: http://git.reviewboard.kde.org/r/100836/diff


Testing
-------

Only manual testing so far with a little testapplication.


Thanks,

Christian

_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list