Use the SMAM action for Mark All As Read. First step to clean up foldercollection from kmail deps, so it can be shared by deskopt & mobile for the expiry dialog.

svn path=/trunk/KDE/kdepim/kmail/; revision=1178220
wilder-work
Andras Mantia 16 years ago
parent a6cee0d51e
commit 53ef9a82a6
  1. 33
      foldercollection.cpp
  2. 4
      foldercollection.h
  3. 8
      kmail_part.rc
  4. 19
      kmmainwidget.cpp
  5. 8
      kmmainwidget.h
  6. 8
      kmmainwin.rc

@ -28,7 +28,6 @@
#include <akonadi/itemfetchscope.h>
#include <akonadi/collectiondeletejob.h>
#include <kio/jobuidelegate.h>
#include "kmcommands.h"
#include "expirejob.h"
#include "foldershortcutactionmanager.h"
@ -393,38 +392,6 @@ void FolderCollection::daysToExpire(int& unreadDays, int& readDays) {
readDays = ::daysToExpire( getReadExpireAge(), getReadExpireUnits() );
}
void FolderCollection::markUnreadAsRead()
{
if ( mCollection.isValid() ) {
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( mCollection,this );
job->fetchScope().setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
connect( job, SIGNAL( result( KJob* ) ), this, SLOT( slotMarkAsReadfetchDone( KJob* ) ) );
}
}
void FolderCollection::slotMarkAsReadfetchDone( KJob * job)
{
if ( job->error() )
return;
Akonadi::ItemFetchJob *fjob = dynamic_cast<Akonadi::ItemFetchJob*>( job );
Q_ASSERT( fjob );
Akonadi::Item::List items;
foreach( const Akonadi::Item &item, fjob->items() ) {
MessageStatus status;
status.setStatusFromFlags( item.flags() );
if (status.isUnread()) {
items.append( item );
}
}
if ( items.empty() )
return;
KMCommand *command = new KMSetStatusCommand( MessageStatus::statusRead(), items );
command->start();
}
void FolderCollection::removeCollection()
{
Akonadi::CollectionDeleteJob *job = new Akonadi::CollectionDeleteJob( mCollection );

@ -195,15 +195,11 @@ public:
QString mailingListPostAddress() const;
/** Mark all new and unread messages as read. */
void markUnreadAsRead();
void removeCollection();
void expireOldMessages( bool immediate );
protected slots:
void slotIdentitiesChanged();
void slotMarkAsReadfetchDone( KJob * job);
void slotDeletionCollectionResult( KJob *job );
signals:

@ -2,7 +2,7 @@
the same menu entries at the same place in KMail and Kontact -->
<!DOCTYPE kpartgui>
<kpartgui version="459" name="kmmainwin" >
<kpartgui version="460" name="kmmainwin" >
<MenuBar>
<Menu noMerge="1" name="file" >
<text>&amp;File</text>
@ -96,7 +96,7 @@
<text>F&amp;older</text>
<Action name="akonadi_collection_create" />
<Separator/>
<Action name="mark_all_as_read" />
<Action name="akonadi_mark_all_as_read" />
<Separator/>
<Action name="akonadi_collection_sync" />
<Separator/>
@ -192,7 +192,7 @@
</MenuBar>
<Menu name="akonadi_favoriteview_contextmenu">
<Action name="akonadi_collection_sync"/>
<Action name="mark_all_as_read" />
<Action name="akonadi_mark_all_as_read" />
<Action name="search_messages" />
<Action name="move_to_trash" />
<Separator/>
@ -211,7 +211,7 @@
<Menu name="akonadi_collectionview_contextmenu">
<ActionList name="akonadi_collection_sync_actionlist"/>
<Separator/>
<Action name="mark_all_as_read" />
<Action name="akonadi_mark_all_as_read" />
<Action name="search_messages" />
<ActionList name="outbox_folder_actionlist" />
<Action name="akonadi_move_all_to_trash"/>

@ -1560,15 +1560,6 @@ void KMMainWidget::slotDelayedRemoveFolder( KJob *job )
mCurrentFolder.clear();
}
//-----------------------------------------------------------------------------
void KMMainWidget::slotMarkAllAsRead()
{
if (!mCurrentFolder)
return;
mCurrentFolder->markUnreadAsRead();
updateMessageActions();
}
//-----------------------------------------------------------------------------
void KMMainWidget::slotExpireAll()
{
@ -3077,10 +3068,6 @@ void KMMainWidget::setupActions()
connect( mShowFolderShortcutDialogAction, SIGNAL( triggered( bool ) ),
SLOT( slotShowFolderShortcutDialog() ) );
mMarkAllAsReadAction = new KAction(KIcon("mail-mark-read"), i18n("Mark All Messages as &Read"), this);
actionCollection()->addAction("mark_all_as_read", mMarkAllAsReadAction );
connect(mMarkAllAsReadAction, SIGNAL(triggered(bool)), SLOT(slotMarkAllAsRead()));
// FIXME: this action is not currently enabled in the rc file, but even if
// it were there is inconsistency between the action name and action.
// "Expiration Settings" implies that this will lead to a settings dialogue
@ -3756,11 +3743,6 @@ void KMMainWidget::updateMessageActionsDelayed()
mApplyFilterActionsMenu->setEnabled( count );
}
// This needs to be updated more often, so it is in its method.
void KMMainWidget::updateMarkAsReadAction()
{
mMarkAllAsReadAction->setEnabled( mCurrentFolder && mCurrentFolder->isValid() && (mCurrentFolder->statistics().unreadCount() > 0) );
}
void KMMainWidget::slotAkonadiStandardActionUpdated()
{
@ -3875,7 +3857,6 @@ void KMMainWidget::updateFolderMenu()
folderWithContent &&
!KMail::Util::isVirtualCollection( mCurrentFolder->collection() ) );
updateMarkAsReadAction();
// the visual ones only make sense if we are showing a message list
mPreferHtmlAction->setEnabled( mFolderTreeWidget->folderTreeView()->currentFolder().isValid() );

@ -327,7 +327,6 @@ class KMAIL_EXPORT KMMainWidget : public QWidget
void slotShowFolderShortcutDialog();
void slotExpireFolder();
void slotExpireAll();
void slotMarkAllAsRead();
void slotArchiveFolder();
void slotRemoveFolder();
void slotDelayedRemoveFolder( KJob* );
@ -410,11 +409,6 @@ class KMAIL_EXPORT KMMainWidget : public QWidget
/** Update html and threaded messages preferences in Folder menu. */
void updateFolderMenu();
/**
Enable or disable the "mark all as read" action. Needs to happen more
often than the other updates and is therefor in its own method.
*/
void updateMarkAsReadAction();
/** Settings menu */
@ -597,7 +591,7 @@ private:
KMail::SearchWindow *mSearchWin;
KAction *mExpireFolderAction,
*mMarkAllAsReadAction, *mFolderMailingListPropertiesAction,
*mFolderMailingListPropertiesAction,
*mShowFolderShortcutDialogAction,
*mArchiveFolderAction,
*mPostToMailinglistAction;

@ -2,7 +2,7 @@
the same menu entries at the same place in KMail and Kontact -->
<!DOCTYPE kpartgui>
<kpartgui version="459" name="kmmainwin" >
<kpartgui version="460" name="kmmainwin" >
<MenuBar>
<Menu noMerge="1" name="file" >
<text>&amp;File</text>
@ -96,7 +96,7 @@
<text>F&amp;older</text>
<Action name="akonadi_collection_create" />
<Separator/>
<Action name="mark_all_as_read" />
<Action name="akonadi_mark_all_as_read" />
<Separator/>
<Action name="akonadi_collection_sync" />
<Separator/>
@ -192,7 +192,7 @@
</MenuBar>
<Menu name="akonadi_favoriteview_contextmenu">
<Action name="akonadi_collection_sync"/>
<Action name="mark_all_as_read" />
<Action name="akonadi_mark_all_as_read" />
<Action name="search_messages" />
<Action name="move_to_trash" />
<Separator/>
@ -211,7 +211,7 @@
<Menu name="akonadi_collectionview_contextmenu">
<ActionList name="akonadi_collection_sync_actionlist"/>
<Separator/>
<Action name="mark_all_as_read" />
<Action name="akonadi_mark_all_as_read" />
<Action name="search_messages" />
<ActionList name="outbox_folder_actionlist" />
<Action name="akonadi_move_all_to_trash"/>

Loading…
Cancel
Save